Re: [lng-odp] [PATCH 1/2] odp_pktio_open loop back interface

2014-11-26 Thread Alexandru Badicioiu
On 25 November 2014 at 18:24, Maxim Uvarov maxim.uva...@linaro.org wrote:

 Define special name for loop back interface. That interface
 can be used mostly for testing. Each implementation can interpret
 that loop0 to any other device.

[Alex] A few words about what is expected from this interface in term of
functionality would be beneficial for people who did not participate to the
discussion. I think the name is not the best one - in Linux loop0 is a
well-known block device.


 Signed-off-by: Maxim Uvarov maxim.uva...@linaro.org
 ---
  platform/linux-generic/include/api/odp_packet_io.h | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

 diff --git a/platform/linux-generic/include/api/odp_packet_io.h
 b/platform/linux-generic/include/api/odp_packet_io.h
 index 667395c..c388c41 100644
 --- a/platform/linux-generic/include/api/odp_packet_io.h
 +++ b/platform/linux-generic/include/api/odp_packet_io.h
 @@ -33,7 +33,8 @@ extern C {
   * Open an ODP packet IO instance
   *
   * @param devPacket IO device
 - * @param pool   Pool to use for packet IO
 + *  loop0 is specially reserved name for loop back interface.
 +* @param pool   Pool to use for packet IO
   *
   * @return ODP packet IO handle or ODP_PKTIO_INVALID on error
   */
 --
 1.8.5.1.163.gd7aced9


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

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


Re: [lng-odp] [RFC] More lenient packet parsing in linux

2014-11-26 Thread Shmulik Ladkani
On Tue, 25 Nov 2014 15:04:53 -0600 Bill Fischofer bill.fischo...@linaro.org 
wrote:
 These functions are scheduled for rework as part of the packet API
 revisions.  Will be sure to address this point as part of that rework.

Thanks.

If there's a concensus the 'len  ODPH_ETH_LEN_MIN' is too strict, any
reason not to submit a tiny patch that removes this sanity test?

This could be beneficial, as your patchset would therefore not
carry this logical change, but instead focus on packet API changes.

Regards,
Shmulik

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


Re: [lng-odp] [PATCH 2/2] linux-generic: odp_pktio_open loop0 support

2014-11-26 Thread Ola Liljedahl
On 26 November 2014 at 09:39, Alexandru Badicioiu
alexandru.badici...@linaro.org wrote:
 This patch has no description. The title is not self explanatory either.
 Also the existence of eth0 should be verified  before mapping the loop0 to
 eth0 - some platforms may use other interface names (e.g. fmX-gby for FSL
 DPAA platforms).  I think a better solution would be to enumerate the
 available interfaces  and pick a suitable one.
I second that opinion. On my ChromeBook (great development
platforms!), the only Ethernet-like
interface is called mlan0.



 On 25 November 2014 at 18:24, Maxim Uvarov maxim.uva...@linaro.org wrote:

 Signed-off-by: Maxim Uvarov maxim.uva...@linaro.org
 ---
  platform/linux-generic/odp_packet_io.c | 27 +++
  1 file changed, 27 insertions(+)

 diff --git a/platform/linux-generic/odp_packet_io.c
 b/platform/linux-generic/odp_packet_io.c
 index c523350..501b2e9 100644
 --- a/platform/linux-generic/odp_packet_io.c
 +++ b/platform/linux-generic/odp_packet_io.c
 @@ -156,6 +156,33 @@ odp_pktio_t odp_pktio_open(const char *dev,
 odp_buffer_pool_t pool)
 pktio_entry_t *pktio_entry;
 int res;
 int fanout = 1;
 +   char loop0[IFNAMSIZ] = eth0; /* linux-generic loop0 device*/
This comment is strange. If ODP uses an interface like eth0, how can
that be a loopback interface?
Won't packet I/O using this interface be mapped onto the real Ethernet
interface and sent onto the physical link?

-- Ola

 +   char *loop_hint;
 +
 +   if (strlen(dev)  IFNAMSIZ) {
 +   /* ioctl names limitation */
 +   ODP_ERR(pktio name %s is too big, limit is %d bytes\n,
 +   dev, IFNAMSIZ);
 +   return ODP_PKTIO_INVALID;
 +   }
 +
 +   loop_hint = getenv(ODP_PKTIO_LOOPDEV);
 +   if (!strncmp(dev, loop0, 5)) {
 +   if (loop_hint  (strlen(loop_hint)  0)) {
 +   if (strlen(loop_hint)  IFNAMSIZ) {
 +   ODP_ERR(pktio name %s is too big, limit
 is %d bytes\n,
 +   loop_hint, IFNAMSIZ);
 +   return ODP_PKTIO_INVALID;
 +   }
 +
 +   memset(loop0, 0, IFNAMSIZ);
 +   memcpy(loop0, loop_hint, strlen(loop_hint));
 +   ODP_DBG(pktio rename loop0 to %s\n, loop_hint);
 +   } else {
 +   ODP_DBG(pktio rename loop0 to eth0\n);
 +   dev = loop0;
 +   }
 +   }

 id = alloc_lock_pktio_entry();
 if (id == ODP_PKTIO_INVALID) {
 --
 1.8.5.1.163.gd7aced9


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



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


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


Re: [lng-odp] [RFC] More lenient packet parsing in linux

2014-11-26 Thread Ciprian Barbu
On Wed, Nov 26, 2014 at 11:16 AM, Ola Liljedahl
ola.liljed...@linaro.org wrote:
 I think this check is too strict and should be removed.

 I remember we had a discussion about this many months ago and already
 then I was of the opinion that this check is unnecessary and not very
 beneficial.

 The 64-byte limit originates from Ethernet *link* restrictions and
 doesn't have anything to do with parsing packets. We want to be able
 to use virtual interfaces even in production systems, they are
 actually some very good reasons for that.

There was a long discussion on this topic on end of April, there are
no archives for that it seems. I found this post which contains some
snippets:
http://lists.linaro.org/pipermail/lng-odp/2014-April/24.html

But the conclusion of that discussion was that Petri wanted to have
ODP work with Ethernet cards only, no WiFi (which also generate frames
shorter than 60/64) and no other software originated packets. That's
why the restrictions was kept in place and instead a bug was opened
saying that ODP cannot work with wireless network cards.

With the addition of classification support in linux-generic this
limitation should be revised IMO.

/Ciprian


 -- Ola

 On 26 November 2014 at 09:41, Shmulik Ladkani shmulik.ladk...@gmail.com 
 wrote:
 On Tue, 25 Nov 2014 15:04:53 -0600 Bill Fischofer 
 bill.fischo...@linaro.org wrote:
 These functions are scheduled for rework as part of the packet API
 revisions.  Will be sure to address this point as part of that rework.

 Thanks.

 If there's a concensus the 'len  ODPH_ETH_LEN_MIN' is too strict, any
 reason not to submit a tiny patch that removes this sanity test?

 This could be beneficial, as your patchset would therefore not
 carry this logical change, but instead focus on packet API changes.

 Regards,
 Shmulik

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

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

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


[lng-odp] [PATCH v2] Classification: APIs deferred from ODP v1.0

2014-11-26 Thread Balasubramanian Manoharan
This patch removes Classification APIs which have been deferred from ODP v1.0
The following is the list of the deferred APIs
* odp_cos_set_queue_group
* odp_cos_set_pool
* odp_cos_set_headroom
* odp_cos_flow_set
* odp_cos_flow_is_set
* odp_cos_class_flow_signature
* odp_cos_port_flow_signature

Signed-off-by: Balasubramanian Manoharan bala.manoha...@linaro.org
---
V2: This patch is modified as independantly compilable unit
 .../linux-generic/include/api/odp_classification.h | 106 +
 platform/linux-generic/odp_classification.c|  48 +-
 2 files changed, 8 insertions(+), 146 deletions(-)

diff --git a/platform/linux-generic/include/api/odp_classification.h 
b/platform/linux-generic/include/api/odp_classification.h
index cc5d84a..64ad73f 100644
--- a/platform/linux-generic/include/api/odp_classification.h
+++ b/platform/linux-generic/include/api/odp_classification.h
@@ -48,6 +48,9 @@ typedef uint32_t odp_flowsig_t;
 */
 #define ODP_COS_INVALID((odp_cos_t)~0)
 
+/** Maximum ClassOfService name length in chars */
+#define ODP_COS_NAME_LEN 32
+
 /**
  * Class-of-service packet drop policies
  */
@@ -110,33 +113,6 @@ int odp_cos_destroy(odp_cos_t cos_id);
 int odp_cos_set_queue(odp_cos_t cos_id, odp_queue_t queue_id);
 
 /**
- * Assign a homogenous queue-group to a class-of-service.
- *
- * @param[in]  cos_id  class-of-service instance
- * @param[in]  queue_group_id  Identifier of the queue group to receive packets
- * associated with this class of service.
- *
- * @return 0 on success, -1 on error.
- */
-int odp_cos_set_queue_group(odp_cos_t cos_id,
-   odp_queue_group_t queue_group_id);
-
-/**
- * Assign packet buffer pool for specific class-of-service
- *
- * @param[in]  cos_id  class-of-service instance.
- * @param[in]  pool_id Buffer pool identifier where all packet buffers
- * will be sourced to store packet that
- * belong to this class of service.
- *
- * @return 0 on success, -1 on error.
- *
- * @note Optional.
- */
-int odp_cos_set_pool(odp_cos_t cos_id, odp_buffer_pool_t pool_id);
-
-
-/**
  * Assign packet drop policy for specific class-of-service
  *
  * @param[in]  cos_id  class-of-service instance.
@@ -203,21 +179,6 @@ int odp_pktio_set_skip(odp_pktio_t pktio_in, size_t 
offset);
 int odp_pktio_set_headroom(odp_pktio_t pktio_in, size_t headroom);
 
 /**
- * Specify per-cos buffer headroom
- *
- * @param[in]  cos_id  Class-of-service instance
- * @param[in]  headroomNumber of bytes of space preceding packet
- * data to reserve for use as headroom.
- * Must not exceed the implementation
- * defined ODP_PACKET_MAX_HEADROOM.
- *
- * @return 0 on success, -1 on error.
- *
- * @note Optional.
- */
-int odp_cos_set_headroom(odp_cos_t cos_id, size_t headroom);
-
-/**
  * Request to override per-port class of service
  * based on Layer-2 priority field if present.
  *
@@ -263,60 +224,6 @@ int odp_cos_with_l3_qos(odp_pktio_t pktio_in,
 typedef uint16_t odp_cos_flow_set_t;
 
 /**
- * Set a member of the flow signature fields data set
- */
-static inline
-odp_cos_flow_set_t odp_cos_flow_set(odp_cos_flow_set_t set,
-   odp_cos_hdr_flow_fields_e field)
-{
-   return set | (1U  field);
-}
-
-/**
- * Test a member of the flow signature fields data set
- */
-static inline bool
-odp_cos_flow_is_set(odp_cos_flow_set_t set, odp_cos_hdr_flow_fields_e field)
-{
-   return (set  (1U  field)) != 0;
-}
-
-/**
- * Set up set of headers used to calculate a flow signature
- * based on class-of-service.
- *
- * @param[in]  cos_id  Class of service instance identifier
- * @param[in]  req_data_setRequested data-set for
- * flow signature calculation
- *
- * @return Data-set that was successfully applied.
- * All-zeros data set indicates a failure to
- * assign any of the requested fields,
- * or other error.
- * @note Optional.
- */
-odp_cos_flow_set_t
-odp_cos_class_flow_signature(odp_cos_t cos_id,
-odp_cos_flow_set_t req_data_set);
-
-/**
- * Set up set of headers used to calculate a flow signature
- * based on ingress port.
- *
- * @param[in]  pktio_inIngress port identifier
- * @param[in]  req_data_setRequested data-set for
- * flow signature calculation
- *
- * @return Data-set that was successfully applied.
- * An all-zeros data-set indicates a failure to
- * assign any of the requested fields,
- * or other error.
- */
-odp_cos_flow_set_t

Re: [lng-odp] [PATCH] examples: remove the use of ODP_UNUSED

2014-11-26 Thread Ciprian Barbu
On Mon, Nov 24, 2014 at 9:19 PM, Mike Holmes mike.hol...@linaro.org wrote:
 ODP_UNUSED should be used internally to an ODP implementation and not by
 an application. The declaration should never have specified ODP_UNUSED for
 find_ipsec_cache_entry_out()

 Signed-off-by: Mike Holmes mike.hol...@linaro.org

Reviewed-by: Ciprian Barbu ciprian.ba...@linaro.org

 ---
  example/example_debug.h | 5 +
  example/ipsec/odp_ipsec.c   | 5 +++--
  example/ipsec/odp_ipsec_cache.c | 2 +-
  example/ipsec/odp_ipsec_cache.h | 2 +-
  4 files changed, 10 insertions(+), 4 deletions(-)

 diff --git a/example/example_debug.h b/example/example_debug.h
 index b83667c..dd3aa7f 100644
 --- a/example/example_debug.h
 +++ b/example/example_debug.h
 @@ -78,6 +78,11 @@ do { \
 EXAMPLE_LOG(EXAMPLE_LOG_ABORT, fmt, ##__VA_ARGS__)

  /**
 + * Intentionally unused variables to functions
 + */
 +#define EXAMPLE_UNUSED __attribute__((__unused__))
 +
 +/**
   * @}
   */

 diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c
 index ec115fc..ad62436 100644
 --- a/example/ipsec/odp_ipsec.c
 +++ b/example/ipsec/odp_ipsec.c
 @@ -619,7 +619,8 @@ void initialize_intf(char *intf)
   * @return PKT_CONTINUE if good, supported packet else PKT_DROP
   */
  static
 -pkt_disposition_e do_input_verify(odp_packet_t pkt, pkt_ctx_t *ctx 
 ODP_UNUSED)
 +pkt_disposition_e do_input_verify(odp_packet_t pkt,
 + pkt_ctx_t *ctx EXAMPLE_UNUSED)
  {
 if (odp_unlikely(odp_packet_error(pkt)))
 return PKT_DROP;
 @@ -1037,7 +1038,7 @@ pkt_disposition_e do_ipsec_out_finish(odp_packet_t pkt,
   * @return NULL (should never return)
   */
  static
 -void *pktio_thread(void *arg ODP_UNUSED)
 +void *pktio_thread(void *arg EXAMPLE_UNUSED)
  {
 int thr;
 odp_packet_t pkt;
 diff --git a/example/ipsec/odp_ipsec_cache.c b/example/ipsec/odp_ipsec_cache.c
 index fb53bb6..7a0c813 100644
 --- a/example/ipsec/odp_ipsec_cache.c
 +++ b/example/ipsec/odp_ipsec_cache.c
 @@ -171,7 +171,7 @@ ipsec_cache_entry_t *find_ipsec_cache_entry_in(uint32_t 
 src_ip,

  ipsec_cache_entry_t *find_ipsec_cache_entry_out(uint32_t src_ip,
 uint32_t dst_ip,
 -   uint8_t proto ODP_UNUSED)
 +   uint8_t proto EXAMPLE_UNUSED)
  {
 ipsec_cache_entry_t *entry = ipsec_cache-out_list;

 diff --git a/example/ipsec/odp_ipsec_cache.h b/example/ipsec/odp_ipsec_cache.h
 index 5791cf8..2cbaabd 100644
 --- a/example/ipsec/odp_ipsec_cache.h
 +++ b/example/ipsec/odp_ipsec_cache.h
 @@ -118,7 +118,7 @@ ipsec_cache_entry_t *find_ipsec_cache_entry_in(uint32_t 
 src_ip,
   */
  ipsec_cache_entry_t *find_ipsec_cache_entry_out(uint32_t src_ip,
 uint32_t dst_ip,
 -   uint8_t proto ODP_UNUSED);
 +   uint8_t proto);

  #ifdef __cplusplus
  }
 --
 2.1.0


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

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


Re: [lng-odp] [PATCH v2] DEPENDENCIES: Update CUnit instructions

2014-11-26 Thread Ciprian Barbu
On Wed, Nov 26, 2014 at 12:11 AM, Mike Holmes mike.hol...@linaro.org wrote:
 Signed-off-by: Mike Holmes mike.hol...@linaro.org

Just a couple of nits, otherwise you can have my Reviewed-by

 ---

 Add t to ar.bz2

  DEPENDENCIES | 18 ++
  1 file changed, 14 insertions(+), 4 deletions(-)

 diff --git a/DEPENDENCIES b/DEPENDENCIES
 index f70a1d4..bc39889 100644
 --- a/DEPENDENCIES
 +++ b/DEPENDENCIES
 @@ -78,23 +78,33 @@ Prerequisites for building the OpenDataPlane (ODP) API

  4.0 Packages needed to build API tests

 -   Cunit test framework
 +   Cunit test framework version 2.1-3 is required
 Cunit prvodes a framework to run the API test suite that proves 
 conformance to the
 ODP API. The home page http://cunit.sourceforge.net/doc/introduction.html

  4.1 Native Cunit install

 -   # Debian/Ubuntu
 +   # Debian/Ubuntu check it is 2.1-3
 $ apt-get install libcunit1-dev

 -4.2 Cross compile of Cunit
 +4.2 Built from src
 +
 +   export CUNIT_VERSION=2.1-3
 +   curl -sSOL 
 http://sourceforge.net/projects/cunit/files/CUnit/${CUNIT_VERSION}/CUnit-${CUNIT_VERSION}.tar.bz2
 +   tar -jxf *.bz2

I would suggest changing this to CUnit*.bz2. For example I have a dir
with package source archives. If I use your command it may extract 100
archives instead of just one.

 +   cd CUnit*
 +   ./bootstrap
 +   make install
 +   #In Step 4.4 use --with-cunit-path=/home/your name/CUnitHome

nit: although it's to be changed, you should avoid using spaces inside
a path. Instead use /home/your_name or better /home/user

 +
 +4.3 Cross compile of Cunit

 $ git svn clone http://svn.code.sf.net/p/cunit/code/trunk cunit-code
 $ cd cunit-code
 $ ./bootstrap
 $ ./configure --host=arm-linux-gnueabihf 
 --prefix=/home/user/src/install-cunit

 -4.3 Using Cunit with ODP
 +4.4 Using Cunit with ODP
 $ Add the configuration option to the regular configuration options
 ./configure  --enable-cunit  #if cunit is in the PATH
 ./configure  --with-cunit-path=DIR #only if you need a path to Cunit libs 
 and headers
 --
 2.1.0


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

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


Re: [lng-odp] [PATCH v2] DEPENDENCIES: Update CUnit instructions

2014-11-26 Thread Ciprian Barbu
On Wed, Nov 26, 2014 at 12:29 PM, Ciprian Barbu
ciprian.ba...@linaro.org wrote:
 On Wed, Nov 26, 2014 at 12:11 AM, Mike Holmes mike.hol...@linaro.org wrote:
 Signed-off-by: Mike Holmes mike.hol...@linaro.org

 Just a couple of nits, otherwise you can have my Reviewed-by

 ---

 Add t to ar.bz2

  DEPENDENCIES | 18 ++
  1 file changed, 14 insertions(+), 4 deletions(-)

 diff --git a/DEPENDENCIES b/DEPENDENCIES
 index f70a1d4..bc39889 100644
 --- a/DEPENDENCIES
 +++ b/DEPENDENCIES
 @@ -78,23 +78,33 @@ Prerequisites for building the OpenDataPlane (ODP) API

  4.0 Packages needed to build API tests

 -   Cunit test framework
 +   Cunit test framework version 2.1-3 is required
 Cunit prvodes a framework to run the API test suite that proves 
 conformance to the
 ODP API. The home page http://cunit.sourceforge.net/doc/introduction.html

  4.1 Native Cunit install

 -   # Debian/Ubuntu
 +   # Debian/Ubuntu check it is 2.1-3
 $ apt-get install libcunit1-dev

 -4.2 Cross compile of Cunit
 +4.2 Built from src
 +
 +   export CUNIT_VERSION=2.1-3
 +   curl -sSOL 
 http://sourceforge.net/projects/cunit/files/CUnit/${CUNIT_VERSION}/CUnit-${CUNIT_VERSION}.tar.bz2
 +   tar -jxf *.bz2

 I would suggest changing this to CUnit*.bz2. For example I have a dir
 with package source archives. If I use your command it may extract 100
 archives instead of just one.

 +   cd CUnit*
 +   ./bootstrap
 +   make install
 +   #In Step 4.4 use --with-cunit-path=/home/your name/CUnitHome

 nit: although it's to be changed, you should avoid using spaces inside
 a path. Instead use /home/your_name or better /home/user

Or even better $HOME/CUnitHome


 +
 +4.3 Cross compile of Cunit

 $ git svn clone http://svn.code.sf.net/p/cunit/code/trunk cunit-code
 $ cd cunit-code
 $ ./bootstrap
 $ ./configure --host=arm-linux-gnueabihf 
 --prefix=/home/user/src/install-cunit

 -4.3 Using Cunit with ODP
 +4.4 Using Cunit with ODP
 $ Add the configuration option to the regular configuration options
 ./configure  --enable-cunit  #if cunit is in the PATH
 ./configure  --with-cunit-path=DIR #only if you need a path to Cunit 
 libs and headers
 --
 2.1.0


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

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


Re: [lng-odp] [PATCH] netdev-odp: Use VLOG_ERR instead of ODP_ERR

2014-11-26 Thread Taras Kondratiuk

On 11/25/2014 06:54 PM, Mike Holmes wrote:

Taras is submitting a patch that allows you to replace the output stream
for ODP_ERR etc with the applications prefered stream - see
https://mail.google.com/mail/u/1/#inbox/149e780e4e57d70c


Taking into account that ODP_ERR() is not a part of public API Zoltan's
patch looks correct. OVS should not use ODP_ERR().

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


Re: [lng-odp] [PATCH] DEPENDENCIES: Update CUnit instructions

2014-11-26 Thread Taras Kondratiuk

On 11/26/2014 12:08 AM, Mike Holmes wrote:

Signed-off-by: Mike Holmes mike.hol...@linaro.org
---
  DEPENDENCIES | 18 ++
  1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/DEPENDENCIES b/DEPENDENCIES
index f70a1d4..11452ff 100644
--- a/DEPENDENCIES
+++ b/DEPENDENCIES
@@ -78,23 +78,33 @@ Prerequisites for building the OpenDataPlane (ODP) API

  4.0 Packages needed to build API tests

-   Cunit test framework
+   Cunit test framework version 2.1-3 is required
 Cunit prvodes a framework to run the API test suite that proves 
conformance to the
 ODP API. The home page http://cunit.sourceforge.net/doc/introduction.html

  4.1 Native Cunit install

-   # Debian/Ubuntu
+   # Debian/Ubuntu check it is 2.1-3
 $ apt-get install libcunit1-dev

-4.2 Cross compile of Cunit
+4.2 Built from src
+
+   export CUNIT_VERSION=2.1-3
+   curl -sSOL 
http://sourceforge.net/projects/cunit/files/CUnit/${CUNIT_VERSION}/CUnit-${CUNIT_VERSION}.
 ar.bz2


tar.bz2 ?

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


Re: [lng-odp] [PATCH 2/2] linux-generic: odp_pktio_open loop0 support

2014-11-26 Thread Maxim Uvarov

On 11/26/2014 12:25 PM, Ola Liljedahl wrote:

On 26 November 2014 at 09:39, Alexandru Badicioiu
alexandru.badici...@linaro.org wrote:

This patch has no description. The title is not self explanatory either.
Also the existence of eth0 should be verified  before mapping the loop0 to
eth0 - some platforms may use other interface names (e.g. fmX-gby for FSL
DPAA platforms).  I think a better solution would be to enumerate the
available interfaces  and pick a suitable one.

I second that opinion. On my ChromeBook (great development
platforms!), the only Ethernet-like
interface is called mlan0.
Hm, renaming should be done to some predictable name. eth0 is very 
common for linux.

If it's not so that can be changed with export ODP_PKTIO_LOOPDEV=mlan0.

I can walk over the list but not sure how to select interface that can 
be used.


Maxim.






On 25 November 2014 at 18:24, Maxim Uvarov maxim.uva...@linaro.org wrote:

Signed-off-by: Maxim Uvarov maxim.uva...@linaro.org
---
  platform/linux-generic/odp_packet_io.c | 27 +++
  1 file changed, 27 insertions(+)

diff --git a/platform/linux-generic/odp_packet_io.c
b/platform/linux-generic/odp_packet_io.c
index c523350..501b2e9 100644
--- a/platform/linux-generic/odp_packet_io.c
+++ b/platform/linux-generic/odp_packet_io.c
@@ -156,6 +156,33 @@ odp_pktio_t odp_pktio_open(const char *dev,
odp_buffer_pool_t pool)
 pktio_entry_t *pktio_entry;
 int res;
 int fanout = 1;
+   char loop0[IFNAMSIZ] = eth0; /* linux-generic loop0 device*/

This comment is strange. If ODP uses an interface like eth0, how can
that be a loopback interface?
Won't packet I/O using this interface be mapped onto the real Ethernet
interface and sent onto the physical link?

-- Ola


+   char *loop_hint;
+
+   if (strlen(dev)  IFNAMSIZ) {
+   /* ioctl names limitation */
+   ODP_ERR(pktio name %s is too big, limit is %d bytes\n,
+   dev, IFNAMSIZ);
+   return ODP_PKTIO_INVALID;
+   }
+
+   loop_hint = getenv(ODP_PKTIO_LOOPDEV);
+   if (!strncmp(dev, loop0, 5)) {
+   if (loop_hint  (strlen(loop_hint)  0)) {
+   if (strlen(loop_hint)  IFNAMSIZ) {
+   ODP_ERR(pktio name %s is too big, limit
is %d bytes\n,
+   loop_hint, IFNAMSIZ);
+   return ODP_PKTIO_INVALID;
+   }
+
+   memset(loop0, 0, IFNAMSIZ);
+   memcpy(loop0, loop_hint, strlen(loop_hint));
+   ODP_DBG(pktio rename loop0 to %s\n, loop_hint);
+   } else {
+   ODP_DBG(pktio rename loop0 to eth0\n);
+   dev = loop0;
+   }
+   }

 id = alloc_lock_pktio_entry();
 if (id == ODP_PKTIO_INVALID) {
--
1.8.5.1.163.gd7aced9


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



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




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


Re: [lng-odp] [PATCH] examples: remove the use of ODP_UNUSED

2014-11-26 Thread Maxim Uvarov

Merged, thanks,

Maxim.

On 11/24/2014 10:19 PM, Mike Holmes wrote:

ODP_UNUSED should be used internally to an ODP implementation and not by
an application. The declaration should never have specified ODP_UNUSED for
find_ipsec_cache_entry_out()

Signed-off-by: Mike Holmes mike.hol...@linaro.org
---
  example/example_debug.h | 5 +
  example/ipsec/odp_ipsec.c   | 5 +++--
  example/ipsec/odp_ipsec_cache.c | 2 +-
  example/ipsec/odp_ipsec_cache.h | 2 +-
  4 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/example/example_debug.h b/example/example_debug.h
index b83667c..dd3aa7f 100644
--- a/example/example_debug.h
+++ b/example/example_debug.h
@@ -78,6 +78,11 @@ do { \
EXAMPLE_LOG(EXAMPLE_LOG_ABORT, fmt, ##__VA_ARGS__)
  
  /**

+ * Intentionally unused variables to functions
+ */
+#define EXAMPLE_UNUSED __attribute__((__unused__))
+
+/**
   * @}
   */
  
diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c

index ec115fc..ad62436 100644
--- a/example/ipsec/odp_ipsec.c
+++ b/example/ipsec/odp_ipsec.c
@@ -619,7 +619,8 @@ void initialize_intf(char *intf)
   * @return PKT_CONTINUE if good, supported packet else PKT_DROP
   */
  static
-pkt_disposition_e do_input_verify(odp_packet_t pkt, pkt_ctx_t *ctx ODP_UNUSED)
+pkt_disposition_e do_input_verify(odp_packet_t pkt,
+ pkt_ctx_t *ctx EXAMPLE_UNUSED)
  {
if (odp_unlikely(odp_packet_error(pkt)))
return PKT_DROP;
@@ -1037,7 +1038,7 @@ pkt_disposition_e do_ipsec_out_finish(odp_packet_t pkt,
   * @return NULL (should never return)
   */
  static
-void *pktio_thread(void *arg ODP_UNUSED)
+void *pktio_thread(void *arg EXAMPLE_UNUSED)
  {
int thr;
odp_packet_t pkt;
diff --git a/example/ipsec/odp_ipsec_cache.c b/example/ipsec/odp_ipsec_cache.c
index fb53bb6..7a0c813 100644
--- a/example/ipsec/odp_ipsec_cache.c
+++ b/example/ipsec/odp_ipsec_cache.c
@@ -171,7 +171,7 @@ ipsec_cache_entry_t *find_ipsec_cache_entry_in(uint32_t 
src_ip,
  
  ipsec_cache_entry_t *find_ipsec_cache_entry_out(uint32_t src_ip,

uint32_t dst_ip,
-   uint8_t proto ODP_UNUSED)
+   uint8_t proto EXAMPLE_UNUSED)
  {
ipsec_cache_entry_t *entry = ipsec_cache-out_list;
  
diff --git a/example/ipsec/odp_ipsec_cache.h b/example/ipsec/odp_ipsec_cache.h

index 5791cf8..2cbaabd 100644
--- a/example/ipsec/odp_ipsec_cache.h
+++ b/example/ipsec/odp_ipsec_cache.h
@@ -118,7 +118,7 @@ ipsec_cache_entry_t *find_ipsec_cache_entry_in(uint32_t 
src_ip,
   */
  ipsec_cache_entry_t *find_ipsec_cache_entry_out(uint32_t src_ip,
uint32_t dst_ip,
-   uint8_t proto ODP_UNUSED);
+   uint8_t proto);
  
  #ifdef __cplusplus

  }



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


Re: [lng-odp] [PATCH] .gitignore: distribute the ignore file to sub dirs

2014-11-26 Thread Maxim Uvarov

On 11/25/2014 09:06 PM, Mike Holmes wrote:

+++ b/test/validation/.gitignore
@@ -0,0 +1,6 @@
+*.log
+*.trs
+odp_init
+odp_queue
+odp_crypto
+CUnit-Memory-Dump.xml
xml has to be global. It's like core which stores to PWD, not to 
directory where binary is located.


Maxim.

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


Re: [lng-odp] [PATCH] DEPENDENCIES: Update CUnit instructions

2014-11-26 Thread Maxim Uvarov

On 11/26/2014 01:59 PM, Taras Kondratiuk wrote:

On 11/26/2014 12:08 AM, Mike Holmes wrote:

Signed-off-by: Mike Holmes mike.hol...@linaro.org
---
  DEPENDENCIES | 18 ++
  1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/DEPENDENCIES b/DEPENDENCIES
index f70a1d4..11452ff 100644
--- a/DEPENDENCIES
+++ b/DEPENDENCIES
@@ -78,23 +78,33 @@ Prerequisites for building the OpenDataPlane 
(ODP) API


  4.0 Packages needed to build API tests

-   Cunit test framework
+   Cunit test framework version 2.1-3 is required
 Cunit prvodes a framework to run the API test suite that proves 
conformance to the
 ODP API. The home page 
http://cunit.sourceforge.net/doc/introduction.html


  4.1 Native Cunit install

-   # Debian/Ubuntu
+   # Debian/Ubuntu check it is 2.1-3
 $ apt-get install libcunit1-dev

-4.2 Cross compile of Cunit
+4.2 Built from src
+
+   export CUNIT_VERSION=2.1-3
+   curl -sSOL 
http://sourceforge.net/projects/cunit/files/CUnit/${CUNIT_VERSION}/CUnit-${CUNIT_VERSION}. 
ar.bz2


tar.bz2 ?


curl?

Can it say simple -  download cunit 2.1-3 version from cunit.sf.net 
(check link). ?


Maxim.



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



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


Re: [lng-odp] [PATCH v2 4/5] Linux-generic: Classification Implementation v1.0

2014-11-26 Thread Maxim Uvarov

Reviewed-by:  Maxim Uvarov maxim.uva...@linaro.org


On 11/21/2014 03:27 PM, Balasubramanian Manoharan wrote:

This patch contains classification implementation for ODP v1.0.

The salient features of this classification version are as follows:
* Attaches PMR, PMR_SET to a Pktio entry
* Attaches CoS values for L2 and L3 QoS to a Pktio entry
* Selects ClassOfService for a packet based on PMR, L2 QoS and L3 QoS values
* Selects a default CoS if packet does not match any of the assigned rules
* Selects an Error CoS for an Error packet
* Enqueues the packet to the queue associated with the selected CoS

Signed-off-by: Balasubramanian Manoharan bala.manoha...@linaro.org
---
V2: Change pmr_term value size from bits to bytes

  helper/include/odph_ip.h   |   6 +
  platform/linux-generic/include/api/odp.h   |   1 +
  .../linux-generic/include/api/odp_classification.h |  10 +-
  .../include/odp_classification_datamodel.h | 199 +
  .../include/odp_classification_inlines.h   | 259 ++
  .../include/odp_classification_internal.h  | 173 
  platform/linux-generic/include/odp_internal.h  |   2 +
  platform/linux-generic/odp_classification.c| 869 ++---
  platform/linux-generic/odp_init.c  |   4 +
  9 files changed, 1402 insertions(+), 121 deletions(-)
  create mode 100644 
platform/linux-generic/include/odp_classification_datamodel.h
  create mode 100644 platform/linux-generic/include/odp_classification_inlines.h
  create mode 100644 
platform/linux-generic/include/odp_classification_internal.h

diff --git a/helper/include/odph_ip.h b/helper/include/odph_ip.h
index 2c83c0f..f78724e 100644
--- a/helper/include/odph_ip.h
+++ b/helper/include/odph_ip.h
@@ -35,6 +35,9 @@ extern C {
  /** @internal Returns IPv4 header length */
  #define ODPH_IPV4HDR_IHL(ver_ihl) ((ver_ihl)  0x0f)
  
+/** @internal Returns IPv4 DSCP */

+#define ODPH_IPV4HDR_DSCP(tos) (((tos)  0xfc)  2)
+
  /** @internal Returns IPv4 Don't fragment */
  #define ODPH_IPV4HDR_FLAGS_DONT_FRAG(frag_offset)  ((frag_offset)  0x4000)
  
@@ -47,6 +50,9 @@ extern C {

  /** @internal Returns true if IPv4 packet is a fragment */
  #define ODPH_IPV4HDR_IS_FRAGMENT(frag_offset) ((frag_offset)  0x3fff)
  
+/** @internal Returns IPv4 DSCP */

+#define ODPH_IPV6HDR_DSCP(ver_tc_flow) (uint8_t)ver_tc_flow)  0x0fc0)  
22)  0xff)
+
  /** IPv4 header */
  typedef struct ODP_PACKED {
uint8_tver_ihl; /** Version / Header length */
diff --git a/platform/linux-generic/include/api/odp.h 
b/platform/linux-generic/include/api/odp.h
index 6e4f69e..b7b1ca9 100644
--- a/platform/linux-generic/include/api/odp.h
+++ b/platform/linux-generic/include/api/odp.h
@@ -47,6 +47,7 @@ extern C {
  #include odp_packet_flags.h
  #include odp_packet_io.h
  #include odp_crypto.h
+#include odp_classification.h
  #include odp_rwlock.h
  
  #ifdef __cplusplus

diff --git a/platform/linux-generic/include/api/odp_classification.h 
b/platform/linux-generic/include/api/odp_classification.h
index cc5d84a..091b10d 100644
--- a/platform/linux-generic/include/api/odp_classification.h
+++ b/platform/linux-generic/include/api/odp_classification.h
@@ -48,6 +48,9 @@ typedef uint32_t odp_flowsig_t;
  */
  #define ODP_COS_INVALID((odp_cos_t)~0)
  
+/** Maximum ClassOfService name length in chars */

+#define ODP_COS_NAME_LEN 32
+
  /**
   * Class-of-service packet drop policies
   */
@@ -325,7 +328,7 @@ typedef uint32_t odp_pmr_t;
  /**
   * Macro for Invalid PMR.
   */
-#defineODP_PMR_INVAL ((odp_pmr_t)NULL)
+#defineODP_PMR_INVAL ((odp_pmr_t)~0)
  
  /**

   * Packet Matching Rule field enumeration
@@ -497,9 +500,6 @@ typedef uint32_t odp_pmr_set_t;
   * @param[in] num_terms   Number of terms in the match rule.
   * @param[in] terms   Array of num_terms entries, one entry per
   *term desired.
- * @param[in]  dst_cos Class-of-service to be assigned to packets
- * that match the compound rule-set,
- * or a subset thereof, if partly applied.
   * @param[out]pmr_set_id  Returned handle to the composite rule 
set.
   *
   * @returnReturn value may be a positive number
@@ -510,7 +510,7 @@ typedef uint32_t odp_pmr_set_t;
   *or -1 for error.
   */
  int odp_pmr_match_set_create(int num_terms, odp_pmr_match_t *terms,
-odp_cos_t dst_cos, odp_pmr_set_t *pmr_set_id);
+odp_pmr_set_t *pmr_set_id);
  
  /**

   * Function to delete a composite packet match rule set
diff --git a/platform/linux-generic/include/odp_classification_datamodel.h 
b/platform/linux-generic/include/odp_classification_datamodel.h
new file mode 100644
index 000..f7c9fb5
--- /dev/null
+++ b/platform/linux-generic/include/odp_classification_datamodel.h
@@ -0,0 +1,199 @@
+/* Copyright (c) 2014, 

Re: [lng-odp] [PATCH] api: odp_atomic.h: doxygen fix

2014-11-26 Thread Maxim Uvarov

Merged.

Maxim.

On 11/25/2014 11:44 PM, Mike Holmes wrote:



On 25 November 2014 at 15:38, Ola Liljedahl ola.liljed...@linaro.org 
mailto:ola.liljed...@linaro.org wrote:


Signed-off-by: Ola Liljedahl ola.liljed...@linaro.org
mailto:ola.liljed...@linaro.org


Reviewed-and-tested-by: Mike Holmes mike.hol...@linaro.org 
mailto:mike.hol...@linaro.org


---
 platform/linux-generic/include/api/odp_atomic.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/platform/linux-generic/include/api/odp_atomic.h
b/platform/linux-generic/include/api/odp_atomic.h
index de9d91c..9eebb86 100644
--- a/platform/linux-generic/include/api/odp_atomic.h
+++ b/platform/linux-generic/include/api/odp_atomic.h
@@ -36,7 +36,7 @@ typedef struct {
 #if __GCC_ATOMIC_LLONG_LOCK_FREE  2
/* Some architectures do not support lock-free operations
on 64-bit
 * data types. We use a spin lock to ensure atomicity. */
-   char lock;
+   char lock; /** Spin lock used to ensure atomic access */
 #endif
 } odp_atomic_u64_t
 ODP_ALIGNED(sizeof(uint64_t)); /* Enforce alignement! */
--
1.9.1


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




--
*Mike Holmes*
Linaro  Sr Technical Manager
LNG - ODP


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



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


Re: [lng-odp] [PATCH] netdev-odp: Use VLOG_ERR instead of ODP_ERR

2014-11-26 Thread Zoltan Kiss
But independent from this, OVS should overwrite the log function, right? 
So ODP internal log messages won't be lost.


Regards,

Zoli

On 26/11/14 10:47, Taras Kondratiuk wrote:

On 11/25/2014 06:54 PM, Mike Holmes wrote:

Taras is submitting a patch that allows you to replace the output stream
for ODP_ERR etc with the applications prefered stream - see
https://mail.google.com/mail/u/1/#inbox/149e780e4e57d70c


Taking into account that ODP_ERR() is not a part of public API Zoltan's
patch looks correct. OVS should not use ODP_ERR().


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


Re: [lng-odp] [PATCH] netdev-odp: Use VLOG_ERR instead of ODP_ERR

2014-11-26 Thread Taras Kondratiuk

On 11/26/2014 02:54 PM, Zoltan Kiss wrote:

But independent from this, OVS should overwrite the log function, right?
So ODP internal log messages won't be lost.


Right.
I assume it should direct log messages into its own logging subsystem.

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


Re: [lng-odp] [PATCH 2/2] linux-generic: odp_pktio_open loop0 support

2014-11-26 Thread Jerin Jacob
On Wed, Nov 26, 2014 at 02:53:50PM +0300, Maxim Uvarov wrote:
 On 11/26/2014 12:25 PM, Ola Liljedahl wrote:
 On 26 November 2014 at 09:39, Alexandru Badicioiu
 alexandru.badici...@linaro.org wrote:
 This patch has no description. The title is not self explanatory either.
 Also the existence of eth0 should be verified  before mapping the loop0 to
 eth0 - some platforms may use other interface names (e.g. fmX-gby for FSL
 DPAA platforms).  I think a better solution would be to enumerate the
 available interfaces  and pick a suitable one.
 I second that opinion. On my ChromeBook (great development
 platforms!), the only Ethernet-like
 interface is called mlan0.
 Hm, renaming should be done to some predictable name. eth0 is very common
 for linux.
 If it's not so that can be changed with export ODP_PKTIO_LOOPDEV=mlan0.
 
 I can walk over the list but not sure how to select interface that can be
 used.

IMO we should  have an ODP API to enumerate all the available pktio ports 
in a given platform as strings along with a bitmap to represent their 
capability(like PKTIO_CAP_LOOPBACK)
So that application can choose the pktio based on the capability.
We can use our odp___next API model for enumeration.

 
 Maxim.
 
 
 
 
 On 25 November 2014 at 18:24, Maxim Uvarov maxim.uva...@linaro.org wrote:
 Signed-off-by: Maxim Uvarov maxim.uva...@linaro.org
 ---
   platform/linux-generic/odp_packet_io.c | 27 +++
   1 file changed, 27 insertions(+)
 
 diff --git a/platform/linux-generic/odp_packet_io.c
 b/platform/linux-generic/odp_packet_io.c
 index c523350..501b2e9 100644
 --- a/platform/linux-generic/odp_packet_io.c
 +++ b/platform/linux-generic/odp_packet_io.c
 @@ -156,6 +156,33 @@ odp_pktio_t odp_pktio_open(const char *dev,
 odp_buffer_pool_t pool)
  pktio_entry_t *pktio_entry;
  int res;
  int fanout = 1;
 +   char loop0[IFNAMSIZ] = eth0; /* linux-generic loop0 device*/
 This comment is strange. If ODP uses an interface like eth0, how can
 that be a loopback interface?
 Won't packet I/O using this interface be mapped onto the real Ethernet
 interface and sent onto the physical link?
 
 -- Ola
 
 +   char *loop_hint;
 +
 +   if (strlen(dev)  IFNAMSIZ) {
 +   /* ioctl names limitation */
 +   ODP_ERR(pktio name %s is too big, limit is %d bytes\n,
 +   dev, IFNAMSIZ);
 +   return ODP_PKTIO_INVALID;
 +   }
 +
 +   loop_hint = getenv(ODP_PKTIO_LOOPDEV);
 +   if (!strncmp(dev, loop0, 5)) {
 +   if (loop_hint  (strlen(loop_hint)  0)) {
 +   if (strlen(loop_hint)  IFNAMSIZ) {
 +   ODP_ERR(pktio name %s is too big, limit
 is %d bytes\n,
 +   loop_hint, IFNAMSIZ);
 +   return ODP_PKTIO_INVALID;
 +   }
 +
 +   memset(loop0, 0, IFNAMSIZ);
 +   memcpy(loop0, loop_hint, strlen(loop_hint));
 +   ODP_DBG(pktio rename loop0 to %s\n, loop_hint);
 +   } else {
 +   ODP_DBG(pktio rename loop0 to eth0\n);
 +   dev = loop0;
 +   }
 +   }
 
  id = alloc_lock_pktio_entry();
  if (id == ODP_PKTIO_INVALID) {
 --
 1.8.5.1.163.gd7aced9
 
 
 ___
 lng-odp mailing list
 lng-odp@lists.linaro.org
 http://lists.linaro.org/mailman/listinfo/lng-odp
 
 
 ___
 lng-odp mailing list
 lng-odp@lists.linaro.org
 http://lists.linaro.org/mailman/listinfo/lng-odp
 
 
 
 ___
 lng-odp mailing list
 lng-odp@lists.linaro.org
 http://lists.linaro.org/mailman/listinfo/lng-odp

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


Re: [lng-odp] [PATCH 2/2] linux-generic: odp_pktio_open loop0 support

2014-11-26 Thread Alexandru Badicioiu
On 26 November 2014 at 15:23, Jerin Jacob jerin.ja...@caviumnetworks.com
wrote:

 On Wed, Nov 26, 2014 at 02:53:50PM +0300, Maxim Uvarov wrote:
  On 11/26/2014 12:25 PM, Ola Liljedahl wrote:
  On 26 November 2014 at 09:39, Alexandru Badicioiu
  alexandru.badici...@linaro.org wrote:
  This patch has no description. The title is not self explanatory
 either.
  Also the existence of eth0 should be verified  before mapping the
 loop0 to
  eth0 - some platforms may use other interface names (e.g. fmX-gby for
 FSL
  DPAA platforms).  I think a better solution would be to enumerate the
  available interfaces  and pick a suitable one.
  I second that opinion. On my ChromeBook (great development
  platforms!), the only Ethernet-like
  interface is called mlan0.
  Hm, renaming should be done to some predictable name. eth0 is very common
  for linux.
  If it's not so that can be changed with export ODP_PKTIO_LOOPDEV=mlan0.
 
  I can walk over the list but not sure how to select interface that can be
  used.

 IMO we should  have an ODP API to enumerate all the available pktio ports
 in a given platform as strings along with a bitmap to represent their
 capability(like PKTIO_CAP_LOOPBACK)
 So that application can choose the pktio based on the capability.
 We can use our odp___next API model for enumeration.

[Alex] I share this opinion too.


 
  Maxim.
 
 
  
  
  On 25 November 2014 at 18:24, Maxim Uvarov maxim.uva...@linaro.org
 wrote:
  Signed-off-by: Maxim Uvarov maxim.uva...@linaro.org
  ---
platform/linux-generic/odp_packet_io.c | 27
 +++
1 file changed, 27 insertions(+)
  
  diff --git a/platform/linux-generic/odp_packet_io.c
  b/platform/linux-generic/odp_packet_io.c
  index c523350..501b2e9 100644
  --- a/platform/linux-generic/odp_packet_io.c
  +++ b/platform/linux-generic/odp_packet_io.c
  @@ -156,6 +156,33 @@ odp_pktio_t odp_pktio_open(const char *dev,
  odp_buffer_pool_t pool)
   pktio_entry_t *pktio_entry;
   int res;
   int fanout = 1;
  +   char loop0[IFNAMSIZ] = eth0; /* linux-generic loop0 device*/
  This comment is strange. If ODP uses an interface like eth0, how can
  that be a loopback interface?
  Won't packet I/O using this interface be mapped onto the real Ethernet
  interface and sent onto the physical link?
  
  -- Ola
  
  +   char *loop_hint;
  +
  +   if (strlen(dev)  IFNAMSIZ) {
  +   /* ioctl names limitation */
  +   ODP_ERR(pktio name %s is too big, limit is %d
 bytes\n,
  +   dev, IFNAMSIZ);
  +   return ODP_PKTIO_INVALID;
  +   }
  +
  +   loop_hint = getenv(ODP_PKTIO_LOOPDEV);
  +   if (!strncmp(dev, loop0, 5)) {
  +   if (loop_hint  (strlen(loop_hint)  0)) {
  +   if (strlen(loop_hint)  IFNAMSIZ) {
  +   ODP_ERR(pktio name %s is too big,
 limit
  is %d bytes\n,
  +   loop_hint, IFNAMSIZ);
  +   return ODP_PKTIO_INVALID;
  +   }
  +
  +   memset(loop0, 0, IFNAMSIZ);
  +   memcpy(loop0, loop_hint, strlen(loop_hint));
  +   ODP_DBG(pktio rename loop0 to %s\n,
 loop_hint);
  +   } else {
  +   ODP_DBG(pktio rename loop0 to eth0\n);
  +   dev = loop0;
  +   }
  +   }
  
   id = alloc_lock_pktio_entry();
   if (id == ODP_PKTIO_INVALID) {
  --
  1.8.5.1.163.gd7aced9
  
  
  ___
  lng-odp mailing list
  lng-odp@lists.linaro.org
  http://lists.linaro.org/mailman/listinfo/lng-odp
  
  
  ___
  lng-odp mailing list
  lng-odp@lists.linaro.org
  http://lists.linaro.org/mailman/listinfo/lng-odp
  
 
 
  ___
  lng-odp mailing list
  lng-odp@lists.linaro.org
  http://lists.linaro.org/mailman/listinfo/lng-odp

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

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


Re: [lng-odp] [PATCH 2/2] linux-generic: odp_pktio_open loop0 support

2014-11-26 Thread Taras Kondratiuk

On 11/26/2014 03:23 PM, Jerin Jacob wrote:

On Wed, Nov 26, 2014 at 02:53:50PM +0300, Maxim Uvarov wrote:

On 11/26/2014 12:25 PM, Ola Liljedahl wrote:

On 26 November 2014 at 09:39, Alexandru Badicioiu
alexandru.badici...@linaro.org wrote:

This patch has no description. The title is not self explanatory either.
Also the existence of eth0 should be verified  before mapping the loop0 to
eth0 - some platforms may use other interface names (e.g. fmX-gby for FSL
DPAA platforms).  I think a better solution would be to enumerate the
available interfaces  and pick a suitable one.

I second that opinion. On my ChromeBook (great development
platforms!), the only Ethernet-like
interface is called mlan0.

Hm, renaming should be done to some predictable name. eth0 is very common
for linux.
If it's not so that can be changed with export ODP_PKTIO_LOOPDEV=mlan0.

I can walk over the list but not sure how to select interface that can be
used.


IMO we should  have an ODP API to enumerate all the available pktio ports
in a given platform as strings along with a bitmap to represent their 
capability(like PKTIO_CAP_LOOPBACK)
So that application can choose the pktio based on the capability.
We can use our odp___next API model for enumeration.


+1

Instead of bitmap it can some struct.

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


Re: [lng-odp] [PATCH 2/2] linux-generic: odp_pktio_open loop0 support

2014-11-26 Thread Maxim Uvarov

On 11/26/2014 04:33 PM, Taras Kondratiuk wrote:

On 11/26/2014 03:23 PM, Jerin Jacob wrote:

On Wed, Nov 26, 2014 at 02:53:50PM +0300, Maxim Uvarov wrote:

On 11/26/2014 12:25 PM, Ola Liljedahl wrote:

On 26 November 2014 at 09:39, Alexandru Badicioiu
alexandru.badici...@linaro.org wrote:
This patch has no description. The title is not self explanatory 
either.
Also the existence of eth0 should be verified  before mapping the 
loop0 to
eth0 - some platforms may use other interface names (e.g. fmX-gby 
for FSL

DPAA platforms).  I think a better solution would be to enumerate the
available interfaces  and pick a suitable one.

I second that opinion. On my ChromeBook (great development
platforms!), the only Ethernet-like
interface is called mlan0.
Hm, renaming should be done to some predictable name. eth0 is very 
common

for linux.
If it's not so that can be changed with export 
ODP_PKTIO_LOOPDEV=mlan0.


I can walk over the list but not sure how to select interface that 
can be

used.


IMO we should  have an ODP API to enumerate all the available pktio 
ports
in a given platform as strings along with a bitmap to represent their 
capability(like PKTIO_CAP_LOOPBACK)

So that application can choose the pktio based on the capability.
We can use our odp___next API model for enumeration.


+1

Instead of bitmap it can some struct.



Any hint how that can be implemented on linux-generic for v1?



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


Re: [lng-odp] [PATCH 2/2] linux-generic: odp_pktio_open loop0 support

2014-11-26 Thread Jerin Jacob
On Wed, Nov 26, 2014 at 05:05:14PM +0300, Maxim Uvarov wrote:
 On 11/26/2014 04:33 PM, Taras Kondratiuk wrote:
 On 11/26/2014 03:23 PM, Jerin Jacob wrote:
 On Wed, Nov 26, 2014 at 02:53:50PM +0300, Maxim Uvarov wrote:
 On 11/26/2014 12:25 PM, Ola Liljedahl wrote:
 On 26 November 2014 at 09:39, Alexandru Badicioiu
 alexandru.badici...@linaro.org wrote:
 This patch has no description. The title is not self explanatory
 either.
 Also the existence of eth0 should be verified  before mapping the
 loop0 to
 eth0 - some platforms may use other interface names (e.g. fmX-gby
 for FSL
 DPAA platforms).  I think a better solution would be to enumerate the
 available interfaces  and pick a suitable one.
 I second that opinion. On my ChromeBook (great development
 platforms!), the only Ethernet-like
 interface is called mlan0.
 Hm, renaming should be done to some predictable name. eth0 is very
 common
 for linux.
 If it's not so that can be changed with export
 ODP_PKTIO_LOOPDEV=mlan0.
 
 I can walk over the list but not sure how to select interface that can
 be
 used.
 
 IMO we should  have an ODP API to enumerate all the available pktio
 ports
 in a given platform as strings along with a bitmap to represent their
 capability(like PKTIO_CAP_LOOPBACK)
 So that application can choose the pktio based on the capability.
 We can use our odp___next API model for enumeration.
 
 +1
 
 Instead of bitmap it can some struct.
 
 
 Any hint how that can be implemented on linux-generic for v1?

How about mapping to linux lo loopback device ?

lo: flags=73UP,LOOPBACK,RUNNING  mtu 65536
inet 127.0.0.1  netmask 255.0.0.0
inet6 ::1  prefixlen 128  scopeid 0x10host
loop  txqueuelen 0  (Local Loopback)
RX packets 580  bytes 48524 (47.3 KiB)
RX errors 0  dropped 0  overruns 0  frame 0
TX packets 580  bytes 48524 (47.3 KiB)
TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0


 
 

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


Re: [lng-odp] [PATCH 2/2] linux-generic: odp_pktio_open loop0 support

2014-11-26 Thread Taras Kondratiuk

On 11/26/2014 04:05 PM, Maxim Uvarov wrote:

On 11/26/2014 04:33 PM, Taras Kondratiuk wrote:

On 11/26/2014 03:23 PM, Jerin Jacob wrote:

On Wed, Nov 26, 2014 at 02:53:50PM +0300, Maxim Uvarov wrote:

On 11/26/2014 12:25 PM, Ola Liljedahl wrote:

On 26 November 2014 at 09:39, Alexandru Badicioiu
alexandru.badici...@linaro.org wrote:

This patch has no description. The title is not self explanatory
either.
Also the existence of eth0 should be verified  before mapping the
loop0 to
eth0 - some platforms may use other interface names (e.g. fmX-gby
for FSL
DPAA platforms).  I think a better solution would be to enumerate the
available interfaces  and pick a suitable one.

I second that opinion. On my ChromeBook (great development
platforms!), the only Ethernet-like
interface is called mlan0.

Hm, renaming should be done to some predictable name. eth0 is very
common
for linux.
If it's not so that can be changed with export
ODP_PKTIO_LOOPDEV=mlan0.

I can walk over the list but not sure how to select interface that
can be
used.


IMO we should  have an ODP API to enumerate all the available pktio
ports
in a given platform as strings along with a bitmap to represent their
capability(like PKTIO_CAP_LOOPBACK)
So that application can choose the pktio based on the capability.
We can use our odp___next API model for enumeration.


+1

Instead of bitmap it can some struct.



Any hint how that can be implemented on linux-generic for v1?


SIOCGIFCONF ioctl can be used to get a list of interfaces.
Or read /proc/net/dev directly. Then read flags with SIOCGIFFLAGS ioctl.

I'm not sure if we need this for v1.

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


[lng-odp] [PATCH] validation: add odp_system test

2014-11-26 Thread Mike Holmes
Signed-off-by: Mike Holmes mike.hol...@linaro.org
---
 test/validation/.gitignore   |   1 +
 test/validation/Makefile.am  |   4 +-
 test/validation/odp_system.c | 114 +++
 3 files changed, 118 insertions(+), 1 deletion(-)
 create mode 100644 test/validation/odp_system.c

diff --git a/test/validation/.gitignore b/test/validation/.gitignore
index 2917c66..ba204a0 100644
--- a/test/validation/.gitignore
+++ b/test/validation/.gitignore
@@ -3,4 +3,5 @@
 odp_init
 odp_queue
 odp_crypto
+odp_system
 CUnit-Memory-Dump.xml
diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am
index 0b831d0..c991900 100644
--- a/test/validation/Makefile.am
+++ b/test/validation/Makefile.am
@@ -6,11 +6,12 @@ AM_LDFLAGS += -L$(CUNIT_PATH)/lib -static -lcunit
 if ODP_CUNIT_ENABLED
 TESTS = ${bin_PROGRAMS}
 check_PROGRAMS = ${bin_PROGRAMS}
-bin_PROGRAMS = odp_init odp_queue odp_crypto
+bin_PROGRAMS = odp_init odp_queue odp_crypto odp_system
 odp_init_LDFLAGS = $(AM_LDFLAGS)
 odp_queue_LDFLAGS = $(AM_LDFLAGS)
 odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto
 odp_crypto_LDFLAGS = $(AM_LDFLAGS)
+odp_system_LDFLAGS = $(AM_LDFLAGS)
 endif
 
 dist_odp_init_SOURCES = odp_init.c
@@ -18,3 +19,4 @@ dist_odp_queue_SOURCES = odp_queue.c
 dist_odp_crypto_SOURCES = crypto/odp_crypto_test_async_inp.c \
  crypto/odp_crypto_test_sync_inp.c \
  odp_crypto.c
+dist_odp_system_SOURCES = odp_system.c
diff --git a/test/validation/odp_system.c b/test/validation/odp_system.c
new file mode 100644
index 000..abcc746
--- /dev/null
+++ b/test/validation/odp_system.c
@@ -0,0 +1,114 @@
+/* Copyright (c) 2014, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include odp.h
+#include CUnit/Basic.h
+
+static void test_odp_sys_core_count(void)
+{
+   int cores;
+
+   cores = odp_sys_core_count();
+   CU_ASSERT(0  cores)
+}
+
+static void test_odp_sys_cache_line_size(void)
+{
+   uint64_t cache_size;
+
+   cache_size = odp_sys_cache_line_size();
+   CU_ASSERT(0  cache_size)
+}
+
+static void test_odp_sys_cpu_model_str(void)
+{
+   char model[64];
+
+   strcpy(model, odp_sys_cpu_model_str());
+   CU_ASSERT(strlen(model)  0)
+   CU_ASSERT(strlen(model)  127)
+}
+
+static void test_odp_sys_page_size(void)
+{
+   uint64_t page;
+
+   page = odp_sys_page_size();
+   CU_ASSERT(0  page)
+}
+
+static void test_odp_sys_huge_page_size(void)
+{
+   uint64_t page;
+
+   page = odp_sys_huge_page_size();
+   CU_ASSERT(0  page)
+}
+
+static void test_odp_sys_cpu_hz(void)
+{
+   uint64_t hz;
+
+   hz = odp_sys_cpu_hz();
+   CU_ASSERT(0  hz)
+}
+
+static int init_suite(void)
+{
+   printf(\tODP API version: %s\n, odp_version_api_str());
+   printf(\tODP implementation version: %s\n, odp_version_impl_str());
+
+   if (odp_init_global(NULL, NULL)) {
+   printf(ODP global init failed.\n);
+   return -1;
+   }
+   odp_init_local();
+
+   return 0;
+}
+
+static int finalise(void)
+{
+   odp_term_local();
+   odp_term_global();
+
+   return 0;
+}
+
+CU_TestInfo test_odp_system[] = {
+   {odp_sys_core_count,  test_odp_sys_core_count},
+   {odp_sys_cache_line_size,  test_odp_sys_cache_line_size},
+   {odp_sys_cpu_model_str,  test_odp_sys_cpu_model_str},
+   {odp_sys_page_size,  test_odp_sys_page_size},
+   {odp_sys_huge_page_size,  test_odp_sys_huge_page_size},
+   {odp_sys_cpu_hz,  test_odp_sys_cpu_hz},
+   CU_TEST_INFO_NULL,
+};
+
+CU_SuiteInfo suites[] = {
+   {odp_system, init_suite, finalise, NULL, NULL,
+test_odp_system},
+CU_SUITE_INFO_NULL,
+};
+
+
+int main(void)
+{
+   int ret;
+
+   CU_set_error_action(CUEA_ABORT);
+
+   CU_initialize_registry();
+   CU_register_suites(suites);
+   CU_basic_set_mode(CU_BRM_VERBOSE);
+   CU_basic_run_tests();
+
+   ret = CU_get_number_of_failure_records();
+
+   CU_cleanup_registry();
+
+   return ret;
+}
-- 
2.1.0


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


Re: [lng-odp] [PATCH ARCH] testing.dox: Add cunit test rules

2014-11-26 Thread Mike Holmes
On 24 November 2014 at 05:38, Maxim Uvarov maxim.uva...@linaro.org wrote:

 On 11/21/2014 10:23 PM, Mike Holmes wrote:

 Signed-off-by: Mike Holmes mike.hol...@linaro.org
 ---
   testing.dox | 7 +++
   1 file changed, 7 insertions(+)

 diff --git a/testing.dox b/testing.dox
 index 86498f8..3791ebd 100644
 --- a/testing.dox
 +++ b/testing.dox
 @@ -141,6 +141,13 @@ All suites/tests in the registry may be run using a
 single function call, or sel
- Run tests using an appropriate interface, e.g. CU_console_run_tests
- Cleanup the test registry - CU_cleanup_registry
   +@subsection cunit_rules ODP cunit test rules
 + - If there are two or more tests, then CU_register_suites() shall be
 used to define them

 ;

  + - The tests main entry point will be in test/validation, supporting
 code shall be in a sub directory of validation


 ;

 + - A test suite shall display the version string of the API

 ;

 + - Test suites are self contained and can be executed in any order

 ;

 + - Tests shall not require external equipment

 .

 +
   @code
   /* Copyright (c) 2014, Linaro Limited
* All rights reserved.



Are semi colons or full stops necessary on the bullet lists ? We have not
done that elsewhere



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




-- 
*Mike Holmes*
Linaro  Sr Technical Manager
LNG - ODP
___
lng-odp mailing list
lng-odp@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/lng-odp


Re: [lng-odp] [RFC] More lenient packet parsing in linux

2014-11-26 Thread Bill Fischofer
Running under Linux these tests are redundant since the OS takes care of
it.  On SoCs the I/O HW will normally flag runt packets anyway so again
this is unnecessary.  It will be deleted along with the parser changes
needed for the new packet APIs.  An intermediate patch is fine but would be
short lived since that routine is scheduled for replacement anyway.

Bill

On Wednesday, November 26, 2014, Ciprian Barbu ciprian.ba...@linaro.org
wrote:

 On Wed, Nov 26, 2014 at 11:16 AM, Ola Liljedahl
 ola.liljed...@linaro.org javascript:; wrote:
  I think this check is too strict and should be removed.
 
  I remember we had a discussion about this many months ago and already
  then I was of the opinion that this check is unnecessary and not very
  beneficial.
 
  The 64-byte limit originates from Ethernet *link* restrictions and
  doesn't have anything to do with parsing packets. We want to be able
  to use virtual interfaces even in production systems, they are
  actually some very good reasons for that.

 There was a long discussion on this topic on end of April, there are
 no archives for that it seems. I found this post which contains some
 snippets:
 http://lists.linaro.org/pipermail/lng-odp/2014-April/24.html

 But the conclusion of that discussion was that Petri wanted to have
 ODP work with Ethernet cards only, no WiFi (which also generate frames
 shorter than 60/64) and no other software originated packets. That's
 why the restrictions was kept in place and instead a bug was opened
 saying that ODP cannot work with wireless network cards.

 With the addition of classification support in linux-generic this
 limitation should be revised IMO.

 /Ciprian

 
  -- Ola
 
  On 26 November 2014 at 09:41, Shmulik Ladkani shmulik.ladk...@gmail.com
 javascript:; wrote:
  On Tue, 25 Nov 2014 15:04:53 -0600 Bill Fischofer 
 bill.fischo...@linaro.org javascript:; wrote:
  These functions are scheduled for rework as part of the packet API
  revisions.  Will be sure to address this point as part of that rework.
 
  Thanks.
 
  If there's a concensus the 'len  ODPH_ETH_LEN_MIN' is too strict, any
  reason not to submit a tiny patch that removes this sanity test?
 
  This could be beneficial, as your patchset would therefore not
  carry this logical change, but instead focus on packet API changes.
 
  Regards,
  Shmulik
 
  ___
  lng-odp mailing list
  lng-odp@lists.linaro.org javascript:;
  http://lists.linaro.org/mailman/listinfo/lng-odp
 
  ___
  lng-odp mailing list
  lng-odp@lists.linaro.org javascript:;
  http://lists.linaro.org/mailman/listinfo/lng-odp

 ___
 lng-odp mailing list
 lng-odp@lists.linaro.org javascript:;
 http://lists.linaro.org/mailman/listinfo/lng-odp

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


Re: [lng-odp] [PATCH 2/2] linux-generic: odp_pktio_open loop0 support

2014-11-26 Thread Stuart Haslam
On Wed, Nov 26, 2014 at 04:32:43PM +0200, Taras Kondratiuk wrote:
 On 11/26/2014 04:05 PM, Maxim Uvarov wrote:
 On 11/26/2014 04:33 PM, Taras Kondratiuk wrote:
 On 11/26/2014 03:23 PM, Jerin Jacob wrote:
 On Wed, Nov 26, 2014 at 02:53:50PM +0300, Maxim Uvarov wrote:
 On 11/26/2014 12:25 PM, Ola Liljedahl wrote:
 On 26 November 2014 at 09:39, Alexandru Badicioiu
 alexandru.badici...@linaro.org wrote:
 This patch has no description. The title is not self explanatory
 either.
 Also the existence of eth0 should be verified  before mapping the
 loop0 to
 eth0 - some platforms may use other interface names (e.g. fmX-gby
 for FSL
 DPAA platforms).  I think a better solution would be to enumerate the
 available interfaces  and pick a suitable one.
 I second that opinion. On my ChromeBook (great development
 platforms!), the only Ethernet-like
 interface is called mlan0.
 Hm, renaming should be done to some predictable name. eth0 is very
 common
 for linux.
 If it's not so that can be changed with export
 ODP_PKTIO_LOOPDEV=mlan0.
 
 I can walk over the list but not sure how to select interface that
 can be
 used.
 
 IMO we should  have an ODP API to enumerate all the available pktio
 ports
 in a given platform as strings along with a bitmap to represent their
 capability(like PKTIO_CAP_LOOPBACK)
 So that application can choose the pktio based on the capability.
 We can use our odp___next API model for enumeration.
 
 +1
 
 Instead of bitmap it can some struct.
 
 
 Any hint how that can be implemented on linux-generic for v1?
 
 SIOCGIFCONF ioctl can be used to get a list of interfaces.
 Or read /proc/net/dev directly. Then read flags with SIOCGIFFLAGS ioctl.
 
 I'm not sure if we need this for v1.


I started doing some of this a couple of weeks back [1]. It's easy
enough to find the available interfaces but the difficult part is
figuring out if those interfaces can be used by ODP (I didn't get
that far), and how much of this is a system/implementation problem
vs being an application/user problem? For example I presume you'd
want to exclude management ports.. and messing with settings such as
MTU on shared interfaces (including lo) is sure to cause problems.

Maybe you could filter out interfaces that have IPs assigned?..

Anyway, I think interface enumeration would be good to have but I
don't think it's needed for 1.0.

--
Stuart. 

[1] 
https://git.linaro.org/people/stuart.haslam/odp.git/commit/3671a175d82c51c825f28d103fcc8da152a233d3

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


[lng-odp] [PATCH 2/2] platform: implement odp_queue_destroy()

2014-11-26 Thread Taras Kondratiuk
Signed-off-by: Taras Kondratiuk taras.kondrat...@linaro.org
---
 platform/linux-generic/odp_queue.c |   17 +
 1 file changed, 17 insertions(+)

diff --git a/platform/linux-generic/odp_queue.c 
b/platform/linux-generic/odp_queue.c
index 1318bcd..f44aba0 100644
--- a/platform/linux-generic/odp_queue.c
+++ b/platform/linux-generic/odp_queue.c
@@ -192,6 +192,23 @@ odp_queue_t odp_queue_create(const char *name, 
odp_queue_type_t type,
return handle;
 }
 
+int odp_queue_destroy(odp_queue_t handle)
+{
+   queue_entry_t *queue;
+   queue = queue_to_qentry(handle);
+
+   if (queue-s.status == QUEUE_STATUS_FREE)
+   return -1; /* Queue is alredy freed */
+
+   LOCK(queue-s.lock);
+   queue-s.status = QUEUE_STATUS_FREE;
+   queue-s.head = NULL;
+   queue-s.tail = NULL;
+   queue-s.sched_buf = ODP_BUFFER_INVALID;
+   UNLOCK(queue-s.lock);
+
+   return 0;
+}
 
 odp_buffer_t queue_sched_buf(odp_queue_t handle)
 {
-- 
1.7.9.5


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


[lng-odp] [PATCH 1/2] api: queue: add odp_queue_destroy()

2014-11-26 Thread Taras Kondratiuk
Signed-off-by: Taras Kondratiuk taras.kondrat...@linaro.org
---
 platform/linux-generic/include/api/odp_queue.h |9 +
 1 file changed, 9 insertions(+)

diff --git a/platform/linux-generic/include/api/odp_queue.h 
b/platform/linux-generic/include/api/odp_queue.h
index b8ac4bb..3321950 100644
--- a/platform/linux-generic/include/api/odp_queue.h
+++ b/platform/linux-generic/include/api/odp_queue.h
@@ -124,6 +124,15 @@ odp_queue_t odp_queue_create(const char *name, 
odp_queue_type_t type,
 odp_queue_param_t *param);
 
 /**
+ * Destroy ODP queue
+ *
+ * @param queueQueue handle
+ *
+ * @return 0 if successful
+ */
+int odp_queue_destroy(odp_queue_t queue);
+
+/**
  * Find a queue by name
  *
  * @param nameQueue name
-- 
1.7.9.5


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


Re: [lng-odp] [PATCH 1/2] api: queue: add odp_queue_destroy()

2014-11-26 Thread Mike Holmes
On 26 November 2014 at 12:03, Taras Kondratiuk taras.kondrat...@linaro.org
wrote:

 Signed-off-by: Taras Kondratiuk taras.kondrat...@linaro.org
 ---
  platform/linux-generic/include/api/odp_queue.h |9 +
  1 file changed, 9 insertions(+)

 diff --git a/platform/linux-generic/include/api/odp_queue.h
 b/platform/linux-generic/include/api/odp_queue.h
 index b8ac4bb..3321950 100644
 --- a/platform/linux-generic/include/api/odp_queue.h
 +++ b/platform/linux-generic/include/api/odp_queue.h
 @@ -124,6 +124,15 @@ odp_queue_t odp_queue_create(const char *name,
 odp_queue_type_t type,
  odp_queue_param_t *param);

  /**
 + * Destroy ODP queue
 + *


Does it need the queue to be drained, will it drain the queue, will if free
buffers if it drains the queue.
does it wait if the queue is full
Are there any @warnings about its behaviour?


 + * @param queueQueue handle


in or out ?


 + *
 + * @return 0 if successful


what cases cause a failure, what is returned value in those case?


 + */
 +int odp_queue_destroy(odp_queue_t queue);
 +
 +/**
   * Find a queue by name
   *
   * @param nameQueue name
 --
 1.7.9.5


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




-- 
*Mike Holmes*
Linaro  Sr Technical Manager
LNG - ODP
___
lng-odp mailing list
lng-odp@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/lng-odp


[lng-odp] [PATCH 3/5] pktio: mac addr functions

2014-11-26 Thread Maxim Uvarov
Define API for mac address change and implement linux-generic version.

Signed-off-by: Maxim Uvarov maxim.uva...@linaro.org
---
 platform/linux-generic/include/api/odp_packet_io.h | 23 
 platform/linux-generic/odp_packet_io.c | 67 ++
 2 files changed, 90 insertions(+)

diff --git a/platform/linux-generic/include/api/odp_packet_io.h 
b/platform/linux-generic/include/api/odp_packet_io.h
index 20425be..480d930 100644
--- a/platform/linux-generic/include/api/odp_packet_io.h
+++ b/platform/linux-generic/include/api/odp_packet_io.h
@@ -173,6 +173,29 @@ int odp_pktio_promisc_set(odp_pktio_t id, odp_bool enable);
 int odp_pktio_promisc_enabled(odp_pktio_t id);
 
 /**
+ * Set the default MAC address of a packet IO interface.
+ *
+ * @param[in] id ODP packet IO handle.
+ * @param[in] mac_addr   MAC address to be assigned to the interface.
+ * @param[in] addr_size  Size of the address in bytes.
+ *
+ * @return 0 on success, -1 on error.
+ */
+int odp_pktio_mac_addr_set(odp_pktio_t id, const unsigned char *mac_addr,
+  size_t addr_size);
+
+/**
+ * Get the default MAC address of a packet IO interface.
+ *
+ * @param[in]  idODP packet IO handle.
+ * @param[out] mac_addr  Storage for MAC address of the packet IO interface.
+ *
+ * @retval -1 on any error.
+ * @retval size of mac addr.
+ */
+int odp_pktio_mac_addr(odp_pktio_t id, unsigned char *mac_addr);
+
+/**
  * @}
  */
 
diff --git a/platform/linux-generic/odp_packet_io.c 
b/platform/linux-generic/odp_packet_io.c
index b1dbc41..72531b3 100644
--- a/platform/linux-generic/odp_packet_io.c
+++ b/platform/linux-generic/odp_packet_io.c
@@ -21,6 +21,7 @@
 
 #include string.h
 #include sys/ioctl.h
+#include linux/if_arp.h
 
 typedef struct {
pktio_entry_t entries[ODP_CONFIG_PKTIO_ENTRIES];
@@ -616,3 +617,69 @@ int odp_pktio_promisc_enabled(odp_pktio_t id)
else
return 0;
 }
+
+int odp_pktio_mac_addr_set(odp_pktio_t id, const unsigned char *mac_addr,
+   size_t addr_size)
+{
+   pktio_entry_t *entry;
+   int sockfd;
+   struct ifreq ifr;
+   int ret;
+
+   entry = get_entry(id);
+   if (entry == NULL) {
+   ODP_DBG(pktio entry %d does not exist\n, id);
+   return -1;
+   }
+
+   if (entry-s.pkt_sock_mmap.sockfd)
+   sockfd = entry-s.pkt_sock_mmap.sockfd;
+   else
+   sockfd = entry-s.pkt_sock.sockfd;
+
+   strncpy(ifr.ifr_name, entry-s.name, IFNAMSIZ - 1);
+   ifr.ifr_name[IFNAMSIZ] = 0;
+   memcpy(ifr.ifr_hwaddr.sa_data, mac_addr, addr_size);
+   ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER;
+
+   ret = ioctl(sockfd, SIOCSIFHWADDR, ifr);
+   if (ret  0) {
+   ODP_DBG(ioctl SIOCSIFHWADDR error\n);
+   return -1;
+   }
+
+   return 0;
+}
+
+int odp_pktio_mac_addr(odp_pktio_t id, unsigned char *mac_addr)
+{
+   pktio_entry_t *entry;
+   int sockfd;
+   struct ifreq ifr;
+   int ret;
+
+   entry = get_entry(id);
+   if (entry == NULL) {
+   ODP_DBG(pktio entry %d does not exist\n, id);
+   return -1;
+   }
+
+   if (entry-s.pkt_sock_mmap.sockfd)
+   sockfd = entry-s.pkt_sock_mmap.sockfd;
+   else
+   sockfd = entry-s.pkt_sock.sockfd;
+
+   strncpy(ifr.ifr_name, entry-s.name, IFNAMSIZ - 1);
+   ifr.ifr_name[IFNAMSIZ] = 0;
+
+   ret = ioctl(sockfd, SIOCGIFHWADDR, ifr);
+   if (ret  0) {
+   ODP_DBG(ioctl SIOCGIFHWADDR error\n);
+   return -1;
+   }
+
+   memcpy(mac_addr, (unsigned char *)ifr.ifr_ifru.ifru_hwaddr.sa_data,
+  ETH_ALEN);
+
+   return ETH_ALEN;
+}
-- 
1.8.5.1.163.gd7aced9


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


[lng-odp] [PATCH 4/5] cunit: pktio: mtu and promisc mode

2014-11-26 Thread Maxim Uvarov
Add basic check for mtu and promisc modes.

Signed-off-by: Maxim Uvarov maxim.uva...@linaro.org
---
 test/validation/Makefile.am |   4 +-
 test/validation/odp_pktio.c | 164 
 2 files changed, 167 insertions(+), 1 deletion(-)
 create mode 100644 test/validation/odp_pktio.c

diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am
index 0b831d0..91adc7e 100644
--- a/test/validation/Makefile.am
+++ b/test/validation/Makefile.am
@@ -6,11 +6,12 @@ AM_LDFLAGS += -L$(CUNIT_PATH)/lib -static -lcunit
 if ODP_CUNIT_ENABLED
 TESTS = ${bin_PROGRAMS}
 check_PROGRAMS = ${bin_PROGRAMS}
-bin_PROGRAMS = odp_init odp_queue odp_crypto
+bin_PROGRAMS = odp_init odp_queue odp_crypto odp_pktio
 odp_init_LDFLAGS = $(AM_LDFLAGS)
 odp_queue_LDFLAGS = $(AM_LDFLAGS)
 odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto
 odp_crypto_LDFLAGS = $(AM_LDFLAGS)
+odp_pktio_LDFLAGS = $(AM_LDFLAGS)
 endif
 
 dist_odp_init_SOURCES = odp_init.c
@@ -18,3 +19,4 @@ dist_odp_queue_SOURCES = odp_queue.c
 dist_odp_crypto_SOURCES = crypto/odp_crypto_test_async_inp.c \
  crypto/odp_crypto_test_sync_inp.c \
  odp_crypto.c
+dist_odp_pktio_SOURCES = odp_pktio.c
diff --git a/test/validation/odp_pktio.c b/test/validation/odp_pktio.c
new file mode 100644
index 000..56fece9
--- /dev/null
+++ b/test/validation/odp_pktio.c
@@ -0,0 +1,164 @@
+/* Copyright (c) 2014, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:BSD-3-Clause
+ */
+
+#include odp.h
+#include CUnit/Basic.h
+
+#define SHM_PKT_POOL_SIZE  (512 * 2048 * 2)
+#define SHM_PKT_POOL_BUF_SIZE  (1024 * 32)
+
+#define SHM_COMPL_POOL_SIZE(128 * 1024)
+#define SHM_COMPL_POOL_BUF_SIZE128
+
+static odp_pktio_t pktio;
+
+static void test_pktio_mtu(void)
+{
+   int i;
+   int ret;
+   int def;
+
+   def = odp_pktio_mtu(pktio);
+   CU_ASSERT(def  0);
+
+   for (i = 64; i  9000; i *= 2) {
+   printf( %d , i);
+
+   ret = odp_pktio_set_mtu(pktio, i);
+   CU_ASSERT(0 == ret);
+
+   ret = odp_pktio_mtu(pktio);
+   CU_ASSERT(ret == i);
+   }
+
+   ret = odp_pktio_set_mtu(pktio, def);
+   CU_ASSERT(0 == ret);
+
+   return;
+}
+
+static void test_pktio_promisc(void)
+{
+   int ret;
+
+   ret = odp_pktio_promisc_set(pktio, 1);
+   CU_ASSERT(ret == 0);
+
+   /* Check */
+   ret = odp_pktio_promisc_enabled(pktio);
+   CU_ASSERT(ret == 1);
+
+   ret = odp_pktio_promisc_set(pktio, 0);
+   CU_ASSERT(ret == 0);
+
+   /* Check */
+   ret = odp_pktio_promisc_enabled(pktio);
+   CU_ASSERT(ret == 0);
+
+   return;
+}
+
+int main(void)
+{
+   odp_shm_t shm;
+   void *pool_base;
+   odp_buffer_pool_t pool;
+   odp_queue_t out_queue;
+   CU_pSuite ptr_suite;
+   CU_pTest ptest;
+
+   if (odp_init_global(NULL, NULL)) {
+   printf(ODP global init failed.\n);
+   return -1;
+   }
+   odp_init_local();
+
+   shm = odp_shm_reserve(shm_packet_pool,
+   SHM_PKT_POOL_SIZE,
+   ODP_CACHE_LINE_SIZE, 0);
+
+   pool_base = odp_shm_addr(shm);
+   if (!pool_base) {
+   fprintf(stderr, Packet pool allocation failed.\n);
+   return -1;
+   }
+
+   pool = odp_buffer_pool_create(packet_pool, pool_base,
+   SHM_PKT_POOL_SIZE,
+   SHM_PKT_POOL_BUF_SIZE,
+   ODP_CACHE_LINE_SIZE,
+   ODP_BUFFER_TYPE_PACKET);
+   if (ODP_BUFFER_POOL_INVALID == pool) {
+   fprintf(stderr, Packet pool creation failed.\n);
+   return -1;
+   }
+   out_queue = odp_queue_create(crypto-out,
+   ODP_QUEUE_TYPE_POLL, NULL);
+   if (ODP_QUEUE_INVALID == out_queue) {
+   fprintf(stderr, Crypto outq creation failed.\n);
+   return -1;
+   }
+   shm = odp_shm_reserve(shm_compl_pool,
+   SHM_COMPL_POOL_SIZE,
+   ODP_CACHE_LINE_SIZE,
+   ODP_SHM_SW_ONLY);
+   pool_base = odp_shm_addr(shm);
+   if (!pool_base) {
+   fprintf(stderr, Completion pool allocation failed.\n);
+   return -1;
+   }
+   pool = odp_buffer_pool_create(compl_pool, pool_base,
+   SHM_COMPL_POOL_SIZE,
+   SHM_COMPL_POOL_BUF_SIZE,
+   ODP_CACHE_LINE_SIZE,
+   ODP_BUFFER_TYPE_RAW);
+   if (ODP_BUFFER_POOL_INVALID == pool) {
+   fprintf(stderr, Completion pool creation failed.\n);
+   return -1;
+   }
+
+   /* Open a packet IO instance for this thread */
+   pktio = odp_pktio_open(eth0, pool);
+   if (pktio == ODP_PKTIO_INVALID) {
+   fprintf(stderr, Error: pktio create failed\n);
+  

[lng-odp] [PATCH 5/5] cunit: add mac test

2014-11-26 Thread Maxim Uvarov
Mac address unit test.

Signed-off-by: Maxim Uvarov maxim.uva...@linaro.org
---
 test/validation/odp_pktio.c | 46 +
 1 file changed, 46 insertions(+)

diff --git a/test/validation/odp_pktio.c b/test/validation/odp_pktio.c
index 56fece9..c3eb65b 100644
--- a/test/validation/odp_pktio.c
+++ b/test/validation/odp_pktio.c
@@ -6,6 +6,7 @@
 
 #include odp.h
 #include CUnit/Basic.h
+#include linux/if_ether.h
 
 #define SHM_PKT_POOL_SIZE  (512 * 2048 * 2)
 #define SHM_PKT_POOL_BUF_SIZE  (1024 * 32)
@@ -15,6 +16,45 @@
 
 static odp_pktio_t pktio;
 
+static void test_pktio_mac(void)
+{
+   unsigned char mac_addr[ETH_ALEN];
+   unsigned char def_mac_addr[ETH_ALEN];
+   size_t mac_len;
+   int ret;
+   int i;
+
+   mac_len = odp_pktio_mac_addr(pktio, mac_addr);
+   CU_ASSERT(ETH_ALEN == mac_len);
+
+   printf( %X:%X:%X:%X:%X:%X ,
+  mac_addr[0], mac_addr[1], mac_addr[2],
+  mac_addr[3], mac_addr[4], mac_addr[5]);
+
+   /* save original mac addr */
+   memcpy(def_mac_addr, mac_addr, ETH_ALEN);
+
+   /* Modify addr */
+   for (i = 0; i  ETH_ALEN; i++)
+   mac_addr[i] = i * 2;
+
+   ret = odp_pktio_mac_addr_set(pktio, mac_addr, ETH_ALEN);
+   CU_ASSERT(0 == ret);
+
+   /* Verify */
+   mac_len = odp_pktio_mac_addr(pktio, mac_addr);
+   CU_ASSERT(ETH_ALEN == mac_len);
+
+   for (i = 0; i  ETH_ALEN; i++)
+   CU_ASSERT(mac_addr[i] == (i * 2));
+
+   /* Restore original mac */
+   ret = odp_pktio_mac_addr_set(pktio, def_mac_addr, ETH_ALEN);
+   CU_ASSERT(0 == ret);
+
+   return;
+}
+
 static void test_pktio_mtu(void)
 {
int i;
@@ -152,6 +192,12 @@ int main(void)
return CU_get_error();
}
 
+   ptest = CU_ADD_TEST(ptr_suite, test_pktio_mac);
+   if (NULL == ptest) {
+   CU_cleanup_registry();
+   return CU_get_error();
+   }
+
/* Run all tests using the CUnit Basic interface */
CU_basic_set_mode(CU_BRM_VERBOSE);
CU_basic_run_tests();
-- 
1.8.5.1.163.gd7aced9


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


[lng-odp] [PATCH 2/5] promisc mode manipulation functions

2014-11-26 Thread Maxim Uvarov
Define API and implement promisc functions for linux-generic.

Signed-off-by: Maxim Uvarov maxim.uva...@linaro.org
---
 platform/linux-generic/include/api/odp_packet_io.h | 24 +++
 platform/linux-generic/odp_packet_io.c | 74 ++
 2 files changed, 98 insertions(+)

diff --git a/platform/linux-generic/include/api/odp_packet_io.h 
b/platform/linux-generic/include/api/odp_packet_io.h
index 667395c..20425be 100644
--- a/platform/linux-generic/include/api/odp_packet_io.h
+++ b/platform/linux-generic/include/api/odp_packet_io.h
@@ -149,6 +149,30 @@ int odp_pktio_set_mtu(odp_pktio_t id, int mtu);
 int odp_pktio_mtu(odp_pktio_t id);
 
 /**
+ * Enable promiscuous mode on a packet IO interface.
+ *
+ * @param[in] id   ODP packet IO handle.
+ * @param[in] enable1 enabled, 0 disabled.
+ *
+ * @retval  0 on success.
+ * @retval -1 on a bad pktio id
+ * @retval -1 any other error
+ */
+int odp_pktio_promisc_set(odp_pktio_t id, odp_bool enable);
+
+/**
+ * Determine if promiscuous mode is enabled for a packet IO interface.
+ *
+ * @param[in] id ODP packet IO handle.
+ *
+ * @retval  1 if promiscuous mode is enabled.
+ * @retval  0 if promiscuous mode is disabled.
+ * @retval -1 on a bad pktio id
+ * @retval -1 any other error
+*/
+int odp_pktio_promisc_enabled(odp_pktio_t id);
+
+/**
  * @}
  */
 
diff --git a/platform/linux-generic/odp_packet_io.c 
b/platform/linux-generic/odp_packet_io.c
index c523350..b1dbc41 100644
--- a/platform/linux-generic/odp_packet_io.c
+++ b/platform/linux-generic/odp_packet_io.c
@@ -542,3 +542,77 @@ int odp_pktio_mtu(odp_pktio_t id)
 
return ifr.ifr_mtu;
 }
+
+int odp_pktio_promisc_set(odp_pktio_t id, odp_bool enable)
+{
+   pktio_entry_t *entry;
+   int sockfd;
+   struct ifreq ifr;
+   int ret;
+
+   entry = get_entry(id);
+   if (entry == NULL) {
+   ODP_DBG(pktio entry %d does not exist\n, id);
+   return -1;
+   }
+
+   if (entry-s.pkt_sock_mmap.sockfd)
+   sockfd = entry-s.pkt_sock_mmap.sockfd;
+   else
+   sockfd = entry-s.pkt_sock.sockfd;
+
+   strncpy(ifr.ifr_name, entry-s.name, IFNAMSIZ - 1);
+   ifr.ifr_name[IFNAMSIZ] = 0;
+
+   ret = ioctl(sockfd, SIOCGIFFLAGS, ifr);
+   if (ret  0) {
+   ODP_DBG(ioctl SIOCGIFFLAGS error\n);
+   return -1;
+   }
+
+   if (enable)
+   ifr.ifr_flags |= IFF_PROMISC;
+   else
+   ifr.ifr_flags = ~(IFF_PROMISC);
+
+   ret = ioctl(sockfd, SIOCSIFFLAGS, ifr);
+   if (ret  0) {
+   ODP_DBG(ioctl SIOCSIFFLAGS error\n);
+   return -1;
+   }
+
+   return 0;
+}
+
+int odp_pktio_promisc_enabled(odp_pktio_t id)
+{
+   pktio_entry_t *entry;
+   int sockfd;
+   struct ifreq ifr;
+   int ret;
+
+   entry = get_entry(id);
+   if (entry == NULL) {
+   ODP_DBG(pktio entry %d does not exist\n, id);
+   return -1;
+   }
+
+   if (entry-s.pkt_sock_mmap.sockfd)
+   sockfd = entry-s.pkt_sock_mmap.sockfd;
+   else
+   sockfd = entry-s.pkt_sock.sockfd;
+
+   strncpy(ifr.ifr_name, entry-s.name, IFNAMSIZ - 1);
+   ifr.ifr_name[IFNAMSIZ] = 0;
+
+   ret = ioctl(sockfd, SIOCGIFFLAGS, ifr);
+   if (ret  0) {
+   ODP_DBG(ioctl SIOCGIFFLAGS error\n);
+   return -1;
+   }
+
+   if (ifr.ifr_flags  IFF_PROMISC)
+   return 1;
+   else
+   return 0;
+}
-- 
1.8.5.1.163.gd7aced9


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


[lng-odp] [RFC] cunit: Add tests for scheduler API

2014-11-26 Thread Ciprian Barbu
Signed-off-by: Ciprian Barbu ciprian.ba...@linaro.org
---
I started from scratch this time trying to follow the list Taras proposed. This
patch covers the first 4 bullets on his lists.

One thing I need to mention is that the schedule_mq_mt_prio_atomic would not
work (at least on linux-generic) without using odp_schedule_release_atomic.
This might make bullet 6 on Taras' list not needed, I need some clarification
on this.

 test/validation/.gitignore |   1 +
 test/validation/Makefile.am|   4 +-
 test/validation/schedule/odp_schedule.c|  36 ++
 test/validation/schedule/odp_schedule_test.c   | 450 +
 test/validation/schedule/odp_schedule_testsuites.h |  21 +
 5 files changed, 511 insertions(+), 1 deletion(-)
 create mode 100644 test/validation/schedule/odp_schedule.c
 create mode 100644 test/validation/schedule/odp_schedule_test.c
 create mode 100644 test/validation/schedule/odp_schedule_testsuites.h

diff --git a/test/validation/.gitignore b/test/validation/.gitignore
index 696cf0a..c0556e6 100644
--- a/test/validation/.gitignore
+++ b/test/validation/.gitignore
@@ -3,3 +3,4 @@
 odp_init
 odp_queue
 odp_crypto
+odp_schedule
diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am
index 0b831d0..9e9f84f 100644
--- a/test/validation/Makefile.am
+++ b/test/validation/Makefile.am
@@ -6,7 +6,7 @@ AM_LDFLAGS += -L$(CUNIT_PATH)/lib -static -lcunit
 if ODP_CUNIT_ENABLED
 TESTS = ${bin_PROGRAMS}
 check_PROGRAMS = ${bin_PROGRAMS}
-bin_PROGRAMS = odp_init odp_queue odp_crypto
+bin_PROGRAMS = odp_init odp_queue odp_crypto odp_schedule
 odp_init_LDFLAGS = $(AM_LDFLAGS)
 odp_queue_LDFLAGS = $(AM_LDFLAGS)
 odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto
@@ -18,3 +18,5 @@ dist_odp_queue_SOURCES = odp_queue.c
 dist_odp_crypto_SOURCES = crypto/odp_crypto_test_async_inp.c \
  crypto/odp_crypto_test_sync_inp.c \
  odp_crypto.c
+dist_odp_schedule_SOURCES = schedule/odp_schedule_test.c \
+   schedule/odp_schedule.c
diff --git a/test/validation/schedule/odp_schedule.c 
b/test/validation/schedule/odp_schedule.c
new file mode 100644
index 000..9ce1281
--- /dev/null
+++ b/test/validation/schedule/odp_schedule.c
@@ -0,0 +1,36 @@
+/* Copyright (c) 2014, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include odp_schedule_testsuites.h
+
+static CU_SuiteInfo suites[] = {
+   {
+   Scheduler tests ,
+   schedule_test_init,
+   schedule_test_finalize,
+   NULL,
+   NULL,
+   schedule_tests
+   },
+   CU_SUITE_INFO_NULL,
+};
+
+int main(void)
+{
+   CU_set_error_action(CUEA_ABORT);
+   /* initialize the CUnit test registry */
+   if (CUE_SUCCESS != CU_initialize_registry())
+   return CU_get_error();
+
+   /* register suites */
+   CU_register_suites(suites);
+   /* Run all tests using the CUnit Basic interface */
+   CU_basic_set_mode(CU_BRM_VERBOSE);
+   CU_basic_run_tests();
+   CU_cleanup_registry();
+
+   return CU_get_error();
+}
diff --git a/test/validation/schedule/odp_schedule_test.c 
b/test/validation/schedule/odp_schedule_test.c
new file mode 100644
index 000..5a469a6
--- /dev/null
+++ b/test/validation/schedule/odp_schedule_test.c
@@ -0,0 +1,450 @@
+/* Copyright (c) 2014, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include odp_schedule_testsuites.h
+#include odph_linux.h
+
+#define MAX_WORKERS32/** Max worker threads */
+#define MSG_POOL_SIZE   (4*1024*1024)
+#define QUEUES_PER_PRIO16/** Queue per priority */
+#define BUF_SIZE   64
+#define TEST_NUM_BUFS  10
+
+#define GLOBALS_SHM_NAME   test_globals
+#define MSG_POOL_NAME  msg_pool
+#define SHM_MSG_POOL_NAME  shm_msg_pool
+#define SHM_THR_ARGS_NAME  shm_thr_args
+
+
+/** Test global variables */
+typedef struct {
+   int core_count; /** Core count */
+   int proc_mode;  /** Process mode */
+   odp_barrier_t barrier;/** @private Barrier for test synchronisation */
+   odp_schedule_prio_t prio;
+   int prio_buf_count; /** Number of bufs received at current prio */
+   odp_spinlock_t count_lock; /** Used for accessing prio counters */
+} test_globals_t;
+
+typedef struct {
+   odp_schedule_sync_t sync;
+   int num_queues;
+   int num_prio;
+   int use_barrier;
+} thread_args_t;
+
+odp_buffer_pool_t pool;
+
+/**
+ * @internal CUnit test case for verifying functionality of
+ *   schedule_wait_time
+ */
+static void schedule_wait_time(void)
+{
+   uint64_t wait_time;
+
+   wait_time = odp_schedule_wait_time(0);
+   CU_ASSERT(wait_time  0);
+
+   wait_time = odp_schedule_wait_time(1);
+   

Re: [lng-odp] [PATCH 3/5] pktio: mac addr functions

2014-11-26 Thread Victor Kamensky
On 26 November 2014 at 09:31, Maxim Uvarov maxim.uva...@linaro.org wrote:
 Define API for mac address change and implement linux-generic version.

 Signed-off-by: Maxim Uvarov maxim.uva...@linaro.org
 ---
  platform/linux-generic/include/api/odp_packet_io.h | 23 
  platform/linux-generic/odp_packet_io.c | 67 
 ++
  2 files changed, 90 insertions(+)

 diff --git a/platform/linux-generic/include/api/odp_packet_io.h 
 b/platform/linux-generic/include/api/odp_packet_io.h
 index 20425be..480d930 100644
 --- a/platform/linux-generic/include/api/odp_packet_io.h
 +++ b/platform/linux-generic/include/api/odp_packet_io.h
 @@ -173,6 +173,29 @@ int odp_pktio_promisc_set(odp_pktio_t id, odp_bool 
 enable);
  int odp_pktio_promisc_enabled(odp_pktio_t id);

  /**
 + * Set the default MAC address of a packet IO interface.
 + *
 + * @param[in] id ODP packet IO handle.
 + * @param[in] mac_addr   MAC address to be assigned to the interface.
 + * @param[in] addr_size  Size of the address in bytes.
 + *
 + * @return 0 on success, -1 on error.
 + */
 +int odp_pktio_mac_addr_set(odp_pktio_t id, const unsigned char *mac_addr,
 +  size_t addr_size);
 +
 +/**
 + * Get the default MAC address of a packet IO interface.
 + *
 + * @param[in]  idODP packet IO handle.
 + * @param[out] mac_addr  Storage for MAC address of the packet IO interface.

How user knows what size should be allocated for this storage?
Note if it is assumed to be fixed size, documentation should say
so. But such approach would be inconsitent with odp_pktio_mac_addr_set
function which does pass size of mac_addr storage to set.

Maybe you want to pass size that user allocated
for mac_addr storage and use it to copy result while
returning real size of mac_addr, so user can compare
whether it got all of it, and provide storage with required
size if not.

Thanks,
Victor

 + *
 + * @retval -1 on any error.
 + * @retval size of mac addr.
 + */
 +int odp_pktio_mac_addr(odp_pktio_t id, unsigned char *mac_addr);
 +
 +/**
   * @}
   */

 diff --git a/platform/linux-generic/odp_packet_io.c 
 b/platform/linux-generic/odp_packet_io.c
 index b1dbc41..72531b3 100644
 --- a/platform/linux-generic/odp_packet_io.c
 +++ b/platform/linux-generic/odp_packet_io.c
 @@ -21,6 +21,7 @@

  #include string.h
  #include sys/ioctl.h
 +#include linux/if_arp.h

  typedef struct {
 pktio_entry_t entries[ODP_CONFIG_PKTIO_ENTRIES];
 @@ -616,3 +617,69 @@ int odp_pktio_promisc_enabled(odp_pktio_t id)
 else
 return 0;
  }
 +
 +int odp_pktio_mac_addr_set(odp_pktio_t id, const unsigned char *mac_addr,
 +   size_t addr_size)
 +{
 +   pktio_entry_t *entry;
 +   int sockfd;
 +   struct ifreq ifr;
 +   int ret;
 +
 +   entry = get_entry(id);
 +   if (entry == NULL) {
 +   ODP_DBG(pktio entry %d does not exist\n, id);
 +   return -1;
 +   }
 +
 +   if (entry-s.pkt_sock_mmap.sockfd)
 +   sockfd = entry-s.pkt_sock_mmap.sockfd;
 +   else
 +   sockfd = entry-s.pkt_sock.sockfd;
 +
 +   strncpy(ifr.ifr_name, entry-s.name, IFNAMSIZ - 1);
 +   ifr.ifr_name[IFNAMSIZ] = 0;
 +   memcpy(ifr.ifr_hwaddr.sa_data, mac_addr, addr_size);
 +   ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER;
 +
 +   ret = ioctl(sockfd, SIOCSIFHWADDR, ifr);
 +   if (ret  0) {
 +   ODP_DBG(ioctl SIOCSIFHWADDR error\n);
 +   return -1;
 +   }
 +
 +   return 0;
 +}
 +
 +int odp_pktio_mac_addr(odp_pktio_t id, unsigned char *mac_addr)
 +{
 +   pktio_entry_t *entry;
 +   int sockfd;
 +   struct ifreq ifr;
 +   int ret;
 +
 +   entry = get_entry(id);
 +   if (entry == NULL) {
 +   ODP_DBG(pktio entry %d does not exist\n, id);
 +   return -1;
 +   }
 +
 +   if (entry-s.pkt_sock_mmap.sockfd)
 +   sockfd = entry-s.pkt_sock_mmap.sockfd;
 +   else
 +   sockfd = entry-s.pkt_sock.sockfd;
 +
 +   strncpy(ifr.ifr_name, entry-s.name, IFNAMSIZ - 1);
 +   ifr.ifr_name[IFNAMSIZ] = 0;
 +
 +   ret = ioctl(sockfd, SIOCGIFHWADDR, ifr);
 +   if (ret  0) {
 +   ODP_DBG(ioctl SIOCGIFHWADDR error\n);
 +   return -1;
 +   }
 +
 +   memcpy(mac_addr, (unsigned char *)ifr.ifr_ifru.ifru_hwaddr.sa_data,
 +  ETH_ALEN);
 +
 +   return ETH_ALEN;
 +}
 --
 1.8.5.1.163.gd7aced9


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

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


[lng-odp] [PATCH] api_guide_lines: Update bool, is, has and get rules

2014-11-26 Thread Mike Holmes
The API require guide lines to help it conform to a consistent look and feel.
These additional clarifications help promote those guidelines.

Signed-off-by: Mike Holmes mike.hol...@linaro.org
---
 api_guide_lines.dox | 30 +-
 1 file changed, 25 insertions(+), 5 deletions(-)

diff --git a/api_guide_lines.dox b/api_guide_lines.dox
index 4903961..be23e9a 100644
--- a/api_guide_lines.dox
+++ b/api_guide_lines.dox
@@ -48,7 +48,7 @@ type | Correct use
  |---| :-
 void | SHOULD be used for APIs that do not return a value
 void*| SHOULD be used for APIs that return a pointer intended to be used by 
the caller. For example, a routine that returns the address of an application 
context area SHOULD use a void * return type
-int  | SHOULD be used for APIs that return a boolean value. The values 1 = 
true, 0 = false are used for this purpose
+odp_bool_t  | SHOULD be used for APIs that return a @ref boolean value.
 int  | SHOULD be used for success and failure indications, with 0 indicating a 
success. Errno may be set
 
 @subsection parameters Parameter Structure and Validation
@@ -79,6 +79,27 @@ Other mechanisms available to the implementer are:
  - ODP_LOG() is used to direct implementation messages to the application.
 
 
+@subsection function_name Function Names
+Functions must attempt to be so clear in their intent that referencing the 
documentation is not necessary, the guidelines below should be followed unless 
a strong case is made for an exception.
+
+@subsection getters Getting information
+
+@subsubsection is_has Is / Has
+An api with is or has are both considered @ref boolean questions. They can 
only return true or false and it reflects the current state of something.
+
+An example might be a packet interface, you might want to know if it is in 
promiscuous mode.
+@code odp_bool_t state = odp_pktio_is_promiscuous(pktio handle) @endcode
+
+In addtion you might want to know if it has the ability to be in promiscuous 
mode.
+@code odp_bool_t state = odp_pktio_has_promiscuous(pktio handle) @endcode
+
+Another case might be if a packet has a vlan flag set
+@code odp_bool_t state = odp_packet_has_vlan(packet handle) @endcode
+
+@subsubsection get Get
+Where possible returned information should be an enum if it reflects a finite 
list of information.
+In general get apis drop the actual tag get in the function name.
+
 @subsection function_calls Function Calls
 ODP APIs typically have prototypes of the form:
 
@@ -95,7 +116,7 @@ p2_type   | Is the data type of the second 
parameter, etc.
 
 For ODP APIs that return void, results are undefined if the input parameters 
are invalid.
 For those that return void *, the value ODP_NULL or ODP_INVALID MAY be used to 
indicate call failure.
-For non-boolean APIs returning int, a return value of 0 indicates success 
while non-zero indicates failure.
+For non-boolean APIs returning int, a return value of 0 indicates success 
while non-zero indicates failure see @ref success.
 
 @subsection errno Use of errno
 ODP APIs SHOULD make use of the thread-local variable errno, defined in the 
standard library include file errno.h, to indicate a reason for an API call 
failure when appropriate.
@@ -116,14 +137,13 @@ An example of this might be the number of queues that an 
application can create.
 An attempt to allocate more queues than the underlying implementation supports 
would result in this failure code being returned via errno.
 
 @subsection boolean Boolean
-For odp booleans are integers (int)
-The values 1 = true, 0 = false are used for this purpose.
+For odp all booleans are integers. To aid application readability they are 
defined as the type odp_bool_t.
+The values  !0 = true, 0 = false are used for this purpose.
 
 @subsection success Success and Failure
 Pass indications are integers (int) and SHOULD also be used for APIs that 
return a simple success/failure indication to the caller.
 In this case the return value 0 indicates success while non-zero (typically 
-1) indicates failure and errno is set to a reason code that indicates the 
nature of the failure.
 
-
 @section implementation Implementation Considerations
 To support application portability and preserve implementation flexibility, 
ODP APIs MUST be designed with several guiding principles in mind.
 
-- 
2.1.0


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


[lng-odp] [PATCH] api: doxygen: odp_system_info.h

2014-11-26 Thread Mike Holmes
Improve the documentation regarding possible return values.

Signed-off-by: Mike Holmes mike.hol...@linaro.org
---
 platform/linux-generic/include/api/odp_system_info.h | 19 ++-
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/platform/linux-generic/include/api/odp_system_info.h 
b/platform/linux-generic/include/api/odp_system_info.h
index bcd08d7..28ce669 100644
--- a/platform/linux-generic/include/api/odp_system_info.h
+++ b/platform/linux-generic/include/api/odp_system_info.h
@@ -28,28 +28,34 @@ extern C {
 /**
  * CPU frequency in Hz
  *
- * @return CPU frequency in Hz
+ * @retval CPU frequency in Hz
+ * @retval 0 on error
  */
 uint64_t odp_sys_cpu_hz(void);
 
 /**
  * Huge page size in bytes
  *
- * @return Huge page size in bytes
+ * @retval Huge page size in bytes
+ * @retval 0 on error
  */
 uint64_t odp_sys_huge_page_size(void);
 
 /**
  * Page size in bytes
  *
- * @return Page size in bytes
+ * This is set at compile time via ODP_PAGE_SIZE
+ * @retval Page size in bytes
+ *
  */
 uint64_t odp_sys_page_size(void);
 
 /**
  * CPU model name
  *
- * @return Pointer to CPU model name string
+ * @note max size is 127 chars + null termination
+ * @retval Pointer to CPU model name string
+ * @retval null teminated string on failure
  */
 const char *odp_sys_cpu_model_str(void);
 
@@ -63,7 +69,10 @@ int odp_sys_cache_line_size(void);
 /**
  * Core count
  *
- * @return Core count
+ * @note The total physical number of cores, the current number avalable might 
be less.
+ *
+ * @retval Core count
+ * @retval 0 on error
  */
 int odp_sys_core_count(void);
 
-- 
2.1.0


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


[lng-odp] linux-generic 'odp_packet_parse': Failure to parse VLAN frames

2014-11-26 Thread Shmulik Ladkani
Hi,

It seems packet parsing in Linux implementation fails to analyze VLAN
frames (on most recent Linux systems).

The implementation of 'odp_packet_parse' relies on frame's ethtype field
to be either 0x8100 or 0x88A8 (i.e 802.1q and 802.1ad) for
identification of vlan frames.

Problem is, Linux carries packet's VLAN information out-of-band (in
buffer's meta-data), and packet's data is stripped from the vlan header.

This is done regardless of whether HW RX VLAN offload is enabled.
(More precisely, if HW RX VLAN offload is disabled, software mimics its
behavior. Rationale is probably to align implementation by having an
invariant: VLAN info is always in meta-data).

For AF_PACKET sockets, the way to get VLAN information in usermode is by
reading PACKET_AUXDATA cmsg (in the recvmsg case), or by examining
tp_status and tp_vlan_tci of the tpacket2_hdr (in the mmap case).

Any plans this is going to be adderssed for linux-generic's
'odp_packet_parse'?

Regards,
Shmulik

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


Re: [lng-odp] [PATCH] api: doxygen: odp_system_info.h

2014-11-26 Thread Ola Liljedahl
I disprove of this patch.

On 26 November 2014 at 20:20, Mike Holmes mike.hol...@linaro.org wrote:
 Improve the documentation regarding possible return values.

 Signed-off-by: Mike Holmes mike.hol...@linaro.org
 ---
  platform/linux-generic/include/api/odp_system_info.h | 19 ++-
  1 file changed, 14 insertions(+), 5 deletions(-)

 diff --git a/platform/linux-generic/include/api/odp_system_info.h 
 b/platform/linux-generic/include/api/odp_system_info.h
 index bcd08d7..28ce669 100644
 --- a/platform/linux-generic/include/api/odp_system_info.h
 +++ b/platform/linux-generic/include/api/odp_system_info.h
 @@ -28,28 +28,34 @@ extern C {
  /**
   * CPU frequency in Hz
   *
 - * @return CPU frequency in Hz
 + * @retval CPU frequency in Hz
Normally called CPU clock frequency.
Is this current clock frequency or max (peak) frequency (for turbo
mode) or max steady state frequency?
As ODP applications normally busy wait, the kernel DVFS (voltage and
frequency scaling) support will likely rack up the clock frequency
(the threads never block so the system must be really busy, better to
try to complete processing as quickly as possible). But at application
start when this function is called, the clock frequency might still be
rather low.

Power management and frequency scaling is something we need to look
closer at in the future. The current support in Linux is probably not
designed for applications that busy wait all the time and never
complete. The kernel has no understanding of the load and thus
performance requirements of the ODP applications.

 + * @retval 0 on error
or we failed to detect the CPU frequency

   */
  uint64_t odp_sys_cpu_hz(void);

  /**
   * Huge page size in bytes
   *
 - * @return Huge page size in bytes
 + * @retval Huge page size in bytes
 + * @retval 0 on error
   */
  uint64_t odp_sys_huge_page_size(void);

  /**
   * Page size in bytes
   *
 - * @return Page size in bytes
 + * This is set at compile time via ODP_PAGE_SIZE
 + * @retval Page size in bytes
 + *
   */
  uint64_t odp_sys_page_size(void);

  /**
   * CPU model name
   *
 - * @return Pointer to CPU model name string
 + * @note max size is 127 chars + null termination
 + * @retval Pointer to CPU model name string
 + * @retval null teminated string on failure
   */
  const char *odp_sys_cpu_model_str(void);

 @@ -63,7 +69,10 @@ int odp_sys_cache_line_size(void);
  /**
   * Core count
   *
 - * @return Core count
 + * @note The total physical number of cores, the current number avalable 
 might be less.
I think this function should rather return the number of available
cores, not the total number of
cores in the system (as handled by the kernel). Not all cores might be
available to the ODP
application (for different reasons, e.g. not online or the application
has been bound to a certain
subset of cores). It's meaningless for the ODP application to know
about resources that it
cannot (and should not) use.

 + *
 + * @retval Core count
 + * @retval 0 on error
   */
  int odp_sys_core_count(void);

 --
 2.1.0


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

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


Re: [lng-odp] [PATCH] api: doxygen: odp_system_info.h

2014-11-26 Thread Mike Holmes
On 26 November 2014 at 15:23, Ola Liljedahl ola.liljed...@linaro.org
wrote:

 I disprove of this patch.

 On 26 November 2014 at 20:20, Mike Holmes mike.hol...@linaro.org wrote:
  Improve the documentation regarding possible return values.
 
  Signed-off-by: Mike Holmes mike.hol...@linaro.org
  ---
   platform/linux-generic/include/api/odp_system_info.h | 19
 ++-
   1 file changed, 14 insertions(+), 5 deletions(-)
 
  diff --git a/platform/linux-generic/include/api/odp_system_info.h
 b/platform/linux-generic/include/api/odp_system_info.h
  index bcd08d7..28ce669 100644
  --- a/platform/linux-generic/include/api/odp_system_info.h
  +++ b/platform/linux-generic/include/api/odp_system_info.h
  @@ -28,28 +28,34 @@ extern C {
   /**
* CPU frequency in Hz
*
  - * @return CPU frequency in Hz
  + * @retval CPU frequency in Hz
 Normally called CPU clock frequency.
 Is this current clock frequency or max (peak) frequency (for turbo
 mode) or max steady state frequency?


Linux generic gets the information from /proc/cpuinfo  - I assume that is
the max frequency, but we need to clarify


 As ODP applications normally busy wait, the kernel DVFS (voltage and
 frequency scaling) support will likely rack up the clock frequency
 (the threads never block so the system must be really busy, better to
 try to complete processing as quickly as possible). But at application
 start when this function is called, the clock frequency might still be
 rather low.

 Power management and frequency scaling is something we need to look
 closer at in the future. The current support in Linux is probably not
 designed for applications that busy wait all the time and never
 complete. The kernel has no understanding of the load and thus
 performance requirements of the ODP applications.

  + * @retval 0 on error
 or we failed to detect the CPU frequency


This is populated at init time, it should fail there, if it does not it
will be 0 if the speed is not grepped accurately.
As above I hope this is max as it is not a dynamic value.


*/
   uint64_t odp_sys_cpu_hz(void);
 
   /**
* Huge page size in bytes
*
  - * @return Huge page size in bytes
  + * @retval Huge page size in bytes
  + * @retval 0 on error
*/
   uint64_t odp_sys_huge_page_size(void);
 
   /**
* Page size in bytes
*
  - * @return Page size in bytes
  + * This is set at compile time via ODP_PAGE_SIZE
  + * @retval Page size in bytes
  + *
*/
   uint64_t odp_sys_page_size(void);
 
   /**
* CPU model name
*
  - * @return Pointer to CPU model name string
  + * @note max size is 127 chars + null termination
  + * @retval Pointer to CPU model name string
  + * @retval null teminated string on failure
*/
   const char *odp_sys_cpu_model_str(void);
 
  @@ -63,7 +69,10 @@ int odp_sys_cache_line_size(void);
   /**
* Core count
*
  - * @return Core count
  + * @note The total physical number of cores, the current number
 available might be less.
 I think this function should rather return the number of available
 cores, not the total number of
 cores in the system (as handled by the kernel). Not all cores might be
 available to the ODP
 application (for different reasons, e.g. not online or the application
 has been bound to a certain
 subset of cores). It's meaningless for the ODP application to know
 about resources that it
 cannot (and should not) use.


Don't disagree, but that is not how it is currently coded, I think you have
a patch floating that will fix the code and it can amend the docs too.



  + *
  + * @retval Core count
  + * @retval 0 on error
*/
   int odp_sys_core_count(void);
 
  --
  2.1.0
 
 
  ___
  lng-odp mailing list
  lng-odp@lists.linaro.org
  http://lists.linaro.org/mailman/listinfo/lng-odp




-- 
*Mike Holmes*
Linaro  Sr Technical Manager
LNG - ODP
___
lng-odp mailing list
lng-odp@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/lng-odp


Re: [lng-odp] [PATCH 3/5] pktio: mac addr functions

2014-11-26 Thread Maxim Uvarov

On 11/26/2014 09:00 PM, Victor Kamensky wrote:

On 26 November 2014 at 09:31, Maxim Uvarov maxim.uva...@linaro.org wrote:

Define API for mac address change and implement linux-generic version.

Signed-off-by: Maxim Uvarov maxim.uva...@linaro.org
---
  platform/linux-generic/include/api/odp_packet_io.h | 23 
  platform/linux-generic/odp_packet_io.c | 67 ++
  2 files changed, 90 insertions(+)

diff --git a/platform/linux-generic/include/api/odp_packet_io.h 
b/platform/linux-generic/include/api/odp_packet_io.h
index 20425be..480d930 100644
--- a/platform/linux-generic/include/api/odp_packet_io.h
+++ b/platform/linux-generic/include/api/odp_packet_io.h
@@ -173,6 +173,29 @@ int odp_pktio_promisc_set(odp_pktio_t id, odp_bool enable);
  int odp_pktio_promisc_enabled(odp_pktio_t id);

  /**
+ * Set the default MAC address of a packet IO interface.
+ *
+ * @param[in] id ODP packet IO handle.
+ * @param[in] mac_addr   MAC address to be assigned to the interface.
+ * @param[in] addr_size  Size of the address in bytes.
+ *
+ * @return 0 on success, -1 on error.
+ */
+int odp_pktio_mac_addr_set(odp_pktio_t id, const unsigned char *mac_addr,
+  size_t addr_size);
+
+/**
+ * Get the default MAC address of a packet IO interface.
+ *
+ * @param[in]  idODP packet IO handle.
+ * @param[out] mac_addr  Storage for MAC address of the packet IO interface.

How user knows what size should be allocated for this storage?
Note if it is assumed to be fixed size, documentation should say
so. But such approach would be inconsitent with odp_pktio_mac_addr_set
function which does pass size of mac_addr storage to set.

Maybe you want to pass size that user allocated
for mac_addr storage and use it to copy result while
returning real size of mac_addr, so user can compare
whether it got all of it, and provide storage with required
size if not.

Thanks,
Victor


how about adding note that memory len for mac addr should use:

#define ODP_PKTIO_MAC_ADDR_MAX_LEN 8
?

Maxim.

+ *
+ * @retval -1 on any error.
+ * @retval size of mac addr.
+ */
+int odp_pktio_mac_addr(odp_pktio_t id, unsigned char *mac_addr);
+
+/**
   * @}
   */

diff --git a/platform/linux-generic/odp_packet_io.c 
b/platform/linux-generic/odp_packet_io.c
index b1dbc41..72531b3 100644
--- a/platform/linux-generic/odp_packet_io.c
+++ b/platform/linux-generic/odp_packet_io.c
@@ -21,6 +21,7 @@

  #include string.h
  #include sys/ioctl.h
+#include linux/if_arp.h

  typedef struct {
 pktio_entry_t entries[ODP_CONFIG_PKTIO_ENTRIES];
@@ -616,3 +617,69 @@ int odp_pktio_promisc_enabled(odp_pktio_t id)
 else
 return 0;
  }
+
+int odp_pktio_mac_addr_set(odp_pktio_t id, const unsigned char *mac_addr,
+   size_t addr_size)
+{
+   pktio_entry_t *entry;
+   int sockfd;
+   struct ifreq ifr;
+   int ret;
+
+   entry = get_entry(id);
+   if (entry == NULL) {
+   ODP_DBG(pktio entry %d does not exist\n, id);
+   return -1;
+   }
+
+   if (entry-s.pkt_sock_mmap.sockfd)
+   sockfd = entry-s.pkt_sock_mmap.sockfd;
+   else
+   sockfd = entry-s.pkt_sock.sockfd;
+
+   strncpy(ifr.ifr_name, entry-s.name, IFNAMSIZ - 1);
+   ifr.ifr_name[IFNAMSIZ] = 0;
+   memcpy(ifr.ifr_hwaddr.sa_data, mac_addr, addr_size);
+   ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER;
+
+   ret = ioctl(sockfd, SIOCSIFHWADDR, ifr);
+   if (ret  0) {
+   ODP_DBG(ioctl SIOCSIFHWADDR error\n);
+   return -1;
+   }
+
+   return 0;
+}
+
+int odp_pktio_mac_addr(odp_pktio_t id, unsigned char *mac_addr)
+{
+   pktio_entry_t *entry;
+   int sockfd;
+   struct ifreq ifr;
+   int ret;
+
+   entry = get_entry(id);
+   if (entry == NULL) {
+   ODP_DBG(pktio entry %d does not exist\n, id);
+   return -1;
+   }
+
+   if (entry-s.pkt_sock_mmap.sockfd)
+   sockfd = entry-s.pkt_sock_mmap.sockfd;
+   else
+   sockfd = entry-s.pkt_sock.sockfd;
+
+   strncpy(ifr.ifr_name, entry-s.name, IFNAMSIZ - 1);
+   ifr.ifr_name[IFNAMSIZ] = 0;
+
+   ret = ioctl(sockfd, SIOCGIFHWADDR, ifr);
+   if (ret  0) {
+   ODP_DBG(ioctl SIOCGIFHWADDR error\n);
+   return -1;
+   }
+
+   memcpy(mac_addr, (unsigned char *)ifr.ifr_ifru.ifru_hwaddr.sa_data,
+  ETH_ALEN);
+
+   return ETH_ALEN;
+}
--
1.8.5.1.163.gd7aced9


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



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


Re: [lng-odp] [PATCH 3/5] pktio: mac addr functions

2014-11-26 Thread Victor Kamensky
On 26 November 2014 at 13:19, Maxim Uvarov maxim.uva...@linaro.org wrote:
 On 11/26/2014 09:00 PM, Victor Kamensky wrote:

 On 26 November 2014 at 09:31, Maxim Uvarov maxim.uva...@linaro.org
 wrote:

 Define API for mac address change and implement linux-generic version.

 Signed-off-by: Maxim Uvarov maxim.uva...@linaro.org
 ---
   platform/linux-generic/include/api/odp_packet_io.h | 23 
   platform/linux-generic/odp_packet_io.c | 67
 ++
   2 files changed, 90 insertions(+)

 diff --git a/platform/linux-generic/include/api/odp_packet_io.h
 b/platform/linux-generic/include/api/odp_packet_io.h
 index 20425be..480d930 100644
 --- a/platform/linux-generic/include/api/odp_packet_io.h
 +++ b/platform/linux-generic/include/api/odp_packet_io.h
 @@ -173,6 +173,29 @@ int odp_pktio_promisc_set(odp_pktio_t id, odp_bool
 enable);
   int odp_pktio_promisc_enabled(odp_pktio_t id);

   /**
 + * Set the default MAC address of a packet IO interface.
 + *
 + * @param[in] id ODP packet IO handle.
 + * @param[in] mac_addr   MAC address to be assigned to the interface.
 + * @param[in] addr_size  Size of the address in bytes.
 + *
 + * @return 0 on success, -1 on error.
 + */
 +int odp_pktio_mac_addr_set(odp_pktio_t id, const unsigned char
 *mac_addr,
 +  size_t addr_size);
 +
 +/**
 + * Get the default MAC address of a packet IO interface.
 + *
 + * @param[in]  idODP packet IO handle.
 + * @param[out] mac_addr  Storage for MAC address of the packet IO
 interface.

 How user knows what size should be allocated for this storage?
 Note if it is assumed to be fixed size, documentation should say
 so. But such approach would be inconsitent with odp_pktio_mac_addr_set
 function which does pass size of mac_addr storage to set.

 Maybe you want to pass size that user allocated
 for mac_addr storage and use it to copy result while
 returning real size of mac_addr, so user can compare
 whether it got all of it, and provide storage with required
 size if not.

 Thanks,
 Victor


 how about adding note that memory len for mac addr should use:

 #define ODP_PKTIO_MAC_ADDR_MAX_LEN 8
 ?

It would not address my point about inconsistency between
odp_pktio_mac_addr, and odp_pktio_mac_addr_set function.
Why one has 'size' parameter, and another does not.

Also if user always must past mac_addr pointer to storage
size of ODP_PKTIO_MAC_ADDR_MAX_LEN, would it not be
better to have its type as 'const unsigned
char[ODP_PKTIO_MAC_ADDR_MAX]_LEN'?

Thanks,
Victor


 Maxim.

 + *
 + * @retval -1 on any error.
 + * @retval size of mac addr.
 + */
 +int odp_pktio_mac_addr(odp_pktio_t id, unsigned char *mac_addr);
 +
 +/**
* @}
*/

 diff --git a/platform/linux-generic/odp_packet_io.c
 b/platform/linux-generic/odp_packet_io.c
 index b1dbc41..72531b3 100644
 --- a/platform/linux-generic/odp_packet_io.c
 +++ b/platform/linux-generic/odp_packet_io.c
 @@ -21,6 +21,7 @@

   #include string.h
   #include sys/ioctl.h
 +#include linux/if_arp.h

   typedef struct {
  pktio_entry_t entries[ODP_CONFIG_PKTIO_ENTRIES];
 @@ -616,3 +617,69 @@ int odp_pktio_promisc_enabled(odp_pktio_t id)
  else
  return 0;
   }
 +
 +int odp_pktio_mac_addr_set(odp_pktio_t id, const unsigned char
 *mac_addr,
 +   size_t addr_size)
 +{
 +   pktio_entry_t *entry;
 +   int sockfd;
 +   struct ifreq ifr;
 +   int ret;
 +
 +   entry = get_entry(id);
 +   if (entry == NULL) {
 +   ODP_DBG(pktio entry %d does not exist\n, id);
 +   return -1;
 +   }
 +
 +   if (entry-s.pkt_sock_mmap.sockfd)
 +   sockfd = entry-s.pkt_sock_mmap.sockfd;
 +   else
 +   sockfd = entry-s.pkt_sock.sockfd;
 +
 +   strncpy(ifr.ifr_name, entry-s.name, IFNAMSIZ - 1);
 +   ifr.ifr_name[IFNAMSIZ] = 0;
 +   memcpy(ifr.ifr_hwaddr.sa_data, mac_addr, addr_size);
 +   ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER;
 +
 +   ret = ioctl(sockfd, SIOCSIFHWADDR, ifr);
 +   if (ret  0) {
 +   ODP_DBG(ioctl SIOCSIFHWADDR error\n);
 +   return -1;
 +   }
 +
 +   return 0;
 +}
 +
 +int odp_pktio_mac_addr(odp_pktio_t id, unsigned char *mac_addr)
 +{
 +   pktio_entry_t *entry;
 +   int sockfd;
 +   struct ifreq ifr;
 +   int ret;
 +
 +   entry = get_entry(id);
 +   if (entry == NULL) {
 +   ODP_DBG(pktio entry %d does not exist\n, id);
 +   return -1;
 +   }
 +
 +   if (entry-s.pkt_sock_mmap.sockfd)
 +   sockfd = entry-s.pkt_sock_mmap.sockfd;
 +   else
 +   sockfd = entry-s.pkt_sock.sockfd;
 +
 +   strncpy(ifr.ifr_name, entry-s.name, IFNAMSIZ - 1);
 +   ifr.ifr_name[IFNAMSIZ] = 0;
 +
 +   ret = ioctl(sockfd, SIOCGIFHWADDR, ifr);
 +   if (ret  0) {
 +   ODP_DBG(ioctl SIOCGIFHWADDR error\n);
 +   return -1;
 +   }
 +
 +   memcpy(mac_addr, (unsigned char
 

Re: [lng-odp] [PATCH 3/5] pktio: mac addr functions

2014-11-26 Thread Maxim Uvarov

On 11/27/2014 12:43 AM, Victor Kamensky wrote:

On 26 November 2014 at 13:19, Maxim Uvarov maxim.uva...@linaro.org wrote:

On 11/26/2014 09:00 PM, Victor Kamensky wrote:

On 26 November 2014 at 09:31, Maxim Uvarov maxim.uva...@linaro.org
wrote:

Define API for mac address change and implement linux-generic version.

Signed-off-by: Maxim Uvarov maxim.uva...@linaro.org
---
   platform/linux-generic/include/api/odp_packet_io.h | 23 
   platform/linux-generic/odp_packet_io.c | 67
++
   2 files changed, 90 insertions(+)

diff --git a/platform/linux-generic/include/api/odp_packet_io.h
b/platform/linux-generic/include/api/odp_packet_io.h
index 20425be..480d930 100644
--- a/platform/linux-generic/include/api/odp_packet_io.h
+++ b/platform/linux-generic/include/api/odp_packet_io.h
@@ -173,6 +173,29 @@ int odp_pktio_promisc_set(odp_pktio_t id, odp_bool
enable);
   int odp_pktio_promisc_enabled(odp_pktio_t id);

   /**
+ * Set the default MAC address of a packet IO interface.
+ *
+ * @param[in] id ODP packet IO handle.
+ * @param[in] mac_addr   MAC address to be assigned to the interface.
+ * @param[in] addr_size  Size of the address in bytes.
+ *
+ * @return 0 on success, -1 on error.
+ */
+int odp_pktio_mac_addr_set(odp_pktio_t id, const unsigned char
*mac_addr,
+  size_t addr_size);
+
+/**
+ * Get the default MAC address of a packet IO interface.
+ *
+ * @param[in]  idODP packet IO handle.
+ * @param[out] mac_addr  Storage for MAC address of the packet IO
interface.

How user knows what size should be allocated for this storage?
Note if it is assumed to be fixed size, documentation should say
so. But such approach would be inconsitent with odp_pktio_mac_addr_set
function which does pass size of mac_addr storage to set.

Maybe you want to pass size that user allocated
for mac_addr storage and use it to copy result while
returning real size of mac_addr, so user can compare
whether it got all of it, and provide storage with required
size if not.

Thanks,
Victor


how about adding note that memory len for mac addr should use:

#define ODP_PKTIO_MAC_ADDR_MAX_LEN 8
?

It would not address my point about inconsistency between
odp_pktio_mac_addr, and odp_pktio_mac_addr_set function.
Why one has 'size' parameter, and another does not.

Also if user always must past mac_addr pointer to storage
size of ODP_PKTIO_MAC_ADDR_MAX_LEN, would it not be
better to have its type as 'const unsigned
char[ODP_PKTIO_MAC_ADDR_MAX]_LEN'?

Thanks,
Victor



Understand your point now. Now  I think that it's better for 
implementation to

provide storage for mac address. It might be part of pktio_entry.

So current call might be:

int odp_pktio_mac_addr(odp_pktio_t id, unsigned char **mac_addr);

Or even better we can provide to api hole pktio_enty struct.

I.e.

struct odp_pktio_entry * odp_pktio_get(id);
And this return entry will have eveything for current pktio: name, mac, 
promisc mode and etc.
So that we will have one function for everything. And it's will be 
linked to packet i/o handle. So we know

when handle is freed all this data can not be accessed.

But that might be too late for odp 1.0. And I don't want to delay with 
more round of review / discussion.

Might be  const unsigned char[ODP_PKTIO_MAC_ADDR_MAX_LEN] is good for now.

Maxim.



Maxim.


+ *
+ * @retval -1 on any error.
+ * @retval size of mac addr.
+ */
+int odp_pktio_mac_addr(odp_pktio_t id, unsigned char *mac_addr);
+
+/**
* @}
*/

diff --git a/platform/linux-generic/odp_packet_io.c
b/platform/linux-generic/odp_packet_io.c
index b1dbc41..72531b3 100644
--- a/platform/linux-generic/odp_packet_io.c
+++ b/platform/linux-generic/odp_packet_io.c
@@ -21,6 +21,7 @@

   #include string.h
   #include sys/ioctl.h
+#include linux/if_arp.h

   typedef struct {
  pktio_entry_t entries[ODP_CONFIG_PKTIO_ENTRIES];
@@ -616,3 +617,69 @@ int odp_pktio_promisc_enabled(odp_pktio_t id)
  else
  return 0;
   }
+
+int odp_pktio_mac_addr_set(odp_pktio_t id, const unsigned char
*mac_addr,
+   size_t addr_size)
+{
+   pktio_entry_t *entry;
+   int sockfd;
+   struct ifreq ifr;
+   int ret;
+
+   entry = get_entry(id);
+   if (entry == NULL) {
+   ODP_DBG(pktio entry %d does not exist\n, id);
+   return -1;
+   }
+
+   if (entry-s.pkt_sock_mmap.sockfd)
+   sockfd = entry-s.pkt_sock_mmap.sockfd;
+   else
+   sockfd = entry-s.pkt_sock.sockfd;
+
+   strncpy(ifr.ifr_name, entry-s.name, IFNAMSIZ - 1);
+   ifr.ifr_name[IFNAMSIZ] = 0;
+   memcpy(ifr.ifr_hwaddr.sa_data, mac_addr, addr_size);
+   ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER;
+
+   ret = ioctl(sockfd, SIOCSIFHWADDR, ifr);
+   if (ret  0) {
+   ODP_DBG(ioctl SIOCSIFHWADDR error\n);
+   return -1;
+   }
+
+   return 0;
+}
+
+int odp_pktio_mac_addr(odp_pktio_t id, unsigned 

Re: [lng-odp] linux-generic 'odp_packet_parse': Failure to parse VLAN frames

2014-11-26 Thread Maxim Uvarov

On 11/26/2014 11:23 PM, Shmulik Ladkani wrote:

Hi,

It seems packet parsing in Linux implementation fails to analyze VLAN
frames (on most recent Linux systems).

The implementation of 'odp_packet_parse' relies on frame's ethtype field
to be either 0x8100 or 0x88A8 (i.e 802.1q and 802.1ad) for
identification of vlan frames.

Problem is, Linux carries packet's VLAN information out-of-band (in
buffer's meta-data), and packet's data is stripped from the vlan header.

This is done regardless of whether HW RX VLAN offload is enabled.
(More precisely, if HW RX VLAN offload is disabled, software mimics its
behavior. Rationale is probably to align implementation by having an
invariant: VLAN info is always in meta-data).


Classification patch has to cover vlan:
https://patches.linaro.org/41300/



For AF_PACKET sockets, the way to get VLAN information in usermode is by
reading PACKET_AUXDATA cmsg (in the recvmsg case), or by examining
tp_status and tp_vlan_tci of the tpacket2_hdr (in the mmap case).

Any plans this is going to be adderssed for linux-generic's
'odp_packet_parse'?


yes, that has to be part of classification which will be merged soon.

Maxim.



Regards,
Shmulik

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



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


[lng-odp] junk output from ODP applications

2014-11-26 Thread Ola Liljedahl
Why is all of this junk always printed by ODP applications?

odp_buffer_pool.c:137:odp_buffer_pool_init_global():
Buffer pool init global
odp_buffer_pool.c:138:odp_buffer_pool_init_global():  pool_entry_s size 192
odp_buffer_pool.c:139:odp_buffer_pool_init_global():  pool_entry_t size 192
odp_buffer_pool.c:140:odp_buffer_pool_init_global():  odp_buffer_hdr_t size 120
odp_buffer_pool.c:141:odp_buffer_pool_init_global():
odp_queue.c:99:odp_queue_init_global():Queue init ...
odp_queue.c:119:odp_queue_init_global():done
odp_queue.c:120:odp_queue_init_global():Queue init global
odp_queue.c:122:odp_queue_init_global():  struct queue_entry_s size 192
odp_queue.c:124:odp_queue_init_global():  queue_entry_t size192
odp_queue.c:125:odp_queue_init_global():
odp_schedule.c:89:odp_schedule_init_global():Schedule init ... odp_schedule.c:1

Some seem rather meaningless. The size information could be useful but
should be made conditional (run-time or compile-time). Is there some
configuration API I should use? I weakly remember a log API patch
which would have supported this.

-- Ola

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


Re: [lng-odp] junk output from ODP applications

2014-11-26 Thread Maxim Uvarov

Already fixed. Do git pull.

Maxim.

On 11/27/2014 01:45 AM, Ola Liljedahl wrote:

Why is all of this junk always printed by ODP applications?

odp_buffer_pool.c:137:odp_buffer_pool_init_global():
Buffer pool init global
odp_buffer_pool.c:138:odp_buffer_pool_init_global():  pool_entry_s size 192
odp_buffer_pool.c:139:odp_buffer_pool_init_global():  pool_entry_t size 192
odp_buffer_pool.c:140:odp_buffer_pool_init_global():  odp_buffer_hdr_t size 120
odp_buffer_pool.c:141:odp_buffer_pool_init_global():
odp_queue.c:99:odp_queue_init_global():Queue init ...
odp_queue.c:119:odp_queue_init_global():done
odp_queue.c:120:odp_queue_init_global():Queue init global
odp_queue.c:122:odp_queue_init_global():  struct queue_entry_s size 192
odp_queue.c:124:odp_queue_init_global():  queue_entry_t size192
odp_queue.c:125:odp_queue_init_global():
odp_schedule.c:89:odp_schedule_init_global():Schedule init ... odp_schedule.c:1

Some seem rather meaningless. The size information could be useful but
should be made conditional (run-time or compile-time). Is there some
configuration API I should use? I weakly remember a log API patch
which would have supported this.

-- Ola

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



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


Re: [lng-odp] [PATCH v1 3/5] Linux-generic: Pktio changes for Classification

2014-11-26 Thread Bala Manoharan
Ping

On 26 November 2014 at 11:07, Bala Manoharan bala.manoha...@linaro.org
wrote:

 Hi,

 Pls let me know if there are any additional comments for this patch.
 If otherwise please provide reviewed-by

 Regards,
 Bala

 On 25 November 2014 03:24, Anders Roxell anders.rox...@linaro.org wrote:

 On 24 November 2014 at 22:45, Bill Fischofer bill.fischo...@linaro.org
 wrote:
  Again, this points out that we need to start merging patches.  Otherwise
  we're going to be spending all our time reworking and rebasing them
 rather
  than moving onto the next patch.  There's just no clean way to avoid
 this
  with API changes since they tend to get very interdependent as
 applications
  and tests start using them.

 Bill,

 We are merging patches, and there is always going to be a looser...
 There will be merge conflicts, that the submitter has to resolve if
 git am --3way don't do the trick.

 Cheers,
 Anders

 
  On Mon, Nov 24, 2014 at 3:37 PM, Maxim Uvarov maxim.uva...@linaro.org
  wrote:
 
  On 11/25/2014 12:34 AM, Mike Holmes wrote:
 
  This no longer applies, can you rebase it ?
 
 
  git am -3
 
  helps?
 
 
 
 
  On 21 November 2014 08:30, Bala Manoharan bala.manoha...@linaro.org
  wrote:
 
  Hi Maxim,
 
  As discussed, as per the current API a pktio can exist without
  initializing
  the classifier and in that case the packets are sent to the default
  queue
  for that pktio. We can test the classifier using the classifier
 example
  which I am currently working in parallel.
 
  Regards,
  Bala
 
  On 21 November 2014 18:18, Maxim Uvarov maxim.uva...@linaro.org
 wrote:
 
  On 11/21/2014 03:32 PM, Bala Manoharan wrote:
 
  Hi Maxim,
 
  Can we have those as separate patches.
  I would like to keep this patch as specific for linking pktio with
  classification.
  I have created this patch from the current odp tip.
 
  Regards,
  Bala
 
  My ideas was if we link now then we have workable example/packet
 with
  classifier.
  And we can check that basic functionality works and you don't forget
  init
  lock or something
  like that.
 
  Maxim.
 
  On 21 November 2014 17:37, Maxim Uvarov maxim.uva...@linaro.org
  mailto:maxim.uva...@linaro.org wrote:
 
   On 11/21/2014 11:53 AM, Balasubramanian Manoharan wrote:
 
   @@ -163,7 +169,7 @@ odp_pktio_t odp_pktio_open(const char
   *dev, odp_buffer_pool_t pool)
 
   Bala, I sent you patch to change API to odp_pktio_open( *dev,
   cost_t). It should be also included to that patch set.
 
   Thanks,
   Maxim.
 
   ___
   lng-odp mailing list
   lng-odp@lists.linaro.org mailto:lng-odp@lists.linaro.org
   http://lists.linaro.org/mailman/listinfo/lng-odp
 
 
 
  ___
  lng-odp mailing list
  lng-odp@lists.linaro.org
  http://lists.linaro.org/mailman/listinfo/lng-odp
 
 
 
 
 
  ___
  lng-odp mailing list
  lng-odp@lists.linaro.org
  http://lists.linaro.org/mailman/listinfo/lng-odp
 
 
 
  ___
  lng-odp mailing list
  lng-odp@lists.linaro.org
  http://lists.linaro.org/mailman/listinfo/lng-odp
 

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



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


[lng-odp] [PATCH v2] helper: odph_tcp header description

2014-11-26 Thread Balasubramanian Manoharan
This patch adds TCP header description struct odph_tcphdr_t
This structure is used for accessing TCP header information from the packet

Signed-off-by: Balasubramanian Manoharan bala.manoha...@linaro.org
---
V2: Removes Bit Fields from Header struct
 helper/include/odph_tcp.h | 90 +++
 1 file changed, 90 insertions(+)
 create mode 100644 helper/include/odph_tcp.h

diff --git a/helper/include/odph_tcp.h b/helper/include/odph_tcp.h
new file mode 100644
index 000..f625ac7
--- /dev/null
+++ b/helper/include/odph_tcp.h
@@ -0,0 +1,90 @@
+/* Copyright (c) 2014, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+
+/**
+ * @file
+ *
+ * ODP TCP header
+ */
+
+#ifndef ODPH_TCP_H_
+#define ODPH_TCP_H_
+
+#ifdef __cplusplus
+extern C {
+#endif
+
+#include odp_align.h
+#include odp_debug.h
+#include odp_byteorder.h
+
+/** @internal TCP header flag FIN offset */
+#define ODPH_TCPHDR_FIN_OFFSET 0
+
+/** @internal TCP header flag SYN offset */
+#define ODPH_TCPHDR_SYN_OFFSET 1
+
+/** @internal TCP header flag RST offset */
+#define ODPH_TCPHDR_RST_OFFSET 2
+
+/** @internal TCP header flag PSH offset */
+#define ODPH_TCPHDR_PSH_OFFSET 3
+
+/** @internal TCP header flag ACK offset */
+#define ODPH_TCPHDR_ACK_OFFSET 4
+
+/** @internal TCP header flag URG offset */
+#define ODPH_TCPHDR_URG_OFFSET 5
+
+/** @internal TCP header flag ECE offset */
+#define ODPH_TCPHDR_ECE_OFFSET 6
+
+/** @internal TCP header flag CWR offset */
+#define ODPH_TCPHDR_CWR_OFFSET 7
+
+/** @internal Returns TCP header FIN flag */
+#define ODPH_TCPHDR_FLAGS_FIN(flags) ((flags)  (1  ODPH_TCPHDR_FIN_OFFSET))
+
+/** @internal Returns TCP header SYN flag */
+#define ODPH_TCPHDR_FLAGS_SYN(flags) ((flags)  (1  ODPH_TCPHDR_SYN_OFFSET))
+
+/** @internal Returns TCP header RST flag */
+#define ODPH_TCPHDR_FLAGS_RST(flags) ((flags)  (1  ODPH_TCPHDR_RST_OFFSET))
+
+/** @internal Returns TCP header PSH flag */
+#define ODPH_TCPHDR_FLAGS_PSH(flags) ((flags)  (1  ODPH_TCPHDR_PSH_OFFSET))
+
+/** @internal Returns TCP header ACK flag */
+#define ODPH_TCPHDR_FLAGS_ACK(flags) ((flags)  (1  ODPH_TCPHDR_ACK_OFFSET))
+
+/** @internal Returns TCP header URG flag */
+#define ODPH_TCPHDR_FLAGS_URG(flags) ((flags)  (1  ODPH_TCPHDR_URG_OFFSET))
+
+/** @internal Returns TCP header ECE flag */
+#define ODPH_TCPHDR_FLAGS_ECE(flags) ((flags)  (1  ODPH_TCPHDR_ECE_OFFSET))
+
+/** @internal Returns TCP header CWR flag */
+#define ODPH_TCPHDR_FLAGS_CWR(flags) ((flags)  (1  ODPH_TCPHDR_CWR_OFFSET))
+
+/** TCP header */
+typedef struct ODP_PACKED {
+   uint16be_t src_port; /** Source port */
+   uint16be_t dst_port; /** Destinatino port */
+   uint32be_t seq_no;   /** Sequence number */
+   uint32be_t ack_no;   /** Acknowledgment number */
+   uint8_t data_offset; /** Data offset and reserved */
+   uint8_t flags;   /** TCP flags as a byte */
+   uint16be_t window;   /** Window size */
+   uint16be_t cksm; /** Checksum */
+   uint16be_t urgptr;   /** Urgent pointer */
+} odph_tcphdr_t;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
-- 
2.0.1.472.g6f92e5f


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