[lng-odp] [PATCHv1] test: classification: fix: update odp_pktin_queue_param_t

2017-07-27 Thread Balasubramanian Manoharan
classifier_enable field in odp_pktin_queue_param_t has to set to true
for classification test suite to function correctly.

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 .../validation/api/classification/odp_classification_common.c   | 2 ++
 .../validation/api/classification/odp_classification_tests.c| 2 ++
 2 files changed, 4 insertions(+)

diff --git 
a/test/common_plat/validation/api/classification/odp_classification_common.c 
b/test/common_plat/validation/api/classification/odp_classification_common.c
index eca30b8..1b142e1 100644
--- a/test/common_plat/validation/api/classification/odp_classification_common.c
+++ b/test/common_plat/validation/api/classification/odp_classification_common.c
@@ -50,6 +50,8 @@ odp_pktio_t create_pktio(odp_queue_type_t q_type, odp_pool_t 
pool)
 
odp_pktin_queue_param_init(_param);
pktin_param.queue_param.sched.sync = ODP_SCHED_SYNC_ATOMIC;
+   pktin_param.classifier_enable = true;
+   pktin_param.hash_enable = false;
 
if (odp_pktin_queue_config(pktio, _param)) {
fprintf(stderr, "pktin queue config failed.\n");
diff --git 
a/test/common_plat/validation/api/classification/odp_classification_tests.c 
b/test/common_plat/validation/api/classification/odp_classification_tests.c
index 4f43082..a0f73e3 100644
--- a/test/common_plat/validation/api/classification/odp_classification_tests.c
+++ b/test/common_plat/validation/api/classification/odp_classification_tests.c
@@ -52,6 +52,8 @@ int classification_suite_init(void)
 
odp_pktin_queue_param_init(_param);
pktin_param.queue_param.sched.sync = ODP_SCHED_SYNC_ATOMIC;
+   pktin_param.classifier_enable = true;
+   pktin_param.hash_enable = false;
 
if (odp_pktin_queue_config(pktio_loop, _param)) {
fprintf(stderr, "pktin queue config failed.\n");
-- 
1.9.1



[lng-odp] [PATCHv1] fix: classifier_enable field update for classification test cases

2017-07-27 Thread Balasubramanian Manoharan
classifier_enable field in odp_pktin_queue_param_t has to set to true
for classification test suite to function correctly.

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 .../validation/api/classification/odp_classification_common.c   | 2 ++
 .../validation/api/classification/odp_classification_tests.c| 2 ++
 2 files changed, 4 insertions(+)

diff --git 
a/test/common_plat/validation/api/classification/odp_classification_common.c 
b/test/common_plat/validation/api/classification/odp_classification_common.c
index eca30b8..1b142e1 100644
--- a/test/common_plat/validation/api/classification/odp_classification_common.c
+++ b/test/common_plat/validation/api/classification/odp_classification_common.c
@@ -50,6 +50,8 @@ odp_pktio_t create_pktio(odp_queue_type_t q_type, odp_pool_t 
pool)
 
odp_pktin_queue_param_init(_param);
pktin_param.queue_param.sched.sync = ODP_SCHED_SYNC_ATOMIC;
+   pktin_param.classifier_enable = true;
+   pktin_param.hash_enable = false;
 
if (odp_pktin_queue_config(pktio, _param)) {
fprintf(stderr, "pktin queue config failed.\n");
diff --git 
a/test/common_plat/validation/api/classification/odp_classification_tests.c 
b/test/common_plat/validation/api/classification/odp_classification_tests.c
index 4f43082..a0f73e3 100644
--- a/test/common_plat/validation/api/classification/odp_classification_tests.c
+++ b/test/common_plat/validation/api/classification/odp_classification_tests.c
@@ -52,6 +52,8 @@ int classification_suite_init(void)
 
odp_pktin_queue_param_init(_param);
pktin_param.queue_param.sched.sync = ODP_SCHED_SYNC_ATOMIC;
+   pktin_param.classifier_enable = true;
+   pktin_param.hash_enable = false;
 
if (odp_pktin_queue_config(pktio_loop, _param)) {
fprintf(stderr, "pktin queue config failed.\n");
-- 
1.9.1



[lng-odp] [API-NEXTv5 3/3] linux-generic: classification implement packet hashing

2017-07-27 Thread Balasubramanian Manoharan
implementation for packet hashing on classification

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 .../include/odp_classification_datamodel.h |  32 ++-
 .../include/odp_classification_internal.h  |   7 +
 platform/linux-generic/odp_classification.c| 234 ++---
 3 files changed, 244 insertions(+), 29 deletions(-)

diff --git a/platform/linux-generic/include/odp_classification_datamodel.h 
b/platform/linux-generic/include/odp_classification_datamodel.h
index fbe10cb..3cfe8c5 100644
--- a/platform/linux-generic/include/odp_classification_datamodel.h
+++ b/platform/linux-generic/include/odp_classification_datamodel.h
@@ -46,6 +46,22 @@ extern "C" {
 /* Max PMR Term bits */
 #define ODP_PMR_TERM_BYTES_MAX 16
 
+#define ODP_COS_QUEUE_MAX  32
+
+#define ODP_CLS_QUEUE_GROUP_MAX(ODP_COS_MAX_ENTRY * 
ODP_COS_QUEUE_MAX)
+
+typedef union {
+   /* All proto fileds */
+   uint32_t all;
+
+   struct {
+   uint32_t ipv4:1;
+   uint32_t ipv6:1;
+   uint32_t udp:1;
+   uint32_t tcp:1;
+   };
+} odp_cls_hash_proto_t;
+
 /**
 Packet Matching Rule Term Value
 
@@ -85,7 +101,7 @@ typedef struct pmr_term_value {
 Class Of Service
 */
 struct cos_s {
-   queue_t queue;  /* Associated Queue */
+   odp_queue_t queue;  /* Associated Queue */
odp_pool_t pool;/* Associated Buffer pool */
union pmr_u *pmr[ODP_PMR_PER_COS_MAX];  /* Chained PMR */
union cos_u *linked_cos[ODP_PMR_PER_COS_MAX]; /* Chained CoS with PMR*/
@@ -94,7 +110,12 @@ struct cos_s {
size_t headroom;/* Headroom for this CoS */
odp_spinlock_t lock;/* cos lock */
odp_atomic_u32_t num_rule;  /* num of PMRs attached with this CoS */
+   bool queue_group;
+   odp_cls_hash_proto_t hash_proto;
+   uint32_t num_queue;
+   odp_queue_param_t queue_param;
char name[ODP_COS_NAME_LEN];/* name */
+   uint8_t index;
 };
 
 typedef union cos_u {
@@ -122,6 +143,15 @@ typedef union pmr_u {
uint8_t pad[ROUNDUP_CACHE_LINE(sizeof(struct pmr_s))];
 } pmr_t;
 
+typedef struct _cls_queue_grp_tbl_s {
+   odp_queue_t queue[ODP_CLS_QUEUE_GROUP_MAX];
+} _cls_queue_grp_tbl_s;
+
+typedef union _cls_queue_grp_tbl_t {
+   _cls_queue_grp_tbl_s s;
+   uint8_t pad[ROUNDUP_CACHE_LINE(sizeof(_cls_queue_grp_tbl_s))];
+} _cls_queue_grp_tbl_t;
+
 /**
 L2 QoS and CoS Map
 
diff --git a/platform/linux-generic/include/odp_classification_internal.h 
b/platform/linux-generic/include/odp_classification_internal.h
index 78eaac9..aca8e8c 100644
--- a/platform/linux-generic/include/odp_classification_internal.h
+++ b/platform/linux-generic/include/odp_classification_internal.h
@@ -79,6 +79,9 @@ This function returns the CoS associated with L3 QoS value
 cos_t *match_qos_l3_cos(pmr_l3_cos_t *l3_cos, const uint8_t *pkt_addr,
odp_packet_hdr_t *hdr);
 
+void _odp_cls_update_hash_proto(cos_t *cos,
+   odp_pktin_hash_proto_t hash_proto);
+
 /**
 @internal
 CoS associated with L2 QoS value
@@ -138,6 +141,10 @@ Otherwise.
 **/
 int verify_pmr(pmr_t *pmr, const uint8_t *pkt_addr, odp_packet_hdr_t *pkt_hdr);
 
+uint32_t packet_rss_hash(odp_packet_hdr_t *pkt_hdr,
+odp_cls_hash_proto_t hash_proto,
+const uint8_t *base);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/platform/linux-generic/odp_classification.c 
b/platform/linux-generic/odp_classification.c
index cc08b9f..1959493 100644
--- a/platform/linux-generic/odp_classification.c
+++ b/platform/linux-generic/odp_classification.c
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -30,6 +31,15 @@
 
 static cos_tbl_t *cos_tbl;
 static pmr_tbl_t   *pmr_tbl;
+static _cls_queue_grp_tbl_t *queue_grp_tbl;
+
+const uint8_t default_rss[] = {
+   0x6d, 0x5a, 0x56, 0xda, 0x25, 0x5b, 0x0e, 0xc2,
+   0x41, 0x67, 0x25, 0x3d, 0x43, 0xa3, 0x8f, 0xb0,
+   0xd0, 0xca, 0x2b, 0xcb, 0xae, 0x7b, 0x30, 0xb4,
+   0x77, 0xcb, 0x2d, 0xa3, 0x80, 0x30, 0xf2, 0x0c,
+   0x6a, 0x42, 0xb7, 0x3b, 0xbe, 0xac, 0x01, 0xfa,
+};
 
 cos_t *get_cos_entry_internal(odp_cos_t cos_id)
 {
@@ -45,6 +55,7 @@ int odp_classification_init_global(void)
 {
odp_shm_t cos_shm;
odp_shm_t pmr_shm;
+   odp_shm_t queue_grp_shm;
int i;
 
cos_shm = odp_shm_reserve("shm_odp_cos_tbl",
@@ -89,8 +100,22 @@ int odp_classification_init_global(void)
LOCK_INIT(>s.lock);
}
 
+   queue_grp_shm = odp_shm_reserve("shm_odp_cls_queue_grp_tbl",
+   sizeof(_cls_queue_grp_tbl_t),
+   sizeof(queue_entry_t *), 0);
+
+   if (queue_grp_shm == ODP_SHM_

[lng-odp] [API-NEXTv5 2/3] linux-generic: add toeplitz hash algorithm

2017-07-27 Thread Balasubramanian Manoharan
Adds toeplitz hash algorithm implementation for RSS hashing

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 platform/linux-generic/include/protocols/thash.h | 108 +++
 1 file changed, 108 insertions(+)
 create mode 100644 platform/linux-generic/include/protocols/thash.h

diff --git a/platform/linux-generic/include/protocols/thash.h 
b/platform/linux-generic/include/protocols/thash.h
new file mode 100644
index 000..fe141e3
--- /dev/null
+++ b/platform/linux-generic/include/protocols/thash.h
@@ -0,0 +1,108 @@
+/* Copyright (c) 2017, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+/**
+ * @file
+ *
+ * ODP Toeplitz hash function
+ */
+
+#ifndef ODPH_THASH_H_
+#define ODPH_THASH_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include 
+
+/** IPv4 tuple
+ *
+ */
+typedef struct thash_ipv4_tuple {
+   uint32_t src_addr;
+   uint32_t dst_addr;
+   union {
+   struct {
+   uint16_t sport;
+   uint16_t dport;
+   };
+   uint32_t sctp_tag;
+   };
+} thash_ipv4_tuple_t;
+
+typedef struct thash_ipv6_tuple {
+   uint8_t src_addr[16];
+   uint8_t dst_addr[16];
+   union {
+   struct {
+   uint16_t sport;
+   uint16_t dport;
+   };
+   uint32_t sctp_tag;
+   };
+} thash_ipv6_tuple_t;
+
+#define ODP_THASH_V4_L4_LEN (sizeof(thash_ipv4_tuple_t) / 4)
+
+#define ODP_THASH_V4_L3_LEN ((sizeof(thash_ipv4_tuple_t) - \
+   sizeof(((thash_ipv4_tuple_t *)0)->sctp_tag)) / 4)
+
+#define ODP_THASH_V6_L4_LEN (sizeof(thash_ipv6_tuple_t) / 4)
+
+#define ODP_THASH_V6_L3_LEN ((sizeof(thash_ipv6_tuple_t) - \
+   sizeof(((thash_ipv6_tuple_t *)0)->sctp_tag)) / 4)
+
+typedef union {
+   thash_ipv4_tuple_t v4;
+   thash_ipv6_tuple_t v6;
+} thash_tuple_t;
+
+static inline
+void thash_load_ipv6_addr(const _odp_ipv6hdr_t *ipv6,
+ thash_tuple_t *tuple)
+{
+   int i;
+
+   for (i = 0; i < 4; i++) {
+   *((uint32_t *)tuple->v6.src_addr + i) =
+   odp_be_to_cpu_32(*((const uint32_t *)ipv6->src_addr.u32 + i));
+
+   *((uint32_t *)tuple->v6.dst_addr + i) =
+   odp_be_to_cpu_32(*((const uint32_t *)ipv6->dst_addr.u32 + i));
+   }
+}
+
+static inline
+uint32_t thash_softrss(uint32_t *tuple, uint8_t len,
+  const uint8_t *key)
+{
+   uint32_t i, j, ret;
+
+   ret = 0;
+   for (j = 0; j < len; j++) {
+   for (i = 0; i < 32; i++) {
+   if (tuple[j] & (1 << (31 - i))) {
+   ret ^= odp_cpu_to_be_32(((const uint32_t *)
+   key)[j]) << i | (uint32_t)((uint64_t)
+   (odp_cpu_to_be_32(((const uint32_t *)key)
+   [j + 1])) >> (32 - i));
+   }
+   }
+   }
+
+   return ret;
+}
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
-- 
1.9.1



[lng-odp] [API-NEXTv5 1/3] api: classification: add support for packet hashing in classification

2017-07-27 Thread Balasubramanian Manoharan
Enable packet hashing per CoS to be able to distribute incoming packets to
multiple queues linked with a CoS.

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 include/odp/api/spec/classification.h | 90 +--
 1 file changed, 85 insertions(+), 5 deletions(-)

diff --git a/include/odp/api/spec/classification.h 
b/include/odp/api/spec/classification.h
index 39831b2..c76555b 100644
--- a/include/odp/api/spec/classification.h
+++ b/include/odp/api/spec/classification.h
@@ -4,7 +4,6 @@
  * SPDX-License-Identifier: BSD-3-Clause
  */
 
-
 /**
  * @file
  *
@@ -19,12 +18,13 @@
 extern "C" {
 #endif
 
+#include 
+#include 
 /** @defgroup odp_classification ODP CLASSIFICATION
  *  Classification operations.
  *  @{
  */
 
-
 /**
  * @typedef odp_cos_t
  * ODP Class of service handle
@@ -126,6 +126,13 @@ typedef struct odp_cls_capability_t {
/** Maximum number of CoS supported */
unsigned max_cos;
 
+   /** Maximun number of queue supported per CoS
+* if the value is 1, then hashing is not supported*/
+   unsigned max_hash_queues;
+
+   /** Protocol header combination supported for Hashing */
+   odp_pktin_hash_proto_t hash_protocols;
+
/** A Boolean to denote support of PMR range */
odp_bool_t pmr_range_supported;
 } odp_cls_capability_t;
@@ -164,9 +171,40 @@ typedef enum {
  * Used to communicate class of service creation options
  */
 typedef struct odp_cls_cos_param {
-   odp_queue_t queue;  /**< Queue associated with CoS */
-   odp_pool_t pool;/**< Pool associated with CoS */
-   odp_cls_drop_t drop_policy; /**< Drop policy associated with CoS */
+   /* Number of queues to be linked to this CoS.
+* If the number is greater than 1 then hashing is enabled.
+* If number is equal to 1 then hashing is disabled.
+* When hashing is enabled the queues are created by the implementation
+* and application need not configure any queue to the class of service.
+* When hashing is disabled application has to configure the queue to
+* the class of service.
+* Depening on the implementation this number might be rounded-off to
+* nearest supported value (e.g power of 2)
+* */
+   uint32_t num_queue;
+
+   union {
+   /* Mapping used when num_queue = 1, hashing is disabled in
+* this case and application has to configure this queue and
+* packets are delivered to this queue */
+   odp_queue_t queue;
+
+   /* Mapping used when num_queue > 1, hashing is enabled in
+* this case and queues are created by the implementation */
+   struct {
+   /** Queue parameters */
+   odp_queue_param_t queue_param;
+
+   /* Protocol header fields which are included in
+* packet input hash calculation */
+   odp_pktin_hash_proto_t hash_proto;
+   };
+   };
+   /* Pool associated with CoS */
+   odp_pool_t pool;
+
+   /* Drop policy associated with CoS */
+   odp_cls_drop_t drop_policy;
 } odp_cls_cos_param_t;
 
 /**
@@ -209,6 +247,23 @@ int odp_cls_capability(odp_cls_capability_t *capability);
 odp_cos_t odp_cls_cos_create(const char *name, odp_cls_cos_param_t *param);
 
 /**
+ * Queue hash result
+ * Returns the queue within a CoS in which a particular packet will be enqueued
+ * based on the packet parameters and hash protocol field configured with the
+ * class of service.
+ *
+ * @param  cos class of service
+ * @param  packet  Packet handle
+ *
+ * @retval Returns the queue handle on which this packet will be
+ * enqueued.
+ * @retval ODP_QUEUE_INVALID for error case
+ *
+ * @note The packet has to be updated with valid header pointers L2, L3 and L4.
+ */
+odp_queue_t odp_cls_hash_result(odp_cos_t cos, odp_packet_t packet);
+
+/**
  * Discard a class-of-service along with all its associated resources
  *
  * @param[in]  cos_id  class-of-service instance.
@@ -245,6 +300,31 @@ int odp_cos_queue_set(odp_cos_t cos_id, odp_queue_t 
queue_id);
 odp_queue_t odp_cos_queue(odp_cos_t cos_id);
 
 /**
+ * Get the number of queues linked with the specific class-of-service
+ *
+ * @param  cos_id  class-of-service instance.
+ *
+ * @return Number of queues linked with the 
class-of-service.
+ */
+uint32_t odp_cls_cos_num_queue(odp_cos_t cos_id);
+
+/**
+ * Get the list of queue associated with the specific class-of-service
+ *
+ * @param[in]  cos_id  class-of-service instance.
+ *
+ * @param[out] queue   Array of queue handles associated
+ * with the class-of-service.
+ *
+ * @param[in]  num Maximum number of queue handle

[lng-odp] [API-NEXTv4 3/3] linux-generic: classification implement packet hashing

2017-07-24 Thread Balasubramanian Manoharan
implementation for packet hashing on classification

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 .../include/odp_classification_datamodel.h |  32 +++-
 .../include/odp_classification_internal.h  |   7 +
 platform/linux-generic/odp_classification.c| 198 ++---
 3 files changed, 207 insertions(+), 30 deletions(-)

diff --git a/platform/linux-generic/include/odp_classification_datamodel.h 
b/platform/linux-generic/include/odp_classification_datamodel.h
index fbe10cb..3cfe8c5 100644
--- a/platform/linux-generic/include/odp_classification_datamodel.h
+++ b/platform/linux-generic/include/odp_classification_datamodel.h
@@ -46,6 +46,22 @@ extern "C" {
 /* Max PMR Term bits */
 #define ODP_PMR_TERM_BYTES_MAX 16
 
+#define ODP_COS_QUEUE_MAX  32
+
+#define ODP_CLS_QUEUE_GROUP_MAX(ODP_COS_MAX_ENTRY * 
ODP_COS_QUEUE_MAX)
+
+typedef union {
+   /* All proto fileds */
+   uint32_t all;
+
+   struct {
+   uint32_t ipv4:1;
+   uint32_t ipv6:1;
+   uint32_t udp:1;
+   uint32_t tcp:1;
+   };
+} odp_cls_hash_proto_t;
+
 /**
 Packet Matching Rule Term Value
 
@@ -85,7 +101,7 @@ typedef struct pmr_term_value {
 Class Of Service
 */
 struct cos_s {
-   queue_t queue;  /* Associated Queue */
+   odp_queue_t queue;  /* Associated Queue */
odp_pool_t pool;/* Associated Buffer pool */
union pmr_u *pmr[ODP_PMR_PER_COS_MAX];  /* Chained PMR */
union cos_u *linked_cos[ODP_PMR_PER_COS_MAX]; /* Chained CoS with PMR*/
@@ -94,7 +110,12 @@ struct cos_s {
size_t headroom;/* Headroom for this CoS */
odp_spinlock_t lock;/* cos lock */
odp_atomic_u32_t num_rule;  /* num of PMRs attached with this CoS */
+   bool queue_group;
+   odp_cls_hash_proto_t hash_proto;
+   uint32_t num_queue;
+   odp_queue_param_t queue_param;
char name[ODP_COS_NAME_LEN];/* name */
+   uint8_t index;
 };
 
 typedef union cos_u {
@@ -122,6 +143,15 @@ typedef union pmr_u {
uint8_t pad[ROUNDUP_CACHE_LINE(sizeof(struct pmr_s))];
 } pmr_t;
 
+typedef struct _cls_queue_grp_tbl_s {
+   odp_queue_t queue[ODP_CLS_QUEUE_GROUP_MAX];
+} _cls_queue_grp_tbl_s;
+
+typedef union _cls_queue_grp_tbl_t {
+   _cls_queue_grp_tbl_s s;
+   uint8_t pad[ROUNDUP_CACHE_LINE(sizeof(_cls_queue_grp_tbl_s))];
+} _cls_queue_grp_tbl_t;
+
 /**
 L2 QoS and CoS Map
 
diff --git a/platform/linux-generic/include/odp_classification_internal.h 
b/platform/linux-generic/include/odp_classification_internal.h
index 78eaac9..aca8e8c 100644
--- a/platform/linux-generic/include/odp_classification_internal.h
+++ b/platform/linux-generic/include/odp_classification_internal.h
@@ -79,6 +79,9 @@ This function returns the CoS associated with L3 QoS value
 cos_t *match_qos_l3_cos(pmr_l3_cos_t *l3_cos, const uint8_t *pkt_addr,
odp_packet_hdr_t *hdr);
 
+void _odp_cls_update_hash_proto(cos_t *cos,
+   odp_pktin_hash_proto_t hash_proto);
+
 /**
 @internal
 CoS associated with L2 QoS value
@@ -138,6 +141,10 @@ Otherwise.
 **/
 int verify_pmr(pmr_t *pmr, const uint8_t *pkt_addr, odp_packet_hdr_t *pkt_hdr);
 
+uint32_t packet_rss_hash(odp_packet_hdr_t *pkt_hdr,
+odp_cls_hash_proto_t hash_proto,
+const uint8_t *base);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/platform/linux-generic/odp_classification.c 
b/platform/linux-generic/odp_classification.c
index cc08b9f..c90505d 100644
--- a/platform/linux-generic/odp_classification.c
+++ b/platform/linux-generic/odp_classification.c
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -30,6 +31,15 @@
 
 static cos_tbl_t *cos_tbl;
 static pmr_tbl_t   *pmr_tbl;
+static _cls_queue_grp_tbl_t *queue_grp_tbl;
+
+const uint8_t default_rss[] = {
+   0x6d, 0x5a, 0x56, 0xda, 0x25, 0x5b, 0x0e, 0xc2,
+   0x41, 0x67, 0x25, 0x3d, 0x43, 0xa3, 0x8f, 0xb0,
+   0xd0, 0xca, 0x2b, 0xcb, 0xae, 0x7b, 0x30, 0xb4,
+   0x77, 0xcb, 0x2d, 0xa3, 0x80, 0x30, 0xf2, 0x0c,
+   0x6a, 0x42, 0xb7, 0x3b, 0xbe, 0xac, 0x01, 0xfa,
+};
 
 cos_t *get_cos_entry_internal(odp_cos_t cos_id)
 {
@@ -45,6 +55,7 @@ int odp_classification_init_global(void)
 {
odp_shm_t cos_shm;
odp_shm_t pmr_shm;
+   odp_shm_t queue_grp_shm;
int i;
 
cos_shm = odp_shm_reserve("shm_odp_cos_tbl",
@@ -89,8 +100,22 @@ int odp_classification_init_global(void)
LOCK_INIT(>s.lock);
}
 
+   queue_grp_shm = odp_shm_reserve("shm_odp_cls_queue_grp_tbl",
+   sizeof(_cls_queue_grp_tbl_t),
+   sizeof(queue_entry_t *), 0);
+
+   if (queue_grp_shm == ODP_SHM_

[lng-odp] [API-NEXTv4 2/3] linux-generic: add toeplitz hash algorithm

2017-07-24 Thread Balasubramanian Manoharan
Adds toeplitz hash algorithm implementation for RSS hashing

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 platform/linux-generic/include/protocols/thash.h | 108 +++
 1 file changed, 108 insertions(+)
 create mode 100644 platform/linux-generic/include/protocols/thash.h

diff --git a/platform/linux-generic/include/protocols/thash.h 
b/platform/linux-generic/include/protocols/thash.h
new file mode 100644
index 000..fe141e3
--- /dev/null
+++ b/platform/linux-generic/include/protocols/thash.h
@@ -0,0 +1,108 @@
+/* Copyright (c) 2017, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+/**
+ * @file
+ *
+ * ODP Toeplitz hash function
+ */
+
+#ifndef ODPH_THASH_H_
+#define ODPH_THASH_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include 
+
+/** IPv4 tuple
+ *
+ */
+typedef struct thash_ipv4_tuple {
+   uint32_t src_addr;
+   uint32_t dst_addr;
+   union {
+   struct {
+   uint16_t sport;
+   uint16_t dport;
+   };
+   uint32_t sctp_tag;
+   };
+} thash_ipv4_tuple_t;
+
+typedef struct thash_ipv6_tuple {
+   uint8_t src_addr[16];
+   uint8_t dst_addr[16];
+   union {
+   struct {
+   uint16_t sport;
+   uint16_t dport;
+   };
+   uint32_t sctp_tag;
+   };
+} thash_ipv6_tuple_t;
+
+#define ODP_THASH_V4_L4_LEN (sizeof(thash_ipv4_tuple_t) / 4)
+
+#define ODP_THASH_V4_L3_LEN ((sizeof(thash_ipv4_tuple_t) - \
+   sizeof(((thash_ipv4_tuple_t *)0)->sctp_tag)) / 4)
+
+#define ODP_THASH_V6_L4_LEN (sizeof(thash_ipv6_tuple_t) / 4)
+
+#define ODP_THASH_V6_L3_LEN ((sizeof(thash_ipv6_tuple_t) - \
+   sizeof(((thash_ipv6_tuple_t *)0)->sctp_tag)) / 4)
+
+typedef union {
+   thash_ipv4_tuple_t v4;
+   thash_ipv6_tuple_t v6;
+} thash_tuple_t;
+
+static inline
+void thash_load_ipv6_addr(const _odp_ipv6hdr_t *ipv6,
+ thash_tuple_t *tuple)
+{
+   int i;
+
+   for (i = 0; i < 4; i++) {
+   *((uint32_t *)tuple->v6.src_addr + i) =
+   odp_be_to_cpu_32(*((const uint32_t *)ipv6->src_addr.u32 + i));
+
+   *((uint32_t *)tuple->v6.dst_addr + i) =
+   odp_be_to_cpu_32(*((const uint32_t *)ipv6->dst_addr.u32 + i));
+   }
+}
+
+static inline
+uint32_t thash_softrss(uint32_t *tuple, uint8_t len,
+  const uint8_t *key)
+{
+   uint32_t i, j, ret;
+
+   ret = 0;
+   for (j = 0; j < len; j++) {
+   for (i = 0; i < 32; i++) {
+   if (tuple[j] & (1 << (31 - i))) {
+   ret ^= odp_cpu_to_be_32(((const uint32_t *)
+   key)[j]) << i | (uint32_t)((uint64_t)
+   (odp_cpu_to_be_32(((const uint32_t *)key)
+   [j + 1])) >> (32 - i));
+   }
+   }
+   }
+
+   return ret;
+}
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
-- 
1.9.1



[lng-odp] [API-NEXTv4 1/3] api: classification: add support for packet hashing in classification

2017-07-24 Thread Balasubramanian Manoharan
Enable packet hashing per CoS to be able to distribute incoming packets to
multiple queues linked with a CoS.

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
v4: incorporates review comments from Petri

 include/odp/api/spec/classification.h | 83 ---
 1 file changed, 78 insertions(+), 5 deletions(-)

diff --git a/include/odp/api/spec/classification.h 
b/include/odp/api/spec/classification.h
index 39831b2..315afaa 100644
--- a/include/odp/api/spec/classification.h
+++ b/include/odp/api/spec/classification.h
@@ -4,7 +4,6 @@
  * SPDX-License-Identifier: BSD-3-Clause
  */
 
-
 /**
  * @file
  *
@@ -19,12 +18,13 @@
 extern "C" {
 #endif
 
+#include 
+#include 
 /** @defgroup odp_classification ODP CLASSIFICATION
  *  Classification operations.
  *  @{
  */
 
-
 /**
  * @typedef odp_cos_t
  * ODP Class of service handle
@@ -126,6 +126,13 @@ typedef struct odp_cls_capability_t {
/** Maximum number of CoS supported */
unsigned max_cos;
 
+   /** Maximun number of queue supported per CoS
+* if the value is 1, then hashing is not supported*/
+   unsigned max_hash_queues;
+
+   /** Protocol header combination supported for Hashing */
+   odp_pktin_hash_proto_t hash_protocols;
+
/** A Boolean to denote support of PMR range */
odp_bool_t pmr_range_supported;
 } odp_cls_capability_t;
@@ -164,9 +171,33 @@ typedef enum {
  * Used to communicate class of service creation options
  */
 typedef struct odp_cls_cos_param {
-   odp_queue_t queue;  /**< Queue associated with CoS */
-   odp_pool_t pool;/**< Pool associated with CoS */
-   odp_cls_drop_t drop_policy; /**< Drop policy associated with CoS */
+   /* Number of queues to be linked to this CoS.
+* If the number is greater than 1 then hashing has to be
+* configured. If number is equal to 1 then hashing is disabled
+* and queue has to be configured by the application.
+* When hashing is enabled the queues are created by the implementation
+* then application need not configure any queue to the class of service
+* Depening on the implementation this number might be rounded-off to
+* nearest supported value (e.g power of 2)
+* */
+   uint32_t num_queue;
+
+   /** Queue parameters */
+   odp_queue_param_t queue_param;
+
+   /* Protocol header fields which are included in packet input
+* hash calculation */
+   odp_pktin_hash_proto_t hash_proto;
+
+   /* If hashing is disabled, then application has to configure
+* this queue and packets are delivered to this queue */
+   odp_queue_t queue;
+
+   /* Pool associated with CoS */
+   odp_pool_t pool;
+
+   /* Drop policy associated with CoS */
+   odp_cls_drop_t drop_policy;
 } odp_cls_cos_param_t;
 
 /**
@@ -209,6 +240,23 @@ int odp_cls_capability(odp_cls_capability_t *capability);
 odp_cos_t odp_cls_cos_create(const char *name, odp_cls_cos_param_t *param);
 
 /**
+ * Queue hash result
+ * Returns the queue within a CoS in which a particular packet will be enqueued
+ * based on the packet parameters and hash protocol field configured with the
+ * class of service.
+ *
+ * @param  cos class of service
+ * @param  packet  Packet handle
+ *
+ * @retval Returns the queue handle on which this packet will be
+ * enqueued.
+ * @retval ODP_QUEUE_INVALID for error case
+ *
+ * @note The packet has to be updated with valid header pointers L2, L3 and L4.
+ */
+odp_queue_t odp_queue_hash_result(odp_cos_t cos, odp_packet_t packet);
+
+/**
  * Discard a class-of-service along with all its associated resources
  *
  * @param[in]  cos_id  class-of-service instance.
@@ -245,6 +293,31 @@ int odp_cos_queue_set(odp_cos_t cos_id, odp_queue_t 
queue_id);
 odp_queue_t odp_cos_queue(odp_cos_t cos_id);
 
 /**
+ * Get the number of queues linked with the specific class-of-service
+ *
+ * @param  cos_id  class-of-service instance.
+ *
+ * @return Number of queues linked with the 
class-of-service.
+ */
+uint32_t odp_cos_num_queue(odp_cos_t cos_id);
+
+/**
+ * Get the list of queue associated with the specific class-of-service
+ *
+ * @param[in]  cos_id  class-of-service instance.
+ *
+ * @param[out] queue   Array of queue handles associated
+ * with the class-of-service.
+ *
+ * @param[in]  num Maximum number of queue handles to output.
+ *
+ * @return Number of queues linked with CoS
+ * @retval <0  on failure
+ */
+uint32_t odp_cos_queue_multi(odp_cos_t cos_id, odp_queue_t queue[],
+uint32_t num);
+
+/**
  * Assign packet drop policy for specific class-of-service
  *
  * @param[in]  cos_id  class-of-service instance.
-- 
1.9.1



[lng-odp] [RFC/API-NEXTv3 3/3] linux-generic: classification implement packet hashing

2017-07-14 Thread Balasubramanian Manoharan
Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 .../include/odp_classification_datamodel.h |   20 ++-
 .../include/odp_classification_internal.h  |4 +
 platform/linux-generic/odp_classification.c|  182 
 3 files changed, 176 insertions(+), 30 deletions(-)

diff --git a/platform/linux-generic/include/odp_classification_datamodel.h 
b/platform/linux-generic/include/odp_classification_datamodel.h
index fbe10cb..279a198 100644
--- a/platform/linux-generic/include/odp_classification_datamodel.h
+++ b/platform/linux-generic/include/odp_classification_datamodel.h
@@ -46,6 +46,10 @@ extern "C" {
 /* Max PMR Term bits */
 #define ODP_PMR_TERM_BYTES_MAX 16
 
+#define ODP_COS_QUEUE_MAX  32
+
+#define ODP_CLS_QUEUE_GROUP_MAX(ODP_COS_MAX_ENTRY * 
ODP_COS_QUEUE_MAX)
+
 /**
 Packet Matching Rule Term Value
 
@@ -85,7 +89,7 @@ typedef struct pmr_term_value {
 Class Of Service
 */
 struct cos_s {
-   queue_t queue;  /* Associated Queue */
+   odp_queue_t queue;  /* Associated Queue */
odp_pool_t pool;/* Associated Buffer pool */
union pmr_u *pmr[ODP_PMR_PER_COS_MAX];  /* Chained PMR */
union cos_u *linked_cos[ODP_PMR_PER_COS_MAX]; /* Chained CoS with PMR*/
@@ -94,7 +98,12 @@ struct cos_s {
size_t headroom;/* Headroom for this CoS */
odp_spinlock_t lock;/* cos lock */
odp_atomic_u32_t num_rule;  /* num of PMRs attached with this CoS */
+   bool queue_group;
+   odp_hash_proto_t hash_proto;
+   uint32_t num_queue;
+   odp_queue_param_t queue_param;
char name[ODP_COS_NAME_LEN];/* name */
+   uint8_t index;
 };
 
 typedef union cos_u {
@@ -122,6 +131,15 @@ typedef union pmr_u {
uint8_t pad[ROUNDUP_CACHE_LINE(sizeof(struct pmr_s))];
 } pmr_t;
 
+typedef struct _cls_queue_grp_tbl_s {
+   odp_queue_t queue[ODP_CLS_QUEUE_GROUP_MAX];
+} _cls_queue_grp_tbl_s;
+
+typedef union _cls_queue_grp_tbl_t {
+   _cls_queue_grp_tbl_s s;
+   uint8_t pad[ROUNDUP_CACHE_LINE(sizeof(_cls_queue_grp_tbl_s))];
+} _cls_queue_grp_tbl_t;
+
 /**
 L2 QoS and CoS Map
 
diff --git a/platform/linux-generic/include/odp_classification_internal.h 
b/platform/linux-generic/include/odp_classification_internal.h
index 78eaac9..f2ac608 100644
--- a/platform/linux-generic/include/odp_classification_internal.h
+++ b/platform/linux-generic/include/odp_classification_internal.h
@@ -138,6 +138,10 @@ Otherwise.
 **/
 int verify_pmr(pmr_t *pmr, const uint8_t *pkt_addr, odp_packet_hdr_t *pkt_hdr);
 
+uint32_t packet_rss_hash(odp_packet_hdr_t *pkt_hdr,
+odp_hash_proto_t hash_proto,
+const uint8_t *base);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/platform/linux-generic/odp_classification.c 
b/platform/linux-generic/odp_classification.c
index cc08b9f..1966c51 100644
--- a/platform/linux-generic/odp_classification.c
+++ b/platform/linux-generic/odp_classification.c
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -30,6 +31,16 @@
 
 static cos_tbl_t *cos_tbl;
 static pmr_tbl_t   *pmr_tbl;
+static _cls_queue_grp_tbl_t *queue_grp_tbl;
+
+const uint8_t default_rss[] = {
+   0x6d, 0x5a, 0x56, 0xda, 0x25, 0x5b, 0x0e, 0xc2,
+   0x41, 0x67, 0x25, 0x3d, 0x43, 0xa3, 0x8f, 0xb0,
+   0xd0, 0xca, 0x2b, 0xcb, 0xae, 0x7b, 0x30, 0xb4,
+   0x77, 0xcb, 0x2d, 0xa3, 0x80, 0x30, 0xf2, 0x0c,
+   0x6a, 0x42, 0xb7, 0x3b, 0xbe, 0xac, 0x01, 0xfa,
+};
+
 
 cos_t *get_cos_entry_internal(odp_cos_t cos_id)
 {
@@ -45,6 +56,7 @@ int odp_classification_init_global(void)
 {
odp_shm_t cos_shm;
odp_shm_t pmr_shm;
+   odp_shm_t queue_grp_shm;
int i;
 
cos_shm = odp_shm_reserve("shm_odp_cos_tbl",
@@ -89,8 +101,22 @@ int odp_classification_init_global(void)
LOCK_INIT(>s.lock);
}
 
+   queue_grp_shm = odp_shm_reserve("shm_odp_cls_queue_grp_tbl",
+   sizeof(_cls_queue_grp_tbl_t),
+   sizeof(queue_entry_t *), 0);
+
+   if (queue_grp_shm == ODP_SHM_INVALID) {
+   ODP_ERR("shm allocation failed for queue_grp_tbl");
+   goto error_queue_grp;
+   }
+
+   queue_grp_tbl = odp_shm_addr(queue_grp_shm);
+   memset(queue_grp_tbl, 0, sizeof(_cls_queue_grp_tbl_t));
+
return 0;
 
+error_queue_grp:
+   odp_shm_free(queue_grp_shm);
 error_pmr:
odp_shm_free(pmr_shm);
 error_cos:
@@ -124,6 +150,11 @@ void odp_cls_cos_param_init(odp_cls_cos_param_t *param)
param->queue = ODP_QUEUE_INVALID;
param->pool = ODP_POOL_INVALID;
param->drop_policy = ODP_COS_DROP_NEVER;
+   param->num_queue = 1;
+   param->deq_mode = ODP_QUEUE

[lng-odp] [RFC/API-NEXTv3 2/3] linux-generic: add toeplitz hash algorithm

2017-07-14 Thread Balasubramanian Manoharan
Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 platform/linux-generic/include/protocols/thash.h |  108 ++
 1 file changed, 108 insertions(+)
 create mode 100644 platform/linux-generic/include/protocols/thash.h

diff --git a/platform/linux-generic/include/protocols/thash.h 
b/platform/linux-generic/include/protocols/thash.h
new file mode 100644
index 000..fe141e3
--- /dev/null
+++ b/platform/linux-generic/include/protocols/thash.h
@@ -0,0 +1,108 @@
+/* Copyright (c) 2017, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+/**
+ * @file
+ *
+ * ODP Toeplitz hash function
+ */
+
+#ifndef ODPH_THASH_H_
+#define ODPH_THASH_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include 
+
+/** IPv4 tuple
+ *
+ */
+typedef struct thash_ipv4_tuple {
+   uint32_t src_addr;
+   uint32_t dst_addr;
+   union {
+   struct {
+   uint16_t sport;
+   uint16_t dport;
+   };
+   uint32_t sctp_tag;
+   };
+} thash_ipv4_tuple_t;
+
+typedef struct thash_ipv6_tuple {
+   uint8_t src_addr[16];
+   uint8_t dst_addr[16];
+   union {
+   struct {
+   uint16_t sport;
+   uint16_t dport;
+   };
+   uint32_t sctp_tag;
+   };
+} thash_ipv6_tuple_t;
+
+#define ODP_THASH_V4_L4_LEN (sizeof(thash_ipv4_tuple_t) / 4)
+
+#define ODP_THASH_V4_L3_LEN ((sizeof(thash_ipv4_tuple_t) - \
+   sizeof(((thash_ipv4_tuple_t *)0)->sctp_tag)) / 4)
+
+#define ODP_THASH_V6_L4_LEN (sizeof(thash_ipv6_tuple_t) / 4)
+
+#define ODP_THASH_V6_L3_LEN ((sizeof(thash_ipv6_tuple_t) - \
+   sizeof(((thash_ipv6_tuple_t *)0)->sctp_tag)) / 4)
+
+typedef union {
+   thash_ipv4_tuple_t v4;
+   thash_ipv6_tuple_t v6;
+} thash_tuple_t;
+
+static inline
+void thash_load_ipv6_addr(const _odp_ipv6hdr_t *ipv6,
+ thash_tuple_t *tuple)
+{
+   int i;
+
+   for (i = 0; i < 4; i++) {
+   *((uint32_t *)tuple->v6.src_addr + i) =
+   odp_be_to_cpu_32(*((const uint32_t *)ipv6->src_addr.u32 + i));
+
+   *((uint32_t *)tuple->v6.dst_addr + i) =
+   odp_be_to_cpu_32(*((const uint32_t *)ipv6->dst_addr.u32 + i));
+   }
+}
+
+static inline
+uint32_t thash_softrss(uint32_t *tuple, uint8_t len,
+  const uint8_t *key)
+{
+   uint32_t i, j, ret;
+
+   ret = 0;
+   for (j = 0; j < len; j++) {
+   for (i = 0; i < 32; i++) {
+   if (tuple[j] & (1 << (31 - i))) {
+   ret ^= odp_cpu_to_be_32(((const uint32_t *)
+   key)[j]) << i | (uint32_t)((uint64_t)
+   (odp_cpu_to_be_32(((const uint32_t *)key)
+   [j + 1])) >> (32 - i));
+   }
+   }
+   }
+
+   return ret;
+}
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
-- 
1.7.9.5



[lng-odp] [RFC/API-NEXTv3 1/3] api: classification: add support for packet hashing in classification

2017-07-14 Thread Balasubramanian Manoharan
Enable packet hashing per CoS to be able to distribute incoming packets to
multiple queues linked with a CoS.

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 include/odp/api/spec/classification.h |   96 +++--
 include/odp/api/spec/packet_io.h  |   21 
 2 files changed, 112 insertions(+), 5 deletions(-)

diff --git a/include/odp/api/spec/classification.h 
b/include/odp/api/spec/classification.h
index 39831b2..d31965e 100644
--- a/include/odp/api/spec/classification.h
+++ b/include/odp/api/spec/classification.h
@@ -4,7 +4,6 @@
  * SPDX-License-Identifier: BSD-3-Clause
  */
 
-
 /**
  * @file
  *
@@ -19,12 +18,13 @@
 extern "C" {
 #endif
 
+#include 
+#include 
 /** @defgroup odp_classification ODP CLASSIFICATION
  *  Classification operations.
  *  @{
  */
 
-
 /**
  * @typedef odp_cos_t
  * ODP Class of service handle
@@ -126,6 +126,19 @@ typedef struct odp_cls_capability_t {
/** Maximum number of CoS supported */
unsigned max_cos;
 
+   /* support mode for plain queue */
+   odp_support_t plain_queue;
+
+   /* support mode for sched queue */
+   odp_support_t sched_queue;
+
+   /** Maximun number of queue supported per CoS
+* if the value is 1, then hashing is not supported*/
+   unsigned max_queue_supported;
+
+   /** Protocol header combination supported for Hashing */
+   odp_pktin_hash_proto_t hash_supported;
+
/** A Boolean to denote support of PMR range */
odp_bool_t pmr_range_supported;
 } odp_cls_capability_t;
@@ -164,9 +177,40 @@ typedef enum {
  * Used to communicate class of service creation options
  */
 typedef struct odp_cls_cos_param {
-   odp_queue_t queue;  /**< Queue associated with CoS */
-   odp_pool_t pool;/**< Pool associated with CoS */
-   odp_cls_drop_t drop_policy; /**< Drop policy associated with CoS */
+   /* Number of queues to be linked to this CoS.
+* If the number is greater than 1 then hashing has to be
+* configured. If number is equal to 1 then hashing is disabled
+* and queue has to be configured by the application.
+* When hashing is enabled the queues are created by the implementation
+* then application need not configure any queue to this CoS.
+* Depening on the implementation this number might be rounded-off to
+* nearest supported value (e.g power of 2)
+* */
+   uint32_t num_queue;
+
+   /** Queue type */
+   odp_queue_type_t queue_type;
+
+   /** ODP Queue dequeue mode
+*  This value is valid only for PLAIN queue types */
+   odp_queue_op_mode_t deq_mode;
+
+   /** Schedule parameters for the queue created */
+   odp_schedule_param_t sched_param;
+
+   /* Protocol header fields which are included in packet input
+* hash calculation */
+   odp_hash_proto_t hash_proto;
+
+   /* If hashing is disabled, then application has to configure
+* this queue and packets are delivered to this queue */
+   odp_queue_t queue;
+
+   /* Pool associated with CoS */
+   odp_pool_t pool;
+
+   /* Drop policy associated with CoS */
+   odp_cls_drop_t drop_policy;
 } odp_cls_cos_param_t;
 
 /**
@@ -209,6 +253,23 @@ int odp_cls_capability(odp_cls_capability_t *capability);
 odp_cos_t odp_cls_cos_create(const char *name, odp_cls_cos_param_t *param);
 
 /**
+ * Queue hash result
+ * Returns the queue within a CoS in which a particular packet will be enqueued
+ * based on the packet parameters and hash protocol field configured with the
+ * class of service.
+ *
+ * @param  cos class of service
+ * @param  packet  Packet handle
+ *
+ * @retval Returns the queue handle on which this packet will be
+ * enqueued.
+ * @retval ODP_QUEUE_INVALID for error case
+ *
+ * @note The packet has to be updated with valid header pointers L2, L3 and L4.
+ */
+odp_queue_t odp_queue_hash_result(odp_cos_t cos, odp_packet_t packet);
+
+/**
  * Discard a class-of-service along with all its associated resources
  *
  * @param[in]  cos_id  class-of-service instance.
@@ -245,6 +306,31 @@ int odp_cos_queue_set(odp_cos_t cos_id, odp_queue_t 
queue_id);
 odp_queue_t odp_cos_queue(odp_cos_t cos_id);
 
 /**
+ * Get the number of queues linked with the specific class-of-service
+ *
+ * @param  cos_id  class-of-service instance.
+ *
+ * @return Number of queues linked with the 
class-of-service.
+ */
+uint32_t odp_cos_num_queue(odp_cos_t cos_id);
+
+/**
+ * Get the list of queue associated with the specific class-of-service
+ *
+ * @param[in]  cos_id  class-of-service instance.
+ *
+ * @param[out] queue   Array of queue handles associated
+ * with the class-of-service.
+ *
+ * @param[in]  num Maximum number of queue handles t

[lng-odp] [RFC/API-NEXT] api: schedule: add ordered context unlock-lock

2017-06-16 Thread Balasubramanian Manoharan
Adds api to release an existing ordered lock and acquire a new lock.

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 include/odp/api/spec/schedule.h |   20 
 1 file changed, 20 insertions(+)

diff --git a/include/odp/api/spec/schedule.h b/include/odp/api/spec/schedule.h
index 8244746..c5d2214 100644
--- a/include/odp/api/spec/schedule.h
+++ b/include/odp/api/spec/schedule.h
@@ -368,6 +368,26 @@ void odp_schedule_order_lock(unsigned lock_index);
 void odp_schedule_order_unlock(unsigned lock_index);
 
 /**
+ * Release ordered context lock and acquires new lock
+ *
+ * This call is valid only when holding an ordered synchronization context.
+ * Release a previously locked ordered context lock and acquires
+ * a new ordered context lock.
+ * This call is valid only when there is a single ordered context lock and
+ * is invalid if there are nested ordered context lock.
+ *
+ * @param lock_index   Index of the ordered lock in the current context to be
+ * acquired. Previously acquired ordered lock is released.
+ * Results are undefined if there is a nested ordered lock
+ * in the context. Must be in the range
+ * 0...odp_queue_lock_count() - 1
+ *
+ * @see odp_schedule_order_lock(), odp_schedule_order_unlock()
+ *
+ */
+void odp_schedule_order_unlock_lock(uint32_t lock_index);
+
+/**
  * @}
  */
 
-- 
1.7.9.5



[lng-odp] [RFC] api: classification: add random early discard

2017-06-12 Thread Balasubramanian Manoharan
Add random early discard configuration to class-of-service

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 include/odp/api/spec/classification.h | 44 +++
 1 file changed, 44 insertions(+)

diff --git a/include/odp/api/spec/classification.h 
b/include/odp/api/spec/classification.h
index 39831b2..badadff 100644
--- a/include/odp/api/spec/classification.h
+++ b/include/odp/api/spec/classification.h
@@ -128,6 +128,13 @@ typedef struct odp_cls_capability_t {
 
/** A Boolean to denote support of PMR range */
odp_bool_t pmr_range_supported;
+
+   /** Support for Random Early Discard */
+   odp_support_t random_early_discard;
+
+   /** Support for Back Pressure to the remote peer */
+   odp_support_t back_pressure;
+
 } odp_cls_capability_t;
 
 /**
@@ -167,6 +174,43 @@ typedef struct odp_cls_cos_param {
odp_queue_t queue;  /**< Queue associated with CoS */
odp_pool_t pool;/**< Pool associated with CoS */
odp_cls_drop_t drop_policy; /**< Drop policy associated with CoS */
+
+   /* Random Early Discard (RED)
+* Random Early discard is enabled to initiate a drop probability
+* for the incoming packet when the packets in the queue/pool reaches
+* a specified threshold.
+* When RED is enabled for a particular flow then further incoming
+* packets are assigned a drop probability based on the size of the
+* pool/queue and the drop probability becomes 1 when the queue/pool
+* is full.
+* RED is logically configured in the CoS and could be implemented
+* in either pool or queue linked to the CoS depending on
+* platform capabilities.
+* RED is controlled using maximum and minimum threshold values
+* which are defined as percentage of the system resource.
+* RED is enabled when the resource limit is equal to or greater than
+* the maximum threshold value and is disabled when resource limit
+* is less than or equal to minimum threshold value. */
+
+   /* A boolean to enable RED parameters */
+   odp_bool_t red_enable;
+
+   /* Maximum threshold percentage for RED */
+   uint16_t max_red_threshold;
+
+   /* Minimum threshold percentage for RED */
+   uint16_t min_red_threshold;
+
+   /* Back pressure
+* When back pressure is enabled for a particular flow, the HW can send
+* back pressure information to the remote peer indicating a network
+* congestion */
+   odp_bool_t bp_enable;
+
+   /* Threshold for enabling back pressure. BP is enabled when pool/queue
+* size is equal to or greater than this backpressure threshold.
+* BP threshold is expressed as a percentage of the resource size. */
+   uint16_t bp_threshold;
 } odp_cls_cos_param_t;
 
 /**
-- 
1.9.1



[lng-odp] [PATCH 3/3] linux-generic: classification: implement packet hashing in classifier

2017-05-03 Thread Balasubramanian Manoharan
Implement packet hashing feature to distribute incoming packet to multiple
queues linked with CoS.

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 .../include/odp_classification_datamodel.h |  18 +++
 .../include/odp_classification_internal.h  |   4 +
 platform/linux-generic/odp_classification.c| 161 +++--
 3 files changed, 168 insertions(+), 15 deletions(-)

diff --git a/platform/linux-generic/include/odp_classification_datamodel.h 
b/platform/linux-generic/include/odp_classification_datamodel.h
index 9df756b..b44a547 100644
--- a/platform/linux-generic/include/odp_classification_datamodel.h
+++ b/platform/linux-generic/include/odp_classification_datamodel.h
@@ -46,6 +46,10 @@ extern "C" {
 /* Max PMR Term bits */
 #define ODP_PMR_TERM_BYTES_MAX 16
 
+#define ODP_COS_QUEUE_MAX  32
+
+#define ODP_CLS_QUEUE_GROUP_MAX(ODP_COS_MAX_ENTRY * 
ODP_COS_QUEUE_MAX)
+
 /**
 Packet Matching Rule Term Value
 
@@ -94,7 +98,12 @@ struct cos_s {
size_t headroom;/* Headroom for this CoS */
odp_spinlock_t lock;/* cos lock */
odp_atomic_u32_t num_rule;  /* num of PMRs attached with this CoS */
+   bool queue_group;
+   odp_hash_proto_t hash_proto;
+   uint32_t num_queue;
+   odp_queue_param_t queue_param;
char name[ODP_COS_NAME_LEN];/* name */
+   uint8_t index;
 };
 
 typedef union cos_u {
@@ -122,6 +131,15 @@ typedef union pmr_u {
uint8_t pad[ROUNDUP_CACHE_LINE(sizeof(struct pmr_s))];
 } pmr_t;
 
+typedef struct _cls_queue_grp_tbl_s {
+   odp_queue_t queue[ODP_CLS_QUEUE_GROUP_MAX];
+} _cls_queue_grp_tbl_s;
+
+typedef union _cls_queue_grp_tbl_t {
+   _cls_queue_grp_tbl_s s;
+   uint8_t pad[ROUNDUP_CACHE_LINE(sizeof(_cls_queue_grp_tbl_s))];
+} _cls_queue_grp_tbl_t;
+
 /**
 L2 QoS and CoS Map
 
diff --git a/platform/linux-generic/include/odp_classification_internal.h 
b/platform/linux-generic/include/odp_classification_internal.h
index 78eaac9..f2ac608 100644
--- a/platform/linux-generic/include/odp_classification_internal.h
+++ b/platform/linux-generic/include/odp_classification_internal.h
@@ -138,6 +138,10 @@ Otherwise.
 **/
 int verify_pmr(pmr_t *pmr, const uint8_t *pkt_addr, odp_packet_hdr_t *pkt_hdr);
 
+uint32_t packet_rss_hash(odp_packet_hdr_t *pkt_hdr,
+odp_hash_proto_t hash_proto,
+const uint8_t *base);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/platform/linux-generic/odp_classification.c 
b/platform/linux-generic/odp_classification.c
index 7ebc47d..9028482 100644
--- a/platform/linux-generic/odp_classification.c
+++ b/platform/linux-generic/odp_classification.c
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -30,6 +31,16 @@
 
 static cos_tbl_t *cos_tbl;
 static pmr_tbl_t   *pmr_tbl;
+static _cls_queue_grp_tbl_t *queue_grp_tbl;
+
+const uint8_t default_rss[] = {
+   0x6d, 0x5a, 0x56, 0xda, 0x25, 0x5b, 0x0e, 0xc2,
+   0x41, 0x67, 0x25, 0x3d, 0x43, 0xa3, 0x8f, 0xb0,
+   0xd0, 0xca, 0x2b, 0xcb, 0xae, 0x7b, 0x30, 0xb4,
+   0x77, 0xcb, 0x2d, 0xa3, 0x80, 0x30, 0xf2, 0x0c,
+   0x6a, 0x42, 0xb7, 0x3b, 0xbe, 0xac, 0x01, 0xfa,
+};
+
 
 cos_t *get_cos_entry_internal(odp_cos_t cos_id)
 {
@@ -45,6 +56,7 @@ int odp_classification_init_global(void)
 {
odp_shm_t cos_shm;
odp_shm_t pmr_shm;
+   odp_shm_t queue_grp_shm;
int i;
 
cos_shm = odp_shm_reserve("shm_odp_cos_tbl",
@@ -89,8 +101,22 @@ int odp_classification_init_global(void)
LOCK_INIT(>s.lock);
}
 
+   queue_grp_shm = odp_shm_reserve("shm_odp_cls_queue_grp_tbl",
+   sizeof(_cls_queue_grp_tbl_t),
+   sizeof(queue_entry_t *), 0);
+
+   if (queue_grp_shm == ODP_SHM_INVALID) {
+   ODP_ERR("shm allocation failed for queue_grp_tbl");
+   goto error_queue_grp;
+   }
+
+   queue_grp_tbl = odp_shm_addr(queue_grp_shm);
+   memset(queue_grp_tbl, 0, sizeof(_cls_queue_grp_tbl_t));
+
return 0;
 
+error_queue_grp:
+   odp_shm_free(queue_grp_shm);
 error_pmr:
odp_shm_free(pmr_shm);
 error_cos:
@@ -124,6 +150,11 @@ void odp_cls_cos_param_init(odp_cls_cos_param_t *param)
param->queue = ODP_QUEUE_INVALID;
param->pool = ODP_POOL_INVALID;
param->drop_policy = ODP_COS_DROP_NEVER;
+   param->num_queue = 1;
+   param->deq_mode = ODP_QUEUE_OP_MT;
+   param->sched_param.prio = ODP_SCHED_PRIO_DEFAULT;
+   param->sched_param.sync = ODP_SCHED_SYNC_PARALLEL;
+   param->sched_param.group = ODP_SCHED_GROUP_ALL;
 }
 
 void odp_cls_pmr_param_init(odp_pmr_param_t *param)
@@ -159,19 +190,23 @@ odp_cos_t odp_cls_cos_create(const char *name, 
odp_cls_cos_param_t *para

[lng-odp] [PATCH 2/3] linux-generic: add Toeplitz hash algorithm

2017-05-03 Thread Balasubramanian Manoharan
Implements Toeplitz hash algorithm for packet hashing

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 platform/linux-generic/include/protocols/thash.h | 108 +++
 1 file changed, 108 insertions(+)
 create mode 100644 platform/linux-generic/include/protocols/thash.h

diff --git a/platform/linux-generic/include/protocols/thash.h 
b/platform/linux-generic/include/protocols/thash.h
new file mode 100644
index 000..fe141e3
--- /dev/null
+++ b/platform/linux-generic/include/protocols/thash.h
@@ -0,0 +1,108 @@
+/* Copyright (c) 2017, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+/**
+ * @file
+ *
+ * ODP Toeplitz hash function
+ */
+
+#ifndef ODPH_THASH_H_
+#define ODPH_THASH_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include 
+
+/** IPv4 tuple
+ *
+ */
+typedef struct thash_ipv4_tuple {
+   uint32_t src_addr;
+   uint32_t dst_addr;
+   union {
+   struct {
+   uint16_t sport;
+   uint16_t dport;
+   };
+   uint32_t sctp_tag;
+   };
+} thash_ipv4_tuple_t;
+
+typedef struct thash_ipv6_tuple {
+   uint8_t src_addr[16];
+   uint8_t dst_addr[16];
+   union {
+   struct {
+   uint16_t sport;
+   uint16_t dport;
+   };
+   uint32_t sctp_tag;
+   };
+} thash_ipv6_tuple_t;
+
+#define ODP_THASH_V4_L4_LEN (sizeof(thash_ipv4_tuple_t) / 4)
+
+#define ODP_THASH_V4_L3_LEN ((sizeof(thash_ipv4_tuple_t) - \
+   sizeof(((thash_ipv4_tuple_t *)0)->sctp_tag)) / 4)
+
+#define ODP_THASH_V6_L4_LEN (sizeof(thash_ipv6_tuple_t) / 4)
+
+#define ODP_THASH_V6_L3_LEN ((sizeof(thash_ipv6_tuple_t) - \
+   sizeof(((thash_ipv6_tuple_t *)0)->sctp_tag)) / 4)
+
+typedef union {
+   thash_ipv4_tuple_t v4;
+   thash_ipv6_tuple_t v6;
+} thash_tuple_t;
+
+static inline
+void thash_load_ipv6_addr(const _odp_ipv6hdr_t *ipv6,
+ thash_tuple_t *tuple)
+{
+   int i;
+
+   for (i = 0; i < 4; i++) {
+   *((uint32_t *)tuple->v6.src_addr + i) =
+   odp_be_to_cpu_32(*((const uint32_t *)ipv6->src_addr.u32 + i));
+
+   *((uint32_t *)tuple->v6.dst_addr + i) =
+   odp_be_to_cpu_32(*((const uint32_t *)ipv6->dst_addr.u32 + i));
+   }
+}
+
+static inline
+uint32_t thash_softrss(uint32_t *tuple, uint8_t len,
+  const uint8_t *key)
+{
+   uint32_t i, j, ret;
+
+   ret = 0;
+   for (j = 0; j < len; j++) {
+   for (i = 0; i < 32; i++) {
+   if (tuple[j] & (1 << (31 - i))) {
+   ret ^= odp_cpu_to_be_32(((const uint32_t *)
+   key)[j]) << i | (uint32_t)((uint64_t)
+   (odp_cpu_to_be_32(((const uint32_t *)key)
+   [j + 1])) >> (32 - i));
+   }
+   }
+   }
+
+   return ret;
+}
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
-- 
1.9.1



[lng-odp] [PATCH 1/3] api: classification: add support for packet hashing in classification

2017-05-03 Thread Balasubramanian Manoharan
Enable packet hashing per CoS to be able to distribute incoming packets to
multiple queues linked with a CoS.

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 include/odp/api/spec/classification.h | 71 ---
 include/odp/api/spec/packet_io.h  | 21 +++
 2 files changed, 87 insertions(+), 5 deletions(-)

diff --git a/include/odp/api/spec/classification.h 
b/include/odp/api/spec/classification.h
index 39831b2..b4b943a 100644
--- a/include/odp/api/spec/classification.h
+++ b/include/odp/api/spec/classification.h
@@ -4,7 +4,6 @@
  * SPDX-License-Identifier: BSD-3-Clause
  */
 
-
 /**
  * @file
  *
@@ -19,12 +18,13 @@
 extern "C" {
 #endif
 
+#include 
+#include 
 /** @defgroup odp_classification ODP CLASSIFICATION
  *  Classification operations.
  *  @{
  */
 
-
 /**
  * @typedef odp_cos_t
  * ODP Class of service handle
@@ -126,6 +126,19 @@ typedef struct odp_cls_capability_t {
/** Maximum number of CoS supported */
unsigned max_cos;
 
+   /* support mode for plain queue */
+   odp_support_t plain_queue;
+
+   /* support mode for sched queue */
+   odp_support_t sched_queue;
+
+   /** Maximun number of queue supported per CoS
+* if the value is 1, then hashing is not supported*/
+   unsigned max_queue_supported;
+
+   /** Protocol header combination supported for Hashing */
+   odp_pktin_hash_proto_t hash_supported;
+
/** A Boolean to denote support of PMR range */
odp_bool_t pmr_range_supported;
 } odp_cls_capability_t;
@@ -164,9 +177,40 @@ typedef enum {
  * Used to communicate class of service creation options
  */
 typedef struct odp_cls_cos_param {
-   odp_queue_t queue;  /**< Queue associated with CoS */
-   odp_pool_t pool;/**< Pool associated with CoS */
-   odp_cls_drop_t drop_policy; /**< Drop policy associated with CoS */
+   /* Number of queues to be linked to this CoS.
+* If the number is greater than 1 then hashing has to be
+* configured. If number is equal to 1 then hashing is disabled
+* and queue has to be configured by the application.
+* When hashing is enabled the queues are created by the implementation
+* and application need not configure any queue to the class of service
+* Depening on the implementation this number might be rounded-off to
+* nearest supported value (e.g power of 2)
+* */
+   uint32_t num_queue;
+
+   /** Queue type */
+   odp_queue_type_t queue_type;
+
+   /** ODP Queue dequeue mode
+*  This value is valid only for PLAIN queue types */
+   odp_queue_op_mode_t deq_mode;
+
+   /** Schedule parameters for the queue created */
+   odp_schedule_param_t sched_param;
+
+   /* Protocol header fields which are included in packet input
+* hash calculation */
+   odp_hash_proto_t hash_proto;
+
+   /* If hashing is disabled, then application has to configure
+* this queue and packets are delivered to this queue */
+   odp_queue_t queue;
+
+   /* Pool associated with CoS */
+   odp_pool_t pool;
+
+   /* Drop policy associated with CoS */
+   odp_cls_drop_t drop_policy;
 } odp_cls_cos_param_t;
 
 /**
@@ -209,6 +253,23 @@ int odp_cls_capability(odp_cls_capability_t *capability);
 odp_cos_t odp_cls_cos_create(const char *name, odp_cls_cos_param_t *param);
 
 /**
+ * Queue hash result
+ * Returns the queue within a CoS in which a particular packet will be enqueued
+ * based on the packet parameters and hash protocol field configured with the
+ * class of service.
+ *
+ * @param  cos class of service
+ * @param  packet  Packet handle
+ *
+ * @retval Returns the queue handle on which this packet will be
+ * enqueued.
+ * @retval ODP_QUEUE_INVALID for error case
+ *
+ * @note The packet has to be updated with valid header pointers L2, L3 and L4.
+ */
+odp_queue_t odp_queue_hash_result(odp_cos_t cos, odp_packet_t packet);
+
+/**
  * Discard a class-of-service along with all its associated resources
  *
  * @param[in]  cos_id  class-of-service instance.
diff --git a/include/odp/api/spec/packet_io.h b/include/odp/api/spec/packet_io.h
index 8802089..1a40a1f 100644
--- a/include/odp/api/spec/packet_io.h
+++ b/include/odp/api/spec/packet_io.h
@@ -131,6 +131,27 @@ typedef union odp_pktin_hash_proto_t {
 } odp_pktin_hash_proto_t;
 
 /**
+ * Packet hash protocols
+ *
+ * The list of protocol header field combination in enum format, which are
+ * included in packet hash calculation.
+ */
+typedef enum odp_hash_proto_t {
+   /** IPv4 address and UDP port numbers */
+   ODP_HASH_PROTO_IPV4_UDP,
+   /** IPv4 addresses and TCP port numbers */
+   ODP_HASH_PROTO_IPV4_TCP,
+   /** IPv4 addresses */
+   ODP_HASH_PROTO_IPV4,
+   /** IPv6 addresses and UDP port numbers */
+ 

[lng-odp] [PATCHv1 1/2] linux-generic: classification: implement eth type packet matching rule

2017-02-17 Thread Balasubramanian Manoharan
Adds implementation for outer and inner ethernet type packet matching rule

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 .../include/odp_classification_inlines.h   | 40 +-
 1 file changed, 32 insertions(+), 8 deletions(-)

diff --git a/platform/linux-generic/include/odp_classification_inlines.h 
b/platform/linux-generic/include/odp_classification_inlines.h
index c9517d6..2747db8 100644
--- a/platform/linux-generic/include/odp_classification_inlines.h
+++ b/platform/linux-generic/include/odp_classification_inlines.h
@@ -332,19 +332,43 @@ static inline int verify_pmr_custom_frame(const uint8_t 
*pkt_addr,
return 0;
 }
 
-static inline int verify_pmr_eth_type_0(const uint8_t *pkt_addr ODP_UNUSED,
-   odp_packet_hdr_t *pkt_hdr ODP_UNUSED,
-   pmr_term_value_t *term_value ODP_UNUSED)
+static inline int verify_pmr_eth_type_0(const uint8_t *pkt_addr,
+   odp_packet_hdr_t *pkt_hdr,
+   pmr_term_value_t *term_value)
 {
-   ODP_UNIMPLEMENTED();
+   const _odp_ethhdr_t *eth;
+   uint16_t ethtype;
+
+   if (!pkt_hdr->p.input_flags.vlan_qinq)
+   return 0;
+
+   eth = (const _odp_ethhdr_t *)(pkt_addr + pkt_hdr->p.l2_offset);
+   ethtype = odp_be_to_cpu_16(eth->type);
+
+   if (term_value->match.value == (ethtype & term_value->match.mask))
+   return 1;
+
return 0;
 }
 
-static inline int verify_pmr_eth_type_x(const uint8_t *pkt_addr ODP_UNUSED,
-   odp_packet_hdr_t *pkt_hdr ODP_UNUSED,
-   pmr_term_value_t *term_value ODP_UNUSED)
+static inline int verify_pmr_eth_type_x(const uint8_t *pkt_addr,
+   odp_packet_hdr_t *pkt_hdr,
+   pmr_term_value_t *term_value)
 {
-   ODP_UNIMPLEMENTED();
+   const _odp_ethhdr_t *eth;
+   uint16_t ethtype;
+   const _odp_vlanhdr_t *vlan;
+
+   if (!pkt_hdr->p.input_flags.vlan_qinq)
+   return 0;
+
+   eth = (const _odp_ethhdr_t *)(pkt_addr + pkt_hdr->p.l2_offset);
+   vlan = (const _odp_vlanhdr_t *)(eth + 1);
+   ethtype = odp_be_to_cpu_16(vlan->type);
+
+   if (term_value->match.value == (ethtype & term_value->match.mask))
+   return 1;
+
return 0;
 }
 #ifdef __cplusplus
-- 
1.9.1



[lng-odp] [PATCHv1 2/2] validation: classification: add test case for outer and inner vlan id

2017-02-09 Thread Balasubramanian Manoharan
Adds test case for outer and inner vlan id packet matching rule

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 .../validation/api/classification/classification.h |   2 +
 .../api/classification/odp_classification_common.c |  17 +-
 .../classification/odp_classification_test_pmr.c   | 229 +
 .../classification/odp_classification_testsuites.h |   4 +-
 4 files changed, 246 insertions(+), 6 deletions(-)

diff --git a/test/common_plat/validation/api/classification/classification.h 
b/test/common_plat/validation/api/classification/classification.h
index 0192e24..66e3208 100644
--- a/test/common_plat/validation/api/classification/classification.h
+++ b/test/common_plat/validation/api/classification/classification.h
@@ -98,6 +98,8 @@ void classification_test_pmr_term_udp_sport(void);
 void classification_test_pmr_term_ipproto(void);
 void classification_test_pmr_term_dmac(void);
 void classification_test_pmr_term_packet_len(void);
+void classification_test_pmr_term_vlan_id_0(void);
+void classification_test_pmr_term_vlan_id_x(void);
 
 /* test arrays: */
 extern odp_testinfo_t classification_suite_basic[];
diff --git 
a/test/common_plat/validation/api/classification/odp_classification_common.c 
b/test/common_plat/validation/api/classification/odp_classification_common.c
index 0ca9083..3b379c1 100644
--- a/test/common_plat/validation/api/classification/odp_classification_common.c
+++ b/test/common_plat/validation/api/classification/odp_classification_common.c
@@ -245,6 +245,8 @@ odp_packet_t create_packet(cls_packet_info_t pkt_info)
uint16_t l3_hdr_len = 0;
uint16_t l4_hdr_len = 0;
uint16_t eth_type;
+   odp_u16be_t *vlan_type;
+   odph_vlanhdr_t *vlan_hdr;
 
/* 48 bit ethernet address needs to be left shifted for proper
value after changing to be*/
@@ -256,6 +258,7 @@ odp_packet_t create_packet(cls_packet_info_t pkt_info)
seqno = odp_atomic_fetch_inc_u32(pkt_info.seq);
 
vlan_hdr_len = pkt_info.vlan ? ODPH_VLANHDR_LEN : 0;
+   vlan_hdr_len = pkt_info.vlan_qinq ? 2 * vlan_hdr_len : vlan_hdr_len;
l3_hdr_len = pkt_info.ipv6 ? ODPH_IPV6HDR_LEN : ODPH_IPV4HDR_LEN;
l4_hdr_len = pkt_info.udp ? ODPH_UDPHDR_LEN : ODPH_TCPHDR_LEN;
eth_type = pkt_info.ipv6 ? ODPH_ETHTYPE_IPV6 : ODPH_ETHTYPE_IPV4;
@@ -275,12 +278,20 @@ odp_packet_t create_packet(cls_packet_info_t pkt_info)
ethhdr = (odph_ethhdr_t *)odp_packet_l2_ptr(pkt, NULL);
memcpy(ethhdr->src.addr, _mac, ODPH_ETHADDR_LEN);
memcpy(ethhdr->dst.addr, _mac_be, ODPH_ETHADDR_LEN);
+   vlan_type = (odp_u16be_t *)>type;
+   vlan_hdr = (odph_vlanhdr_t *)(ethhdr + 1);
+
+   if (pkt_info.vlan_qinq) {
+   odp_packet_has_vlan_qinq_set(pkt, 1);
+   *vlan_type = odp_cpu_to_be_16(ODPH_ETHTYPE_VLAN_OUTER);
+   vlan_hdr->tci = odp_cpu_to_be_16(0);
+   vlan_type = (uint16_t *)_hdr->type;
+   vlan_hdr++;
+   }
if (pkt_info.vlan) {
/* Default vlan header */
-   odph_vlanhdr_t *vlan_hdr;
odp_packet_has_vlan_set(pkt, 1);
-   ethhdr->type = odp_cpu_to_be_16(ODPH_ETHTYPE_VLAN);
-   vlan_hdr = (odph_vlanhdr_t *)(ethhdr + 1);
+   *vlan_type = odp_cpu_to_be_16(ODPH_ETHTYPE_VLAN);
vlan_hdr->tci = odp_cpu_to_be_16(0);
vlan_hdr->type = odp_cpu_to_be_16(eth_type);
} else {
diff --git 
a/test/common_plat/validation/api/classification/odp_classification_test_pmr.c 
b/test/common_plat/validation/api/classification/odp_classification_test_pmr.c
index c714549..d01f716 100644
--- 
a/test/common_plat/validation/api/classification/odp_classification_test_pmr.c
+++ 
b/test/common_plat/validation/api/classification/odp_classification_test_pmr.c
@@ -870,6 +870,233 @@ void classification_test_pmr_term_packet_len(void)
odp_pktio_close(pktio);
 }
 
+void classification_test_pmr_term_vlan_id_0(void)
+{
+   odp_packet_t pkt;
+   uint32_t seqno;
+   uint16_t val;
+   uint16_t mask;
+   int retval;
+   odp_pktio_t pktio;
+   odp_queue_t queue;
+   odp_queue_t retqueue;
+   odp_queue_t default_queue;
+   odp_cos_t default_cos;
+   odp_pool_t default_pool;
+   odp_pool_t pool;
+   odp_pool_t recvpool;
+   odp_pmr_t pmr;
+   odp_cos_t cos;
+   char cosname[ODP_COS_NAME_LEN];
+   odp_cls_cos_param_t cls_param;
+   odp_pmr_param_t pmr_param;
+   odph_ethhdr_t *eth;
+   odph_vlanhdr_t *vlan_0;
+   cls_packet_info_t pkt_info;
+
+   val = 1024;
+   mask = 0xff00;
+   seqno = 0;
+
+   pktio = create_pktio(ODP_QUEUE_TYPE_SCHED, pkt_pool);
+   CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID);
+   retval = start_pktio(pktio);
+   CU_ASSERT(retval == 0);
+
+   configure_default_cos(pktio, _cos,
+

[lng-odp] [PATCHv1 1/2] linux-generic: classification: implement vlan id packet matching rule

2017-02-09 Thread Balasubramanian Manoharan
Add implementation for outer and inner vlan ID packet matching rule

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 .../include/odp_classification_inlines.h   | 41 +++---
 1 file changed, 36 insertions(+), 5 deletions(-)

diff --git a/platform/linux-generic/include/odp_classification_inlines.h 
b/platform/linux-generic/include/odp_classification_inlines.h
index e6f9be9..c9517d6 100644
--- a/platform/linux-generic/include/odp_classification_inlines.h
+++ b/platform/linux-generic/include/odp_classification_inlines.h
@@ -231,11 +231,26 @@ static inline int verify_pmr_ipv6_daddr(const uint8_t 
*pkt_addr,
return 0;
 }
 
-static inline int verify_pmr_vlan_id_0(const uint8_t *pkt_addr ODP_UNUSED,
-  odp_packet_hdr_t *pkt_hdr ODP_UNUSED,
-  pmr_term_value_t *term_value ODP_UNUSED)
+static inline int verify_pmr_vlan_id_0(const uint8_t *pkt_addr,
+  odp_packet_hdr_t *pkt_hdr,
+  pmr_term_value_t *term_value)
 {
-   ODP_UNIMPLEMENTED();
+   const _odp_ethhdr_t *eth;
+   const _odp_vlanhdr_t *vlan;
+   uint16_t tci;
+   uint16_t vlan_id;
+
+   if (!pkt_hdr->p.input_flags.vlan_qinq)
+   return 0;
+
+   eth = (const _odp_ethhdr_t *)(pkt_addr + pkt_hdr->p.l2_offset);
+   vlan = (const _odp_vlanhdr_t *)(eth + 1);
+   tci = odp_be_to_cpu_16(vlan->tci);
+   vlan_id = tci & 0x0fff;
+
+   if (term_value->match.value == (vlan_id & term_value->match.mask))
+   return 1;
+
return 0;
 }
 
@@ -243,7 +258,23 @@ static inline int verify_pmr_vlan_id_x(const uint8_t 
*pkt_addr ODP_UNUSED,
   odp_packet_hdr_t *pkt_hdr ODP_UNUSED,
   pmr_term_value_t *term_value ODP_UNUSED)
 {
-   ODP_UNIMPLEMENTED();
+   const _odp_ethhdr_t *eth;
+   const _odp_vlanhdr_t *vlan;
+   uint16_t tci;
+   uint16_t vlan_id;
+
+   if (!pkt_hdr->p.input_flags.vlan_qinq)
+   return 0;
+
+   eth = (const _odp_ethhdr_t *)(pkt_addr + pkt_hdr->p.l2_offset);
+   vlan = (const _odp_vlanhdr_t *)(eth + 1);
+   vlan++;
+   tci = odp_be_to_cpu_16(vlan->tci);
+   vlan_id = tci & 0x0fff;
+
+   if (term_value->match.value == (vlan_id & term_value->match.mask))
+   return 1;
+
return 0;
 }
 
-- 
1.9.1



[lng-odp] [PATCHv3 2/2] validation: classification: add test case for ipv6 src and dst addr

2017-02-03 Thread Balasubramanian Manoharan
Adds test case for ipv6 source and destination address matching

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 .../validation/api/classification/classification.h |  21 ++
 .../api/classification/odp_classification_common.c | 149 ++-
 .../classification/odp_classification_test_pmr.c   | 292 +++--
 .../api/classification/odp_classification_tests.c  |  42 ++-
 .../classification/odp_classification_testsuites.h |  14 +-
 5 files changed, 421 insertions(+), 97 deletions(-)

diff --git a/test/common_plat/validation/api/classification/classification.h 
b/test/common_plat/validation/api/classification/classification.h
index d73c821..0192e24 100644
--- a/test/common_plat/validation/api/classification/classification.h
+++ b/test/common_plat/validation/api/classification/classification.h
@@ -55,6 +55,27 @@
 #define DATA_MAGIC 0x01020304
 #define TEST_SEQ_INVALID   ((uint32_t)~0)
 
+/* Test packet Time-to-live */
+#define DEFAULT_TTL  128
+
+/* Test packet default DSCP value */
+#define LOW_DROP_PRECEDENCE  0x02
+#define MEDIUM_DROP_PRECEDENCE   0x04
+#define HIGH_DROP_PRECEDENCE 0x06
+#define DROP_PRECEDENCE_MASK 0x06
+#define DSCP_CLASS1  0x08
+#define DSCP_CLASS2  0x10
+#define DSCP_CLASS3  0x18
+#define DSCP_CLASS4  0x20
+#define DEFAULT_DSCP (DSCP_CLASS2 | LOW_DROP_PRECEDENCE)
+
+/* Test packet default ECN */
+#define DEFAULT_ECN  ODPH_IP_ECN_ECT0
+
+/* Test packet default TOS */
+#define DEFAULT_TOS  ((DEFAULT_DSCP << ODPH_IP_TOS_DSCP_SHIFT) | \
+   DEFAULT_ECN)
+
 /* test functions: */
 void classification_test_create_cos(void);
 void classification_test_destroy_cos(void);
diff --git 
a/test/common_plat/validation/api/classification/odp_classification_common.c 
b/test/common_plat/validation/api/classification/odp_classification_common.c
index f7ec6e5..0ca9083 100644
--- a/test/common_plat/validation/api/classification/odp_classification_common.c
+++ b/test/common_plat/validation/api/classification/odp_classification_common.c
@@ -14,6 +14,16 @@ typedef struct cls_test_packet {
odp_u32be_t seq;
 } cls_test_packet_t;
 
+static uint8_t IPV6_SRC_ADDR[ODPH_IPV6ADDR_LEN] = {
+   /* I.e. :::10.0.0.1 */
+   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 10, 0, 0, 1
+};
+
+static uint8_t IPV6_DST_ADDR[ODPH_IPV6ADDR_LEN] = {
+   /* I.e. :::10.0.0.100 */
+   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 10, 0, 0, 100
+};
+
 odp_pktio_t create_pktio(odp_queue_type_t q_type, odp_pool_t pool)
 {
odp_pktio_t pktio;
@@ -211,30 +221,30 @@ odp_pool_t pool_create(const char *poolname)
return odp_pool_create(poolname, );
 }
 
-odp_packet_t create_packet(odp_pool_t pool, bool vlan,
-  odp_atomic_u32_t *seq, bool flag_udp)
-{
-   return create_packet_len(pool, vlan, seq, flag_udp, 0);
-}
-
-odp_packet_t create_packet_len(odp_pool_t pool, bool vlan,
-  odp_atomic_u32_t *seq, bool flag_udp,
-  uint16_t len)
+odp_packet_t create_packet(cls_packet_info_t pkt_info)
 {
uint32_t seqno;
odph_ethhdr_t *ethhdr;
odph_udphdr_t *udp;
odph_tcphdr_t *tcp;
odph_ipv4hdr_t *ip;
+   odph_ipv6hdr_t *ipv6;
uint16_t payload_len;
uint64_t src_mac = CLS_DEFAULT_SMAC;
uint64_t dst_mac = CLS_DEFAULT_DMAC;
uint64_t dst_mac_be;
uint32_t addr = 0;
uint32_t mask;
-   int offset;
odp_packet_t pkt;
int packet_len = 0;
+   uint32_tversion, tc, flow, ver_tc_flow;
+   uint8_t *buf, next_hdr;
+   uint32_tl4_len, l3_len, l2_len, l3_offset, l4_offset;
+   uint16_t vlan_hdr_len = 0;
+   uint16_t l2_hdr_len = 0;
+   uint16_t l3_hdr_len = 0;
+   uint16_t l4_hdr_len = 0;
+   uint16_t eth_type;
 
/* 48 bit ethernet address needs to be left shifted for proper
value after changing to be*/
@@ -242,77 +252,85 @@ odp_packet_t create_packet_len(odp_pool_t pool, bool vlan,
if (dst_mac != dst_mac_be)
dst_mac_be = dst_mac_be >> (64 - 8 * ODPH_ETHADDR_LEN);
 
-   payload_len = sizeof(cls_test_packet_t) + len;
-   packet_len += ODPH_ETHHDR_LEN;
-   packet_len += ODPH_IPV4HDR_LEN;
-   if (flag_udp)
-   packet_len += ODPH_UDPHDR_LEN;
-   else
-   packet_len += ODPH_TCPHDR_LEN;
-   packet_len += payload_len;
-
-   if (vlan)
-   packet_len += ODPH_VLANHDR_LEN;
-
-   pkt = odp_packet_alloc(pool, packet_len);
+   payload_len = sizeof(cls_test_packet_t) + pkt_info.len;
+   seqno = odp_atomic_fetch_inc_u32(pkt_info.seq);
+
+   vlan_hdr_len = pkt_info.vlan ? ODPH_VLANHDR_LEN : 0;
+   l3_hdr_len = pkt_info.ipv6 ? ODPH_IPV6HDR_LEN : ODPH_IPV4HDR_LEN;

[lng-odp] [PATCHv3 1/2] linux-generic: classification: implement ipv6 packet matching rule

2017-02-03 Thread Balasubramanian Manoharan
Adds test case for ipv6 source and destination address matching

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
v3: performance enhancement using bitwise AND for ip address mask

 .../include/odp_classification_datamodel.h | 11 -
 .../include/odp_classification_inlines.h   | 52 ++
 .../linux-generic/include/odp_packet_internal.h|  5 +++
 platform/linux-generic/include/protocols/ip.h  | 14 +-
 platform/linux-generic/odp_classification.c| 27 +++
 platform/linux-generic/odp_packet.c|  2 +-
 6 files changed, 99 insertions(+), 12 deletions(-)

diff --git a/platform/linux-generic/include/odp_classification_datamodel.h 
b/platform/linux-generic/include/odp_classification_datamodel.h
index f6393ee..140f39e 100644
--- a/platform/linux-generic/include/odp_classification_datamodel.h
+++ b/platform/linux-generic/include/odp_classification_datamodel.h
@@ -25,6 +25,7 @@ extern "C" {
 #include 
 #include 
 #include 
+#include 
 
 /* Maximum Class Of Service Entry */
 #define ODP_COS_MAX_ENTRY  64
@@ -43,7 +44,7 @@ extern "C" {
 /* Max L3 QoS Value */
 #define ODP_COS_MAX_L3_QOS (1 << ODP_COS_L3_QOS_BITS)
 /* Max PMR Term bits */
-#define ODP_PMR_TERM_BYTES_MAX 8
+#define ODP_PMR_TERM_BYTES_MAX 16
 
 /**
 Packet Matching Rule Term Value
@@ -67,6 +68,14 @@ typedef struct pmr_term_value {
/** End value of the range */
uint64_tval_end;
} range;
+   struct {
+   _odp_ipv6_addr_t addr;
+   _odp_ipv6_addr_t mask;
+   } match_ipv6;
+   struct {
+   _odp_ipv6_addr_t addr_start;
+   _odp_ipv6_addr_t addr_end;
+   } range_ipv6;
};
uint32_toffset; /**< Offset if term == ODP_PMR_CUSTOM_FRAME */
uint32_tval_sz; /**< Size of the value to be matched */
diff --git a/platform/linux-generic/include/odp_classification_inlines.h 
b/platform/linux-generic/include/odp_classification_inlines.h
index b839197..e6f9be9 100644
--- a/platform/linux-generic/include/odp_classification_inlines.h
+++ b/platform/linux-generic/include/odp_classification_inlines.h
@@ -25,6 +25,8 @@ extern "C" {
 #include 
 #include 
 #include 
+#include 
+#include 
 
 /* PMR term value verification function
 These functions verify the given PMR term value with the value in the packet
@@ -179,19 +181,53 @@ static inline int verify_pmr_dmac(const uint8_t *pkt_addr,
return 0;
 }
 
-static inline int verify_pmr_ipv6_saddr(const uint8_t *pkt_addr ODP_UNUSED,
-   odp_packet_hdr_t *pkt_hdr ODP_UNUSED,
-   pmr_term_value_t *term_value ODP_UNUSED)
+static inline int verify_pmr_ipv6_saddr(const uint8_t *pkt_addr,
+   odp_packet_hdr_t *pkt_hdr,
+   pmr_term_value_t *term_value)
 {
-   ODP_UNIMPLEMENTED();
+   const _odp_ipv6hdr_t *ipv6;
+   uint64_t addr[2];
+
+   if (!packet_hdr_has_ipv6(pkt_hdr))
+   return 0;
+
+   ipv6 = (const _odp_ipv6hdr_t *)(pkt_addr + pkt_hdr->p.l3_offset);
+
+   addr[0] = ipv6->src_addr.u64[0];
+   addr[1] = ipv6->src_addr.u64[1];
+
+   /* 128 bit address is processed as two 64 bit value
+   * for bitwise AND operation */
+   addr[0] = addr[0] & term_value->match_ipv6.mask.u64[0];
+   addr[1] = addr[1] & term_value->match_ipv6.mask.u64[1];
+
+   if (!memcmp(addr, term_value->match_ipv6.addr.u8, _ODP_IPV6ADDR_LEN))
+   return 1;
+
return 0;
 }
 
-static inline int verify_pmr_ipv6_daddr(const uint8_t *pkt_addr ODP_UNUSED,
-   odp_packet_hdr_t *pkt_hdr ODP_UNUSED,
-   pmr_term_value_t *term_value ODP_UNUSED)
+static inline int verify_pmr_ipv6_daddr(const uint8_t *pkt_addr,
+   odp_packet_hdr_t *pkt_hdr,
+   pmr_term_value_t *term_value)
 {
-   ODP_UNIMPLEMENTED();
+   const _odp_ipv6hdr_t *ipv6;
+   uint64_t addr[2];
+
+   if (!packet_hdr_has_ipv6(pkt_hdr))
+   return 0;
+   ipv6 = (const _odp_ipv6hdr_t *)(pkt_addr + pkt_hdr->p.l3_offset);
+   addr[0] = ipv6->dst_addr.u64[0];
+   addr[1] = ipv6->dst_addr.u64[1];
+
+   /* 128 bit address is processed as two 64 bit value
+   * for bitwise AND operation */
+   addr[0] = addr[0] & term_value->match_ipv6.mask.u64[0];
+   addr[1] = addr[1] & term_value->match_ipv6.mask.u64[1];
+
+   if (!memcmp(addr, term_value->match_ipv6.addr.u8, _ODP_IPV6ADDR_LEN))
+   return 1;
+
return 0;
 }
 

[lng-odp] [PATCH 2/2] validation: classification: add test case for ipv6 src and dst addr

2017-01-30 Thread Balasubramanian Manoharan
Adds test case for ipv6 source and destination address matching

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 .../validation/api/classification/classification.h |  21 ++
 .../api/classification/odp_classification_common.c | 149 ++-
 .../classification/odp_classification_test_pmr.c   | 292 +++--
 .../api/classification/odp_classification_tests.c  |  42 ++-
 .../classification/odp_classification_testsuites.h |  14 +-
 5 files changed, 423 insertions(+), 95 deletions(-)

diff --git a/test/common_plat/validation/api/classification/classification.h 
b/test/common_plat/validation/api/classification/classification.h
index d73c821..0192e24 100644
--- a/test/common_plat/validation/api/classification/classification.h
+++ b/test/common_plat/validation/api/classification/classification.h
@@ -55,6 +55,27 @@
 #define DATA_MAGIC 0x01020304
 #define TEST_SEQ_INVALID   ((uint32_t)~0)
 
+/* Test packet Time-to-live */
+#define DEFAULT_TTL  128
+
+/* Test packet default DSCP value */
+#define LOW_DROP_PRECEDENCE  0x02
+#define MEDIUM_DROP_PRECEDENCE   0x04
+#define HIGH_DROP_PRECEDENCE 0x06
+#define DROP_PRECEDENCE_MASK 0x06
+#define DSCP_CLASS1  0x08
+#define DSCP_CLASS2  0x10
+#define DSCP_CLASS3  0x18
+#define DSCP_CLASS4  0x20
+#define DEFAULT_DSCP (DSCP_CLASS2 | LOW_DROP_PRECEDENCE)
+
+/* Test packet default ECN */
+#define DEFAULT_ECN  ODPH_IP_ECN_ECT0
+
+/* Test packet default TOS */
+#define DEFAULT_TOS  ((DEFAULT_DSCP << ODPH_IP_TOS_DSCP_SHIFT) | \
+   DEFAULT_ECN)
+
 /* test functions: */
 void classification_test_create_cos(void);
 void classification_test_destroy_cos(void);
diff --git 
a/test/common_plat/validation/api/classification/odp_classification_common.c 
b/test/common_plat/validation/api/classification/odp_classification_common.c
index f7ec6e5..a947074 100644
--- a/test/common_plat/validation/api/classification/odp_classification_common.c
+++ b/test/common_plat/validation/api/classification/odp_classification_common.c
@@ -14,6 +14,16 @@ typedef struct cls_test_packet {
odp_u32be_t seq;
 } cls_test_packet_t;
 
+static uint8_t IPV6_SRC_ADDR[ODPH_IPV6ADDR_LEN] = {
+   /* I.e. :::10.0.0.1 */
+   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 10, 0, 0, 1
+};
+
+static uint8_t IPV6_DST_ADDR[ODPH_IPV6ADDR_LEN] = {
+   /* I.e. :::10.0.0.100 */
+   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 10, 0, 0, 100
+};
+
 odp_pktio_t create_pktio(odp_queue_type_t q_type, odp_pool_t pool)
 {
odp_pktio_t pktio;
@@ -211,21 +221,14 @@ odp_pool_t pool_create(const char *poolname)
return odp_pool_create(poolname, );
 }
 
-odp_packet_t create_packet(odp_pool_t pool, bool vlan,
-  odp_atomic_u32_t *seq, bool flag_udp)
-{
-   return create_packet_len(pool, vlan, seq, flag_udp, 0);
-}
-
-odp_packet_t create_packet_len(odp_pool_t pool, bool vlan,
-  odp_atomic_u32_t *seq, bool flag_udp,
-  uint16_t len)
+odp_packet_t create_packet(cls_packet_info_t pkt_info)
 {
uint32_t seqno;
odph_ethhdr_t *ethhdr;
odph_udphdr_t *udp;
odph_tcphdr_t *tcp;
odph_ipv4hdr_t *ip;
+   odph_ipv6hdr_t *ipv6;
uint16_t payload_len;
uint64_t src_mac = CLS_DEFAULT_SMAC;
uint64_t dst_mac = CLS_DEFAULT_DMAC;
@@ -235,6 +238,14 @@ odp_packet_t create_packet_len(odp_pool_t pool, bool vlan,
int offset;
odp_packet_t pkt;
int packet_len = 0;
+   uint32_tversion, tc, flow, ver_tc_flow;
+   uint8_t *buf, next_hdr;
+   uint32_tl4_len, l3_len, l2_len, l3_offset, l4_offset;
+   uint16_t vlan_hdr_len = 0;
+   uint16_t l2_hdr_len = 0;
+   uint16_t l3_hdr_len = 0;
+   uint16_t l4_hdr_len = 0;
+   uint16_t eth_type;
 
/* 48 bit ethernet address needs to be left shifted for proper
value after changing to be*/
@@ -242,77 +253,88 @@ odp_packet_t create_packet_len(odp_pool_t pool, bool vlan,
if (dst_mac != dst_mac_be)
dst_mac_be = dst_mac_be >> (64 - 8 * ODPH_ETHADDR_LEN);
 
-   payload_len = sizeof(cls_test_packet_t) + len;
-   packet_len += ODPH_ETHHDR_LEN;
-   packet_len += ODPH_IPV4HDR_LEN;
-   if (flag_udp)
-   packet_len += ODPH_UDPHDR_LEN;
-   else
-   packet_len += ODPH_TCPHDR_LEN;
-   packet_len += payload_len;
-
-   if (vlan)
-   packet_len += ODPH_VLANHDR_LEN;
-
-   pkt = odp_packet_alloc(pool, packet_len);
+   payload_len = sizeof(cls_test_packet_t) + pkt_info.len;
+   seqno = odp_atomic_fetch_inc_u32(pkt_info.seq);
+
+   vlan_hdr_len = pkt_info.vlan ? ODPH_VLANHDR_LEN : 0;
+   l3_hdr_len = pkt_info.ipv6 ? ODPH_IPV6HDR_LEN : ODPH_IPV4HDR_LEN;

[lng-odp] [PATCH 1/2] linux-generic: classification: implement ipv6 packet matching rule

2017-01-30 Thread Balasubramanian Manoharan
Implements IPV6 src and dst address packet matching rule

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 .../include/odp_classification_datamodel.h | 11 +-
 .../include/odp_classification_inlines.h   | 44 ++
 .../linux-generic/include/odp_packet_internal.h|  5 +++
 platform/linux-generic/odp_classification.c| 26 +
 4 files changed, 77 insertions(+), 9 deletions(-)

diff --git a/platform/linux-generic/include/odp_classification_datamodel.h 
b/platform/linux-generic/include/odp_classification_datamodel.h
index f6393ee..5b1cde3 100644
--- a/platform/linux-generic/include/odp_classification_datamodel.h
+++ b/platform/linux-generic/include/odp_classification_datamodel.h
@@ -25,6 +25,7 @@ extern "C" {
 #include 
 #include 
 #include 
+#include 
 
 /* Maximum Class Of Service Entry */
 #define ODP_COS_MAX_ENTRY  64
@@ -43,7 +44,7 @@ extern "C" {
 /* Max L3 QoS Value */
 #define ODP_COS_MAX_L3_QOS (1 << ODP_COS_L3_QOS_BITS)
 /* Max PMR Term bits */
-#define ODP_PMR_TERM_BYTES_MAX 8
+#define ODP_PMR_TERM_BYTES_MAX 16
 
 /**
 Packet Matching Rule Term Value
@@ -67,6 +68,14 @@ typedef struct pmr_term_value {
/** End value of the range */
uint64_tval_end;
} range;
+   struct {
+   uint8_t value[_ODP_IPV6ADDR_LEN];
+   uint8_t mask[_ODP_IPV6ADDR_LEN];
+   } match_ipv6;
+   struct {
+   uint8_t val_start[_ODP_IPV6ADDR_LEN];
+   uint8_t val_end[_ODP_IPV6ADDR_LEN];
+   } range_ipv6;
};
uint32_toffset; /**< Offset if term == ODP_PMR_CUSTOM_FRAME */
uint32_tval_sz; /**< Size of the value to be matched */
diff --git a/platform/linux-generic/include/odp_classification_inlines.h 
b/platform/linux-generic/include/odp_classification_inlines.h
index b839197..4d85cf2 100644
--- a/platform/linux-generic/include/odp_classification_inlines.h
+++ b/platform/linux-generic/include/odp_classification_inlines.h
@@ -179,19 +179,47 @@ static inline int verify_pmr_dmac(const uint8_t *pkt_addr,
return 0;
 }
 
-static inline int verify_pmr_ipv6_saddr(const uint8_t *pkt_addr ODP_UNUSED,
-   odp_packet_hdr_t *pkt_hdr ODP_UNUSED,
-   pmr_term_value_t *term_value ODP_UNUSED)
+static inline int verify_pmr_ipv6_saddr(const uint8_t *pkt_addr,
+   odp_packet_hdr_t *pkt_hdr,
+   pmr_term_value_t *term_value)
 {
-   ODP_UNIMPLEMENTED();
+   const _odp_ipv6hdr_t *ipv6;
+   uint8_t src_addr[_ODP_IPV6ADDR_LEN];
+   uint8_t i;
+
+   if (!packet_hdr_has_ipv6(pkt_hdr))
+   return 0;
+
+   ipv6 = (const _odp_ipv6hdr_t *)(pkt_addr + pkt_hdr->p.l3_offset);
+   memcpy(src_addr, ipv6->src_addr, _ODP_IPV6ADDR_LEN);
+   for (i = 0; i < _ODP_IPV6ADDR_LEN; i++)
+   src_addr[i] = src_addr[i] & term_value->match_ipv6.mask[i];
+
+   if (!memcmp(term_value->match_ipv6.value, src_addr, _ODP_IPV6ADDR_LEN))
+   return 1;
+
return 0;
 }
 
-static inline int verify_pmr_ipv6_daddr(const uint8_t *pkt_addr ODP_UNUSED,
-   odp_packet_hdr_t *pkt_hdr ODP_UNUSED,
-   pmr_term_value_t *term_value ODP_UNUSED)
+static inline int verify_pmr_ipv6_daddr(const uint8_t *pkt_addr,
+   odp_packet_hdr_t *pkt_hdr,
+   pmr_term_value_t *term_value)
 {
-   ODP_UNIMPLEMENTED();
+   const _odp_ipv6hdr_t *ipv6;
+   uint8_t dst_addr[_ODP_IPV6ADDR_LEN];
+   uint8_t i;
+
+   if (!packet_hdr_has_ipv6(pkt_hdr))
+   return 0;
+
+   ipv6 = (const _odp_ipv6hdr_t *)(pkt_addr + pkt_hdr->p.l3_offset);
+   memcpy(dst_addr, ipv6->dst_addr, _ODP_IPV6ADDR_LEN);
+   for (i = 0; i < _ODP_IPV6ADDR_LEN; i++)
+   dst_addr[i] = dst_addr[i] & term_value->match_ipv6.mask[i];
+
+   if (!memcmp(term_value->match_ipv6.value, dst_addr, _ODP_IPV6ADDR_LEN))
+   return 1;
+
return 0;
 }
 
diff --git a/platform/linux-generic/include/odp_packet_internal.h 
b/platform/linux-generic/include/odp_packet_internal.h
index e6e9d74..e3ada5c 100644
--- a/platform/linux-generic/include/odp_packet_internal.h
+++ b/platform/linux-generic/include/odp_packet_internal.h
@@ -294,6 +294,11 @@ static inline int packet_hdr_has_eth(odp_packet_hdr_t 
*pkt_hdr)
return pkt_hdr->p.input_flags.eth;
 }
 
+static inline int packet_hdr_has_ipv6(odp_packet_hdr_t *pkt_hdr)
+{
+   return pkt_hdr->p.input_flags.ipv6;
+}
+
 static inline void 

[lng-odp] [PATCHv3 1/1] validation: pktio: fix invalid mac addr

2017-01-05 Thread Balasubramanian Manoharan
Fixes https://bugs.linaro.org/show_bug.cgi?id=2496

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
v3: Review comment incorporation

 test/common_plat/validation/api/pktio/pktio.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/test/common_plat/validation/api/pktio/pktio.c 
b/test/common_plat/validation/api/pktio/pktio.c
index 7c979fb..438b7e8 100644
--- a/test/common_plat/validation/api/pktio/pktio.c
+++ b/test/common_plat/validation/api/pktio/pktio.c
@@ -31,6 +31,8 @@
 #define PKTIN_TS_MAX_RES   100
 #define PKTIN_TS_CMP_RES   1
 
+#define PKTIO_SRC_MAC  {1, 2, 3, 4, 5, 6}
+#define PKTIO_DST_MAC  {6, 5, 4, 3, 2, 1}
 #undef DEBUG_STATS
 
 /** interface names used for testing */
@@ -245,7 +247,8 @@ static uint32_t pktio_init_packet(odp_packet_t pkt)
odph_udphdr_t *udp;
char *buf;
uint16_t seq;
-   uint8_t mac[ODP_PKTIO_MACADDR_MAXSIZE] = {0};
+   uint8_t src_mac[ODP_PKTIO_MACADDR_MAXSIZE] = PKTIO_SRC_MAC;
+   uint8_t dst_mac[ODP_PKTIO_MACADDR_MAXSIZE] = PKTIO_DST_MAC;
int pkt_len = odp_packet_len(pkt);
 
buf = odp_packet_data(pkt);
@@ -253,8 +256,8 @@ static uint32_t pktio_init_packet(odp_packet_t pkt)
/* Ethernet */
odp_packet_l2_offset_set(pkt, 0);
eth = (odph_ethhdr_t *)buf;
-   memcpy(eth->src.addr, mac, ODPH_ETHADDR_LEN);
-   memcpy(eth->dst.addr, mac, ODPH_ETHADDR_LEN);
+   memcpy(eth->src.addr, _mac, ODPH_ETHADDR_LEN);
+   memcpy(eth->dst.addr, _mac, ODPH_ETHADDR_LEN);
eth->type = odp_cpu_to_be_16(ODPH_ETHTYPE_IPV4);
 
/* IP */
-- 
1.9.1



[lng-odp] [RFC/API-NEXT 1/1] api: classification: packet hashing per class of service

2016-12-09 Thread Balasubramanian Manoharan
Adds support to spread packet from a single CoS to multiple queues by
configuring hashing at CoS level.

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 include/odp/api/spec/classification.h | 45 ---
 1 file changed, 42 insertions(+), 3 deletions(-)

diff --git a/include/odp/api/spec/classification.h 
b/include/odp/api/spec/classification.h
index 0e442c7..220b029 100644
--- a/include/odp/api/spec/classification.h
+++ b/include/odp/api/spec/classification.h
@@ -126,6 +126,12 @@ typedef struct odp_cls_capability_t {
/** Maximum number of CoS supported */
unsigned max_cos;
 
+   /** Maximun number of queue supported per CoS */
+   unsigned max_queue_supported;
+
+   /** Protocol header combination supported for Hashing */
+   odp_pktin_hash_proto_t hash_supported;
+
/** A Boolean to denote support of PMR range */
odp_bool_t pmr_range_supported;
 } odp_cls_capability_t;
@@ -164,9 +170,25 @@ typedef enum {
  * Used to communicate class of service creation options
  */
 typedef struct odp_cls_cos_param {
-   odp_queue_t queue;  /**< Queue associated with CoS */
-   odp_pool_t pool;/**< Pool associated with CoS */
-   odp_cls_drop_t drop_policy; /**< Drop policy associated with CoS */
+   /* Minimum number of queues to be linked to this CoS.
+* If the number is greater than 1 then hashing has to be
+* enabled */
+   uint32_t num_queue;
+   /* Denotes whether hashing is enabled for queues in this CoS
+* When hashing is enabled the queues are created by the implementation
+* and application need not configure any queue to the class of service
+*/
+   odp_bool_t enable_hashing;
+   /* Protocol header fields which are included in packet input
+* hash calculation */
+   odp_pktin_hash_proto_t hash;
+   /* If hashing is disabled, then application has to configure
+* this queue and packets are delivered to this queue */
+   odp_queue_t queue;
+   /* Pool associated with CoS */
+   odp_pool_t pool;
+   /* Drop policy associated with CoS */
+   odp_cls_drop_t drop_policy;
 } odp_cls_cos_param_t;
 
 /**
@@ -209,6 +231,23 @@ int odp_cls_capability(odp_cls_capability_t *capability);
 odp_cos_t odp_cls_cos_create(const char *name, odp_cls_cos_param_t *param);
 
 /**
+ * Queue hash result
+ * Returns the queue within a CoS in which a particular packet will be enqueued
+ * based on the packet parameters and hash protocol field configured with the
+ * class of service.
+ *
+ * @param  cos class of service
+ * @param  packet  Packet handle
+ *
+ * @retval Returns the queue handle on which this packet will be
+ * enqueued.
+ * @retval ODP_QUEUE_INVALID for error case
+ *
+ * @note The packet has to be updated with valid header pointers L2, L3 and L4.
+ */
+odp_queue_t odp_queue_hash_result(odp_cos_t cos, odp_packet_t packet);
+
+/**
  * Discard a class-of-service along with all its associated resources
  *
  * @param[in]  cos_id  class-of-service instance.
-- 
1.9.1



[lng-odp] [PATCHv2 1/1] validation: pktio: fix invalid mac addr

2016-11-10 Thread Balasubramanian Manoharan
Fixes https://bugs.linaro.org/show_bug.cgi?id=2496

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
v2: Incorporate review comments
 test/common_plat/validation/api/pktio/pktio.c | 24 +---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/test/common_plat/validation/api/pktio/pktio.c 
b/test/common_plat/validation/api/pktio/pktio.c
index a6a18c3..7115def 100644
--- a/test/common_plat/validation/api/pktio/pktio.c
+++ b/test/common_plat/validation/api/pktio/pktio.c
@@ -31,6 +31,8 @@
 #define PKTIN_TS_MAX_RES   100
 #define PKTIN_TS_CMP_RES   1
 
+#define PKTIO_SRC_MAC  {1, 2, 3, 4, 5, 6}
+#define PKTIO_DST_MAC  {1, 2, 3, 4, 5, 6}
 #undef DEBUG_STATS
 
 /** interface names used for testing */
@@ -241,16 +243,32 @@ static uint32_t pktio_init_packet(odp_packet_t pkt)
odph_udphdr_t *udp;
char *buf;
uint16_t seq;
-   uint8_t mac[ODP_PKTIO_MACADDR_MAXSIZE] = {0};
+   uint8_t src_mac[ODP_PKTIO_MACADDR_MAXSIZE] = PKTIO_SRC_MAC;
+   uint8_t dst_mac[ODP_PKTIO_MACADDR_MAXSIZE] = PKTIO_DST_MAC;
+   uint8_t src_mac_be[ODP_PKTIO_MACADDR_MAXSIZE];
+   uint8_t dst_mac_be[ODP_PKTIO_MACADDR_MAXSIZE];
int pkt_len = odp_packet_len(pkt);
+   int i;
+
+   #if ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN
+   for (i = 0; i < ODP_PKTIO_MACADDR_MAXSIZE; i++) {
+   src_mac_be[i] = src_mac[i];
+   dst_mac_be[i] = dst_mac[i];
+   }
+   #else
+   for (i = 0; i < ODP_PKTIO_MACADDR_MAXSIZE; i++) {
+   src_mac_be[i] = src_mac[ODP_PKTIO_MACADDR_MAXSIZE - i];
+   dst_mac_be[i] = dst_mac[ODP_PKTIO_MACADDR_MAXSIZE - i];
+   }
+   #endif
 
buf = odp_packet_data(pkt);
 
/* Ethernet */
odp_packet_l2_offset_set(pkt, 0);
eth = (odph_ethhdr_t *)buf;
-   memcpy(eth->src.addr, mac, ODPH_ETHADDR_LEN);
-   memcpy(eth->dst.addr, mac, ODPH_ETHADDR_LEN);
+   memcpy(eth->src.addr, _mac_be, ODPH_ETHADDR_LEN);
+   memcpy(eth->dst.addr, _mac_be, ODPH_ETHADDR_LEN);
eth->type = odp_cpu_to_be_16(ODPH_ETHTYPE_IPV4);
 
/* IP */
-- 
1.9.1



[lng-odp] [API-NEXTv2 1/1] api: pktio: adds further definition for classification configuration

2016-11-04 Thread Balasubramanian Manoharan
Updates classification configuration documentation.

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
v2: Incorporates review comments
 include/odp/api/spec/packet_io.h | 17 ++---
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/include/odp/api/spec/packet_io.h b/include/odp/api/spec/packet_io.h
index d46e405..6598d3e 100644
--- a/include/odp/api/spec/packet_io.h
+++ b/include/odp/api/spec/packet_io.h
@@ -189,12 +189,11 @@ typedef struct odp_pktin_queue_param_t {
 
/** Number of input queues to be created
  *
- * When classifier is enabled the number of queues may be zero
- * (in odp_pktin_queue_config() step), otherwise at least one
- * queue is required. More than one input queues require either flow
- * hashing or classifier enabled. The maximum value is defined by
- * pktio capability 'max_input_queues'. Queue type is defined by the
- * input mode. The default value is 1. */
+ * When classifier is enabled in odp_ipktin_queue_config() this
+ * value is ignored, otherwise at least one queue is required.
+ * More than one input queues require flow hashing configured.
+ * The maximum value is defined by pktio capability 'max_input_queues'.
+ * Queue type is defined by the input mode. The default value is 1. */
unsigned num_queues;
 
/** Queue parameters
@@ -202,7 +201,9 @@ typedef struct odp_pktin_queue_param_t {
  * These are used for input queue creation in ODP_PKTIN_MODE_QUEUE
  * or ODP_PKTIN_MODE_SCHED modes. Scheduler parameters are considered
  * only in ODP_PKTIN_MODE_SCHED mode. Default values are defined in
- * odp_queue_param_t documentation. */
+ * odp_queue_param_t documentation.
+ * when classifier is enabled in odp_pktin_queue_config() this
+ * value is ignored. */
odp_queue_param_t queue_param;
 
 } odp_pktin_queue_param_t;
@@ -887,6 +888,8 @@ int odp_pktio_mac_addr(odp_pktio_t pktio, void *mac_addr, 
int size);
  *
  * @retval 0 on success
  * @retval <0 on failure
+ *
+ * @note The default_cos has to be unique per odp_pktio_t instance.
  */
 int odp_pktio_default_cos_set(odp_pktio_t pktio, odp_cos_t default_cos);
 
-- 
1.9.1



[lng-odp] [PATCHv1 1/1] validation: pktio: fix invalid mac addr

2016-11-03 Thread Balasubramanian Manoharan
Fixes https://bugs.linaro.org/show_bug.cgi?id=2496

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 test/common_plat/validation/api/pktio/pktio.c | 17 ++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/test/common_plat/validation/api/pktio/pktio.c 
b/test/common_plat/validation/api/pktio/pktio.c
index a6a18c3..4bc7e0a 100644
--- a/test/common_plat/validation/api/pktio/pktio.c
+++ b/test/common_plat/validation/api/pktio/pktio.c
@@ -241,16 +241,27 @@ static uint32_t pktio_init_packet(odp_packet_t pkt)
odph_udphdr_t *udp;
char *buf;
uint16_t seq;
-   uint8_t mac[ODP_PKTIO_MACADDR_MAXSIZE] = {0};
+   uint64_t src_mac = 0x010203040506;
+   uint64_t dst_mac = 0x070809101112;
+   uint64_t src_mac_be;
+   uint64_t dst_mac_be;
int pkt_len = odp_packet_len(pkt);
 
+   dst_mac_be = odp_cpu_to_be_64(dst_mac);
+   if (dst_mac != dst_mac_be)
+   dst_mac_be = dst_mac_be >> (64 - 8 * ODPH_ETHADDR_LEN);
+
+   src_mac_be = odp_cpu_to_be_64(src_mac);
+   if (src_mac != src_mac_be)
+   src_mac_be = src_mac_be >> (64 - 8 * ODPH_ETHADDR_LEN);
+
buf = odp_packet_data(pkt);
 
/* Ethernet */
odp_packet_l2_offset_set(pkt, 0);
eth = (odph_ethhdr_t *)buf;
-   memcpy(eth->src.addr, mac, ODPH_ETHADDR_LEN);
-   memcpy(eth->dst.addr, mac, ODPH_ETHADDR_LEN);
+   memcpy(eth->src.addr, _mac_be, ODPH_ETHADDR_LEN);
+   memcpy(eth->dst.addr, _mac_be, ODPH_ETHADDR_LEN);
eth->type = odp_cpu_to_be_16(ODPH_ETHTYPE_IPV4);
 
/* IP */
-- 
1.9.1



[lng-odp] [PATCHv2 1/1] validation: classification: fix TCP/UDP checksum update

2016-10-27 Thread Balasubramanian Manoharan
Fixes https://bugs.linaro.org/show_bug.cgi?id=2512

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
v2: Incorporates review comments
 .../api/classification/odp_classification_common.c | 14 +-
 .../api/classification/odp_classification_test_pmr.c   |  3 +++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git 
a/test/common_plat/validation/api/classification/odp_classification_common.c 
b/test/common_plat/validation/api/classification/odp_classification_common.c
index 7a42ac7..2923a71 100644
--- a/test/common_plat/validation/api/classification/odp_classification_common.c
+++ b/test/common_plat/validation/api/classification/odp_classification_common.c
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include 
+#include "test_debug.h"
 
 typedef struct cls_test_packet {
odp_u32be_t magic;
@@ -291,6 +292,8 @@ odp_packet_t create_packet_len(odp_pool_t pool, bool vlan,
parse_ipv4_string(CLS_DEFAULT_SADDR, , );
ip->src_addr = odp_cpu_to_be_32(addr);
ip->ver_ihl = ODPH_IPV4 << 4 | ODPH_IPV4HDR_IHL_MIN;
+   odp_packet_has_ipv4_set(pkt, 1);
+
if (flag_udp)
ip->tot_len = odp_cpu_to_be_16(ODPH_UDPHDR_LEN + payload_len +
   ODPH_IPV4HDR_LEN);
@@ -318,14 +321,23 @@ odp_packet_t create_packet_len(odp_pool_t pool, bool vlan,
udp->dst_port = odp_cpu_to_be_16(CLS_DEFAULT_DPORT);
udp->length = odp_cpu_to_be_16(payload_len + ODPH_UDPHDR_LEN);
udp->chksum = 0;
+   odp_packet_has_udp_set(pkt, 1);
+   if (odph_udp_tcp_chksum(pkt, ODPH_CHKSUM_GENERATE, NULL) != 0) {
+   LOG_ERR("odph_udp_tcp_chksum failed\n");
+   return ODP_PACKET_INVALID;
+   }
} else {
odp_packet_l4_offset_set(pkt, offset);
tcp = (odph_tcphdr_t *)odp_packet_l4_ptr(pkt, NULL);
tcp->src_port = odp_cpu_to_be_16(CLS_DEFAULT_SPORT);
tcp->dst_port = odp_cpu_to_be_16(CLS_DEFAULT_DPORT);
tcp->hl = ODPH_TCPHDR_LEN / 4;
-   /* TODO: checksum field has to be updated */
tcp->cksm = 0;
+   odp_packet_has_tcp_set(pkt, 1);
+   if (odph_udp_tcp_chksum(pkt, ODPH_CHKSUM_GENERATE, NULL) != 0) {
+   LOG_ERR("odph_udp_tcp_chksum failed\n");
+   return ODP_PACKET_INVALID;
+   }
}
 
/* set pkt sequence number */
diff --git 
a/test/common_plat/validation/api/classification/odp_classification_test_pmr.c 
b/test/common_plat/validation/api/classification/odp_classification_test_pmr.c
index c8bbf50..88fbf8f 100644
--- 
a/test/common_plat/validation/api/classification/odp_classification_test_pmr.c
+++ 
b/test/common_plat/validation/api/classification/odp_classification_test_pmr.c
@@ -717,6 +717,7 @@ void classification_test_pmr_term_dmac(void)
 
/* Other packets delivered to default queue */
pkt = create_packet(pkt_pool, false, , false);
+   CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
eth = (odph_ethhdr_t *)odp_packet_l2_ptr(pkt, NULL);
memset(eth->dst.addr, 0, ODPH_ETHADDR_LEN);
CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
@@ -1102,6 +1103,7 @@ static void classification_test_pmr_term_daddr(void)
/* packet with dst ip address matching PMR rule to be
received in the CoS queue*/
pkt = create_packet(pkt_pool, false, , false);
+   CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
eth = (odph_ethhdr_t *)odp_packet_l2_ptr(pkt, NULL);
odp_pktio_mac_addr(pktio, eth->src.addr, ODPH_ETHADDR_LEN);
odp_pktio_mac_addr(pktio, eth->dst.addr, ODPH_ETHADDR_LEN);
@@ -1122,6 +1124,7 @@ static void classification_test_pmr_term_daddr(void)
 
/* Other packets delivered to default queue */
pkt = create_packet(pkt_pool, false, , false);
+   CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
seqno = cls_pkt_get_seq(pkt);
CU_ASSERT(seqno != TEST_SEQ_INVALID);
eth = (odph_ethhdr_t *)odp_packet_l2_ptr(pkt, NULL);
-- 
1.9.1



[lng-odp] [PATCH 1/1] validation: classification: fix TCP/UDP checksum update

2016-09-09 Thread Balasubramanian Manoharan
Fixes https://bugs.linaro.org/show_bug.cgi?id=2512

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 .../validation/api/classification/odp_classification_common.c  | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git 
a/test/common_plat/validation/api/classification/odp_classification_common.c 
b/test/common_plat/validation/api/classification/odp_classification_common.c
index 7a42ac7..93ac0c0 100644
--- a/test/common_plat/validation/api/classification/odp_classification_common.c
+++ b/test/common_plat/validation/api/classification/odp_classification_common.c
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include 
+#include "test_debug.h"
 
 typedef struct cls_test_packet {
odp_u32be_t magic;
@@ -291,6 +292,8 @@ odp_packet_t create_packet_len(odp_pool_t pool, bool vlan,
parse_ipv4_string(CLS_DEFAULT_SADDR, , );
ip->src_addr = odp_cpu_to_be_32(addr);
ip->ver_ihl = ODPH_IPV4 << 4 | ODPH_IPV4HDR_IHL_MIN;
+   odp_packet_has_ipv4_set(pkt, 1);
+
if (flag_udp)
ip->tot_len = odp_cpu_to_be_16(ODPH_UDPHDR_LEN + payload_len +
   ODPH_IPV4HDR_LEN);
@@ -318,14 +321,19 @@ odp_packet_t create_packet_len(odp_pool_t pool, bool vlan,
udp->dst_port = odp_cpu_to_be_16(CLS_DEFAULT_DPORT);
udp->length = odp_cpu_to_be_16(payload_len + ODPH_UDPHDR_LEN);
udp->chksum = 0;
+   odp_packet_has_udp_set(pkt, 1);
+   if (odph_udp_tcp_chksum(pkt, ODPH_CHKSUM_GENERATE, NULL) != 0)
+   LOG_ERR("odph_udp_tcp_chksum failed\n");
} else {
odp_packet_l4_offset_set(pkt, offset);
tcp = (odph_tcphdr_t *)odp_packet_l4_ptr(pkt, NULL);
tcp->src_port = odp_cpu_to_be_16(CLS_DEFAULT_SPORT);
tcp->dst_port = odp_cpu_to_be_16(CLS_DEFAULT_DPORT);
tcp->hl = ODPH_TCPHDR_LEN / 4;
-   /* TODO: checksum field has to be updated */
tcp->cksm = 0;
+   odp_packet_has_tcp_set(pkt, 1);
+   if (odph_udp_tcp_chksum(pkt, ODPH_CHKSUM_GENERATE, NULL) != 0)
+   LOG_ERR("odph_udp_tcp_chksum failed\n");
}
 
/* set pkt sequence number */
-- 
1.9.1



[lng-odp] [PATCH/API-NEXTv2 3/3] example: traffic_mngr: support for pktio interface in odp_tm_egress_t struct

2016-06-28 Thread Balasubramanian Manoharan
Example modifications to support pktio interface in TM system

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 test/validation/traffic_mngr/traffic_mngr.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/test/validation/traffic_mngr/traffic_mngr.c 
b/test/validation/traffic_mngr/traffic_mngr.c
index 0645370..2fcf2fa 100644
--- a/test/validation/traffic_mngr/traffic_mngr.c
+++ b/test/validation/traffic_mngr/traffic_mngr.c
@@ -323,7 +323,7 @@ static odp_pktio_t pktios[MAX_NUM_IFACES];
 static odp_pktin_queue_t pktins[MAX_NUM_IFACES];
 static odp_pktout_queue_t pktouts[MAX_NUM_IFACES];
 static odp_pktin_queue_t rcv_pktin;
-static odp_pktout_queue_t xmt_pktout;
+static odp_pktio_t xmt_pktio;
 
 static odph_ethaddr_t src_mac;
 static odph_ethaddr_t dst_mac;
@@ -543,7 +543,7 @@ static int open_pktios(void)
}
 
if (2 <= num_ifaces) {
-   xmt_pktout = pktouts[0];
+   xmt_pktio = pktios[0];
rcv_pktin  = pktins[1];
ret = odp_pktio_start(pktios[1]);
if (ret != 0) {
@@ -551,7 +551,7 @@ static int open_pktios(void)
return -1;
}
} else {
-   xmt_pktout = pktouts[0];
+   xmt_pktio = pktios[0];
rcv_pktin  = pktins[0];
}
 
@@ -1627,7 +1627,7 @@ static int create_tm_system(void)
}
 
egress.egress_kind = ODP_TM_EGRESS_PKT_IO;
-   egress.pktout  = xmt_pktout;
+   egress.pktio  = xmt_pktio;
 
snprintf(tm_name, sizeof(tm_name), "TM_system_%u", num_odp_tm_systems);
odp_tm = odp_tm_create(tm_name, , );
-- 
1.9.1

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


[lng-odp] [PATCH/API-NEXTv2 2/3] linux-generic: traffic_mngr: add pktio interface to odp_tm_egress_t struct

2016-06-28 Thread Balasubramanian Manoharan
Code changes for replacing odp_pktout_queue_t with odp_pktio_t in TM system

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 platform/linux-generic/include/odp_traffic_mngr_internal.h | 2 +-
 platform/linux-generic/odp_traffic_mngr.c  | 8 +++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/platform/linux-generic/include/odp_traffic_mngr_internal.h 
b/platform/linux-generic/include/odp_traffic_mngr_internal.h
index 3586889..3e13a0a 100644
--- a/platform/linux-generic/include/odp_traffic_mngr_internal.h
+++ b/platform/linux-generic/include/odp_traffic_mngr_internal.h
@@ -379,7 +379,7 @@ typedef struct {
tm_queue_info_t priority_info[ODP_TM_MAX_PRIORITIES];
 
tm_random_data_t tm_random_data;
-
+   odp_pktout_queue_t pktout;
uint64_t   current_time;
uint8_ttm_idx;
uint8_tfirst_enq;
diff --git a/platform/linux-generic/odp_traffic_mngr.c 
b/platform/linux-generic/odp_traffic_mngr.c
index 1fa2d27..54c3517 100644
--- a/platform/linux-generic/odp_traffic_mngr.c
+++ b/platform/linux-generic/odp_traffic_mngr.c
@@ -2106,7 +2106,7 @@ static void tm_send_pkt(tm_system_t *tm_system, uint32_t 
max_sends)
 
tm_system->egress_pkt_desc = EMPTY_PKT_DESC;
if (tm_system->egress.egress_kind == ODP_TM_EGRESS_PKT_IO)
-   odp_pktout_send(tm_system->egress.pktout, _pkt, 1);
+   odp_pktout_send(tm_system->pktout, _pkt, 1);
else if (tm_system->egress.egress_kind == ODP_TM_EGRESS_FN)
tm_system->egress.egress_fcn(odp_pkt);
else
@@ -2424,6 +2424,7 @@ int odp_tm_capabilities(odp_tm_capabilities_t 
capabilities[] ODP_UNUSED,
cap_ptr->max_tm_queues = ODP_TM_MAX_TM_QUEUES;
cap_ptr->max_levels= ODP_TM_MAX_LEVELS;
cap_ptr->tm_queue_shaper_supported = true;
+   cap_ptr->egress_fcn_supported  = true;
cap_ptr->tm_queue_wred_supported   = true;
cap_ptr->tm_queue_dual_slope_supported = true;
cap_ptr->vlan_marking_supported= true;
@@ -2605,6 +2606,7 @@ odp_tm_t odp_tm_create(const char*name,
tm_system_t *tm_system;
odp_bool_t create_fail;
odp_tm_t odp_tm;
+   odp_pktout_queue_t pktout;
uint32_t malloc_len, max_num_queues, max_queued_pkts, max_timers;
uint32_t max_tm_queues, max_sorted_lists;
int rc;
@@ -2625,6 +2627,10 @@ odp_tm_t odp_tm_create(const char*name,
return ODP_TM_INVALID;
}
 
+   if (odp_pktout_queue(egress->pktio, , 1) != 1)
+   return ODP_TM_INVALID;
+
+   tm_system->pktout = pktout;
tm_system->name_tbl_id = name_tbl_id;
max_tm_queues = requirements->max_tm_queues;
memcpy(_system->egress, egress, sizeof(odp_tm_egress_t));
-- 
1.9.1

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


[lng-odp] [PATCH/API-NEXTv2 1/3] api: traffic_mngr: Add pktio interface to odp_tm_egress_t struct

2016-06-28 Thread Balasubramanian Manoharan
Replaces pktio interface as input to TM system instead of
odp_pktout_queue_t.This creates an 1 to 1 mapping between a TM system
and pktio interface.

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
v2: Incorporates review comments from Petri
 include/odp/api/spec/traffic_mngr.h | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/include/odp/api/spec/traffic_mngr.h 
b/include/odp/api/spec/traffic_mngr.h
index 83b89e7..c9e6f8f 100644
--- a/include/odp/api/spec/traffic_mngr.h
+++ b/include/odp/api/spec/traffic_mngr.h
@@ -270,6 +270,12 @@ typedef struct {
 * have their fan_in only from tm_queues. */
uint8_t max_levels;
 
+   /** egress_fcn_supported indicates whether the tm system supports
+   * egress function. It is an optional feature used to receive the
+   * packet from the tm system and its performance might be limited.
+   */
+   odp_bool_t egress_fcn_supported;
+
/** tm_queue_shaper_supported indicates that the tm_queues support
 * proper TM shaping.  Note that TM Shaping is NOT the same thing as
 * Ingress Metering/Policing as specified by RFC 2697 (A Single Rate
@@ -467,7 +473,7 @@ typedef struct {
odp_tm_egress_kind_t egress_kind; /**< Union discriminator */
 
union {
-   odp_pktout_queue_t pktout;
+   odp_pktio_t pktio;
odp_tm_egress_fcn_t egress_fcn;
};
 } odp_tm_egress_t;
-- 
1.9.1

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


[lng-odp] [PATCH/API-NEXT 3/3] example: traffic_mngr: support for pktio interface in odp_tm_egress_t struct

2016-06-20 Thread Balasubramanian Manoharan
Example modifications to support pktio interface in TM system

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 test/validation/traffic_mngr/traffic_mngr.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/test/validation/traffic_mngr/traffic_mngr.c 
b/test/validation/traffic_mngr/traffic_mngr.c
index 0645370..2fcf2fa 100644
--- a/test/validation/traffic_mngr/traffic_mngr.c
+++ b/test/validation/traffic_mngr/traffic_mngr.c
@@ -323,7 +323,7 @@ static odp_pktio_t pktios[MAX_NUM_IFACES];
 static odp_pktin_queue_t pktins[MAX_NUM_IFACES];
 static odp_pktout_queue_t pktouts[MAX_NUM_IFACES];
 static odp_pktin_queue_t rcv_pktin;
-static odp_pktout_queue_t xmt_pktout;
+static odp_pktio_t xmt_pktio;
 
 static odph_ethaddr_t src_mac;
 static odph_ethaddr_t dst_mac;
@@ -543,7 +543,7 @@ static int open_pktios(void)
}
 
if (2 <= num_ifaces) {
-   xmt_pktout = pktouts[0];
+   xmt_pktio = pktios[0];
rcv_pktin  = pktins[1];
ret = odp_pktio_start(pktios[1]);
if (ret != 0) {
@@ -551,7 +551,7 @@ static int open_pktios(void)
return -1;
}
} else {
-   xmt_pktout = pktouts[0];
+   xmt_pktio = pktios[0];
rcv_pktin  = pktins[0];
}
 
@@ -1627,7 +1627,7 @@ static int create_tm_system(void)
}
 
egress.egress_kind = ODP_TM_EGRESS_PKT_IO;
-   egress.pktout  = xmt_pktout;
+   egress.pktio  = xmt_pktio;
 
snprintf(tm_name, sizeof(tm_name), "TM_system_%u", num_odp_tm_systems);
odp_tm = odp_tm_create(tm_name, , );
-- 
1.9.1

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


[lng-odp] [PATCH/API-NEXT 2/3] linux-generic: traffic_mngr: add pktio interface to odp_tm_egress_t struct

2016-06-20 Thread Balasubramanian Manoharan
Code changes for replacing odp_pktout_queue_t with odp_pktio_t in TM system

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 platform/linux-generic/include/odp_traffic_mngr_internal.h | 2 +-
 platform/linux-generic/odp_traffic_mngr.c  | 8 +++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/platform/linux-generic/include/odp_traffic_mngr_internal.h 
b/platform/linux-generic/include/odp_traffic_mngr_internal.h
index 3586889..3e13a0a 100644
--- a/platform/linux-generic/include/odp_traffic_mngr_internal.h
+++ b/platform/linux-generic/include/odp_traffic_mngr_internal.h
@@ -379,7 +379,7 @@ typedef struct {
tm_queue_info_t priority_info[ODP_TM_MAX_PRIORITIES];
 
tm_random_data_t tm_random_data;
-
+   odp_pktout_queue_t pktout;
uint64_t   current_time;
uint8_ttm_idx;
uint8_tfirst_enq;
diff --git a/platform/linux-generic/odp_traffic_mngr.c 
b/platform/linux-generic/odp_traffic_mngr.c
index 1fa2d27..54c3517 100644
--- a/platform/linux-generic/odp_traffic_mngr.c
+++ b/platform/linux-generic/odp_traffic_mngr.c
@@ -2106,7 +2106,7 @@ static void tm_send_pkt(tm_system_t *tm_system, uint32_t 
max_sends)
 
tm_system->egress_pkt_desc = EMPTY_PKT_DESC;
if (tm_system->egress.egress_kind == ODP_TM_EGRESS_PKT_IO)
-   odp_pktout_send(tm_system->egress.pktout, _pkt, 1);
+   odp_pktout_send(tm_system->pktout, _pkt, 1);
else if (tm_system->egress.egress_kind == ODP_TM_EGRESS_FN)
tm_system->egress.egress_fcn(odp_pkt);
else
@@ -2424,6 +2424,7 @@ int odp_tm_capabilities(odp_tm_capabilities_t 
capabilities[] ODP_UNUSED,
cap_ptr->max_tm_queues = ODP_TM_MAX_TM_QUEUES;
cap_ptr->max_levels= ODP_TM_MAX_LEVELS;
cap_ptr->tm_queue_shaper_supported = true;
+   cap_ptr->egress_fcn_supported  = true;
cap_ptr->tm_queue_wred_supported   = true;
cap_ptr->tm_queue_dual_slope_supported = true;
cap_ptr->vlan_marking_supported= true;
@@ -2605,6 +2606,7 @@ odp_tm_t odp_tm_create(const char*name,
tm_system_t *tm_system;
odp_bool_t create_fail;
odp_tm_t odp_tm;
+   odp_pktout_queue_t pktout;
uint32_t malloc_len, max_num_queues, max_queued_pkts, max_timers;
uint32_t max_tm_queues, max_sorted_lists;
int rc;
@@ -2625,6 +2627,10 @@ odp_tm_t odp_tm_create(const char*name,
return ODP_TM_INVALID;
}
 
+   if (odp_pktout_queue(egress->pktio, , 1) != 1)
+   return ODP_TM_INVALID;
+
+   tm_system->pktout = pktout;
tm_system->name_tbl_id = name_tbl_id;
max_tm_queues = requirements->max_tm_queues;
memcpy(_system->egress, egress, sizeof(odp_tm_egress_t));
-- 
1.9.1

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


[lng-odp] [PATCH/API-NEXT 1/3] api: traffic_mngr: Add pktio interface to odp_tm_egress_t struct

2016-06-20 Thread Balasubramanian Manoharan
Replaces pktio interface as input to TM system instead of
odp_pktout_queue_t.This creates an 1 to 1 mapping between a TM system
and pktio interface.

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 include/odp/api/spec/traffic_mngr.h | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/include/odp/api/spec/traffic_mngr.h 
b/include/odp/api/spec/traffic_mngr.h
index 83b89e7..8c4be4b 100644
--- a/include/odp/api/spec/traffic_mngr.h
+++ b/include/odp/api/spec/traffic_mngr.h
@@ -280,6 +280,12 @@ typedef struct {
 * expected to do. */
odp_bool_t tm_queue_shaper_supported;
 
+   /** egress_fcn_supported indicates whether the tm system supports
+   * egress function. It is an optional features used to receive the
+   * packet from the tm system and its performance might be limited.
+   */
+   odp_bool_t egress_fcn_supported;
+
/** tm_queue_wred_supported indicates that the tm_queues support some
 * form of Random Early Detection. */
odp_bool_t tm_queue_wred_supported;
@@ -467,7 +473,7 @@ typedef struct {
odp_tm_egress_kind_t egress_kind; /**< Union discriminator */
 
union {
-   odp_pktout_queue_t pktout;
+   odp_pktio_t pktio;
odp_tm_egress_fcn_t egress_fcn;
};
 } odp_tm_egress_t;
-- 
1.9.1

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


[lng-odp] [PATCH] doc: users-guide: add packet drop and error CoS documentation

2016-05-19 Thread Balasubramanian Manoharan
Adds documentation for packet drop policy and Error Class of service

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 doc/users-guide/users-guide-cls.adoc | 29 +++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/doc/users-guide/users-guide-cls.adoc 
b/doc/users-guide/users-guide-cls.adoc
index d2ba743..b158122 100644
--- a/doc/users-guide/users-guide-cls.adoc
+++ b/doc/users-guide/users-guide-cls.adoc
@@ -109,7 +109,32 @@ pools. Multiple odp_pktio instances (i.e., multiple ports) 
may each have their
 own default odp_cos, or may share a odp_cos with other ports, based on
 application requirements.
 
-Packet Classification
+=== Error packet handling
+
+Any Error class of service is assigned to ingress port using the function
+odp_pktio_error_cos_set(). All the packets received with error from this
+specific ingress port are assigned to this error class-of-service.
+At minimum this error class-of-service must have a queue and a buffer pool
+assigned to it on platforms that support multiple packet buffer pools.
+Multiple odp_pktio instances (_i.e.,_ multiple ports) may each have their own
+error class of service, or may share an error CoS with other ports, based on
+application requirements.
+
+=== Packet dropping
+
+Each class of service has a `drop_policy` configured during creation. The
+valid value are ODP_COS_DROP_POOL and ODP_COS_DROP_NEVER. If the `drop_policy`
+is set to ODP_COS_DROP_POOL then the packets assigned to the CoS follows the
+drop policy of the associated pool _i.e.,_ depending on the Random Early 
Discard
+or any other configuration of the pool the packet might get dropped. If the
+`drop_policy` is set to ODP_COS_DROP_NEVER then the drop policy of the pool is
+ignored and the packet is never dropped by the implementation.
+
+During creation of the Class of service if the pool or queue is set as INVALID
+using ODP_POOL_INVALID or ODP_QUEUE_INVALID field then the packets received in
+the specific CoS gets dropped by the implementation.
+
+=== Packet Classification
 
 For each odp_pktio port, the API allows the assignment of a class-of-service to
 a packet using one of  three methods:
@@ -136,7 +161,7 @@ destination or source port numbers, and appropriately 
assign these packets a
 class-of-service that maps to a higher priority queue, assuring voice packets a
 lower and bound latency.
 
-Packet meta data Elements
+=== Packet meta data Elements
 
 Here are the specific information elements that are stored within the
 packet meta data structure:
-- 
1.9.1

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


[lng-odp] [PATCHv2] doc: users-guide: add packet marking documentation

2016-05-16 Thread Balasubramanian Manoharan
Updates packet marking api documentation to traffic manager user guide

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
v2: document format update
 doc/users-guide/users-guide-tm.adoc | 73 +
 1 file changed, 73 insertions(+)

diff --git a/doc/users-guide/users-guide-tm.adoc 
b/doc/users-guide/users-guide-tm.adoc
index 12685b2..e02697b 100644
--- a/doc/users-guide/users-guide-tm.adoc
+++ b/doc/users-guide/users-guide-tm.adoc
@@ -263,6 +263,79 @@ settings for any TM system, though in most cases a TM 
system can (and should)
 be created/instantiated with smaller values, since lower values will often
 result in faster operation and/or less memory used.
 
+ Packet Marking
+
+The Packet Marking API is used to mark the packet based upon the final packet
+color assigned to it when it reaches the egress node.
+This is an optional feature and if available on the platform is used to reflect
+the packet color on IPv4/IPv6 DiffServ filed in accordance with 
https://www.ietf.org/rfc/rfc2474.txt[RFC 2474].
+There are three different packet marking fields supported they are,
+1). Assured forwarding in accordance with 
https://www.ietf.org/rfc/rfc2597.txt[RFC 2597], the DSCP is marked to
+set the packet Drop precedence in accordance with the color, i.e High Drop
+precedence for RED, Medium Drop precedence for YELLOW and leave the DSCP
+unchanged if the color is GREEN.
+2). Explicit Congestion Notification protocol per 
https://www.ietf.org/rfc/rfc3168.txt[RFC 3168], where a router
+encountering congestion can notify it by setting the lower 2 bits in
+DiffServ field to "11" Congestion Encountered code, which will ultimately
+reduce the transmission rate of the packet sender.
+3). In IEEE 802.1q VLAN tag header contains a DE - Drop Eligibility bit for
+marking a packet for Downstream switches, and is valid for Ethernet packet
+containing a VLAN tag.
+
+RFC 3168 is only valid for TCP packets whereas RFC 2597 is valid for IPv4/IPv6
+traffic.
+
+The values are set per color and hence the implementation may support these
+parameters only for a specific colors. marking_colors_supported field in
+capabilities structure can be used to check which colors are supported for
+marking.
+
+ Vlan Marking.
+
+This vlan marking is used to enable the drop eligibility on the packet
+based on the packet color. If drop eligibility is enabled then the
+implementation will set the one bit VLAN Drop Eligibility Indicator (DEI)
+field (but only for packets that already carry a VLAN tag) of a packet based
+upon the final packet color assigned to the packet when it reaches the egress
+node.  When drop_eligible_enabled is false, then the given color has
+no effect on the VLAN fields.  See IEEE 802.1q for more details.
+`vlan_marking_supported` boolean in capability structure indicates whether this
+feature is supported by the implementation.
+
+ Explicit Congestion Notification Marking.
+
+The `odp_tm_ecn_marking()` function allows one to configure the TM
+egress so that the two bit ECN subfield of the eight bit TOS field of an
+IPv4 packet OR the eight bit Traffic Class (TC) field of an IPv6 packet can be
+selectively modified based upon the final color assigned to the packet when it
+reaches the egress.  Note that the IPv4 header checksum will be updated -
+but only if the IPv4 TOS field actually changes as a result of this
+setting or the `odp_tm_drop_prec_marking()` setting.  For IPv6, since there is
+no header checksum, nothing needs to be done. If ECN is enabled for a
+particular color then ECN subfield will be set to _ECN_CE_  _i.e.,_ congestion
+experienced.
+`ecn_marking_supported` boolean in capability structure indicates whether this
+feature is supported by the implementation.
+
+ Drop Precedence Marking.
+
+The Drop precedence marking allows one to configure the TM
+egress to support Assured forwarding in accordance with 
https://www.ietf.org/rfc/rfc2597.txt[RFC 2597].
+The Drop Precedence bits are contained within the six bit Differentiated
+Services Code Point subfield of the IPv4 TOS field or the IPv6 Traffic
+Class (TC) field.  Specifically the Drop Precedence sub-subfield can be
+accessed with a DSCP bit mask of 0x06.  When enabled for a given color,
+these two bits will be set to Medium Drop Precedence (value 0x4) if the
+color is ODP_PACKET_YELLOW, set to High Drop Precedence (value 0x6) if
+the color is ODP_PACKET_RED.
+
+Note that the IPv4 header checksum will be updated - but only if the
+IPv4 TOS field actually changes as a result of this setting or the
+`odp_tm_ecn_marking()` setting.  For IPv6, since there is no header checksum,
+nothing else needs to be done.
+`drop_prec_marking_supported` boolean in capability structure indicates whether
+this feature is supported by the implementation.
+
 === Examples
 
 .Create a tm_node chain for two nodes and associate the scheduler
-- 
1.9.1

___

[lng-odp] [PATCH] fix: classification: uninitialized pmr param value

2016-05-13 Thread Balasubramanian Manoharan
Fix memory leaked caused by uninitialized pmr param struct

Fixes: https://bugs.linaro.org/show_bug.cgi?id=2227
 
Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 test/validation/classification/odp_classification_test_pmr.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/test/validation/classification/odp_classification_test_pmr.c 
b/test/validation/classification/odp_classification_test_pmr.c
index 344503a..7c7d07e 100644
--- a/test/validation/classification/odp_classification_test_pmr.c
+++ b/test/validation/classification/odp_classification_test_pmr.c
@@ -250,6 +250,7 @@ void classification_test_pmr_term_tcp_sport(void)
cos = odp_cls_cos_create(cosname, _param);
CU_ASSERT_FATAL(cos != ODP_COS_INVALID);
 
+   odp_cls_pmr_param_init(_param);
pmr_param.term = ODP_PMR_TCP_SPORT;
pmr_param.match.value = 
pmr_param.match.mask = 
@@ -474,6 +475,7 @@ void classification_test_pmr_term_udp_sport(void)
cos = odp_cls_cos_create(cosname, _param);
CU_ASSERT_FATAL(cos != ODP_COS_INVALID);
 
+   odp_cls_pmr_param_init(_param);
pmr_param.term = ODP_PMR_UDP_SPORT;
pmr_param.match.value = 
pmr_param.match.mask = 
@@ -690,6 +692,7 @@ void classification_test_pmr_term_dmac(void)
cos = odp_cls_cos_create(cosname, _param);
CU_ASSERT_FATAL(cos != ODP_COS_INVALID);
 
+   odp_cls_pmr_param_init(_param);
pmr_param.term = ODP_PMR_DMAC;
pmr_param.match.value = 
pmr_param.match.mask = 
-- 
1.9.1

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


[lng-odp] [PATCH] doc: users-guide: add packet marking documentation

2016-05-12 Thread Balasubramanian Manoharan
Updates packet marking api documentation to traffic manager user guide

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 doc/users-guide/users-guide-tm.adoc | 73 +
 1 file changed, 73 insertions(+)

diff --git a/doc/users-guide/users-guide-tm.adoc 
b/doc/users-guide/users-guide-tm.adoc
index 12685b2..06c 100644
--- a/doc/users-guide/users-guide-tm.adoc
+++ b/doc/users-guide/users-guide-tm.adoc
@@ -263,6 +263,79 @@ settings for any TM system, though in most cases a TM 
system can (and should)
 be created/instantiated with smaller values, since lower values will often
 result in faster operation and/or less memory used.
 
+ Packet Marking
+
+Packet Marking API is used to mark the packet based upon the final packet color
+assigned to the packet when it reaches the egress node.
+This is an optional feature and if available on the platform is used to reflect
+the packet color on IPv4/IPv6 DiffServ filed in accordance with RFC 2474.
+There are three different packet marking fields supported they are,
+1). Assured forwarding in accordance with RFC 2597, the DSCP is marked to
+set the packet Drop precedence in accordance with the color, i.e High Drop
+precedence for RED, Medium Drop precedence for YELLOW and leave the DSCP
+unchangesd if the color is GREEN.
+2). Explicit Congestion Notification protocol per RFC 3168, where a router
+encountering congestion can notifiy it by setting the lower 2 bits in
+DiffServ field to "11" Congestion Encountered code, which will ultimately
+reduce the transmission rate of the packet sender.
+3). In IEEE 802.1q VLAN tag header contains a DE - Drop Eligibility bit for
+marking a packet for Downstream switches, and is valid for Ethernet packet
+containing a VLAN tag.
+
+RFC 3168 is only valid for TCP packets whereas RFC 2597 is valid for IPv4/IPv6
+traffic.
+
+The values are set per color and hence the implementation may support these
+parameters only for a specific colors. marking_colors_supported field in
+capabilities structure can be used to check which colors are supported for
+marking.
+
+Vlan Marking.
+
+This vlan marking is used to enable the drop eligibility on the packet
+based on the packet color. If drop eligibility is enabled then the
+implementation will set the one bit VLAN Drop Eligibility Indicator (DEI)
+field (but only for pkts that already carry a VLAN tag) of a packet based
+upon the final pkt color assigned to the pkt when it reaches the egress
+node.  When drop_eligible_enabled is false, then the given color has
+no effect on the VLAN fields.  See IEEE 802.1q for more details.
+vlan_marking_supported boolean in capability structure indicates whether this
+feature is supported by the implementation.
+
+Explicit Congestion Notification Marking.
+
+The odp_tm_ecn_marking() function allows one to configure the TM
+egress so that the two bit ECN subfield of the eight bit TOS field of an
+IPv4 pkt OR the eight bit Traffic Class (TC) field of an IPv6 pkt can be
+selectively modified based upon the final color assigned to the pkt when it
+reaches the egress.  Note that the IPv4 header checksum will be updated -
+but only if the IPv4 TOS field actually changes as a result of this
+setting or the odp_tm_drop_prec_marking setting.  For IPv6, since there is
+no header checksum, nothing needs to be done. If ECN is enabled for a
+particular color then ECN subfield will be set to ECN_CE ie congestion
+experienced.
+ecn_marking_supported boolean in capability structure indicates whether this
+feature is supported by the implementation.
+
+Drop Precedence Marking.
+
+The Drop precedence marking allows one to configure the TM
+egress to support Assured forwarding in accordance with RFC 2597.
+The Drop Precedence bits are contained within the six bit Differentiated
+Services Code Point subfield of the IPv4 TOS field or the IPv6 Traffic
+Class (TC) field.  Specifically the Drop Precedence sub-subfield can be
+accessed with a DSCP bit mask of 0x06.  When enabled for a given color,
+these two bits will be set to Medium Drop Precedence (value 0x4) if the
+color is ODP_PACKET_YELLOW, set to High Drop Precedence (value 0x6) if
+the color is ODP_PACKET_RED.
+
+Note that the IPv4 header checksum will be updated - but only if the
+IPv4 TOS field actually changes as a result of this setting or the
+odp_tm_ecn_marking setting.  For IPv6, since there is no header checksum,
+nothing else needs to be done.
+drop_prec_marking_supported boolean in capability structure indicates whether
+this feature is supported by the implementation.
+
 === Examples
 
 .Create a tm_node chain for two nodes and associate the scheduler
-- 
1.9.1

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


[lng-odp] [PATCH API-NEXTv2 2/2] linux-generic: pktio: support for loopback mode

2016-04-26 Thread Balasubramanian Manoharan
Implements interface loopback mode

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 platform/linux-generic/odp_packet_io.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/platform/linux-generic/odp_packet_io.c 
b/platform/linux-generic/odp_packet_io.c
index 148adc9..4378335 100644
--- a/platform/linux-generic/odp_packet_io.c
+++ b/platform/linux-generic/odp_packet_io.c
@@ -410,6 +410,11 @@ int odp_pktio_config(odp_pktio_t id, const 
odp_pktio_config_t *config)
return -1;
}
 
+   if (config->enable_loop && !capa.loop_supported) {
+   ODP_ERR("Loopback mode not supported\n");
+   return -1;
+   }
+
lock_entry(entry);
if (entry->s.state == STATE_STARTED) {
unlock_entry(entry);
-- 
1.9.1

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


[lng-odp] [PATCH API-NEXTv2 1/2] api: pktio: Adds interface loopback mode

2016-04-26 Thread Balasubramanian Manoharan
Adds loopback interface mode as a configurable parameter in pktio
configuration parameter. Support for loopback is an optional feature and
should be checked in the interface capability before enabling the same.

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
v2: Incorporates review comments from Petri
 include/odp/api/spec/packet_io.h | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/include/odp/api/spec/packet_io.h b/include/odp/api/spec/packet_io.h
index 7c29176..1899a4f 100644
--- a/include/odp/api/spec/packet_io.h
+++ b/include/odp/api/spec/packet_io.h
@@ -362,6 +362,14 @@ typedef struct odp_pktio_config_t {
 *  Default value for all bits is zero. */
odp_pktout_config_opt_t pktout;
 
+   /** Interface loopback mode
+*
+* In this mode the packets sent out through the interface is
+* looped back to input of the same interface. Supporting loopback mode
+* is an optional feature per interface and should be queried in the
+* interface capability before enabling the same. */
+   odp_bool_t enable_loop;
+
 } odp_pktio_config_t;
 
 /**
@@ -399,6 +407,12 @@ typedef struct odp_pktio_capability_t {
 * A bit set to one indicates a supported operation. All other bits are
 * set to zero. */
odp_pktio_set_op_t set_op;
+
+   /** Support of Loopback mode
+*
+* A boolean to denote whether loop back mode is supported on this
+* specific interface. */
+   odp_bool_t loop_supported;
 } odp_pktio_capability_t;
 
 /**
-- 
1.9.1

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


[lng-odp] [API-NEXT 2/2] linux-generic: pktio: support for loopback mode

2016-04-26 Thread Balasubramanian Manoharan
Implements interface loopback mode

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 platform/linux-generic/odp_packet_io.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/platform/linux-generic/odp_packet_io.c 
b/platform/linux-generic/odp_packet_io.c
index 148adc9..4378335 100644
--- a/platform/linux-generic/odp_packet_io.c
+++ b/platform/linux-generic/odp_packet_io.c
@@ -410,6 +410,11 @@ int odp_pktio_config(odp_pktio_t id, const 
odp_pktio_config_t *config)
return -1;
}
 
+   if (config->enable_loop && !capa.loop_supported) {
+   ODP_ERR("Loopback mode not supported\n");
+   return -1;
+   }
+
lock_entry(entry);
if (entry->s.state == STATE_STARTED) {
unlock_entry(entry);
-- 
1.9.1

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


[lng-odp] [API-NEXT 1/2] api: pktio: Adds interface loopback mode

2016-04-26 Thread Balasubramanian Manoharan
Adds loopback interface mode as a configurable parameter in
odp_pktio_config_t structure. Support for loopback is an optional feature
and should be checked in the interface capability before enabling the same.

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 include/odp/api/spec/packet_io.h | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/include/odp/api/spec/packet_io.h b/include/odp/api/spec/packet_io.h
index 7c29176..76a9d5d 100644
--- a/include/odp/api/spec/packet_io.h
+++ b/include/odp/api/spec/packet_io.h
@@ -362,6 +362,14 @@ typedef struct odp_pktio_config_t {
 *  Default value for all bits is zero. */
odp_pktout_config_opt_t pktout;
 
+   /** Interface loopback mode
+*
+* In this mode the packets sent out through the interface is
+* looped back to the system. Supporting loopback mode is an
+* optional feature per interface and should be queries in the
+* interface capability before enabling the same. */
+   odp_bool_t enable_loop;
+
 } odp_pktio_config_t;
 
 /**
@@ -399,6 +407,12 @@ typedef struct odp_pktio_capability_t {
 * A bit set to one indicates a supported operation. All other bits are
 * set to zero. */
odp_pktio_set_op_t set_op;
+
+   /** Support of Loopback mode
+*
+* A boolean to denote whether loop back mode is supported on this
+* specific interface. */
+   odp_bool_t loop_supported;
 } odp_pktio_capability_t;
 
 /**
-- 
1.9.1

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


[lng-odp] [API-NEXTv4 3/4] validation: classification: incorporates capability and PMR range

2016-04-25 Thread Balasubramanian Manoharan
Adds validation suite for classification capability and PMR range

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 test/validation/classification/classification.h|   2 -
 .../classification/odp_classification_basic.c  |  24 ++--
 .../classification/odp_classification_common.c |  19 +--
 .../classification/odp_classification_test_pmr.c   | 127 +++--
 .../classification/odp_classification_tests.c  |  85 ++
 .../classification/odp_classification_testsuites.h |   2 +-
 6 files changed, 129 insertions(+), 130 deletions(-)

diff --git a/test/validation/classification/classification.h 
b/test/validation/classification/classification.h
index 8645ea5..1c442ce 100644
--- a/test/validation/classification/classification.h
+++ b/test/validation/classification/classification.h
@@ -67,8 +67,6 @@ void classification_test_pmr_composite_destroy(void);
 
 void classification_test_pktio_set_skip(void);
 void classification_test_pktio_set_headroom(void);
-void classification_test_pmr_terms_avail(void);
-void classification_test_pmr_terms_cap(void);
 void classification_test_pktio_configure(void);
 void classification_test_pktio_test(void);
 
diff --git a/test/validation/classification/odp_classification_basic.c 
b/test/validation/classification/odp_classification_basic.c
index 0ad6581..372377d 100644
--- a/test/validation/classification/odp_classification_basic.c
+++ b/test/validation/classification/odp_classification_basic.c
@@ -75,7 +75,7 @@ void classification_test_create_pmr_match(void)
uint16_t val;
uint16_t mask;
int retval;
-   odp_pmr_match_t match;
+   odp_pmr_param_t pmr_param;
odp_cos_t default_cos;
odp_cos_t cos;
odp_queue_t default_queue;
@@ -111,12 +111,14 @@ void classification_test_create_pmr_match(void)
 
val = 1024;
mask = 0x;
-   match.term = find_first_supported_l3_pmr();
-   match.val = 
-   match.mask = 
-   match.val_sz = sizeof(val);
-
-   pmr = odp_cls_pmr_create(, 1, default_cos, cos);
+   odp_cls_pmr_param_init(_param);
+   pmr_param.term = find_first_supported_l3_pmr();
+   pmr_param.range_term = false;
+   pmr_param.match.value = 
+   pmr_param.match.mask = 
+   pmr_param.val_sz = sizeof(val);
+
+   pmr = odp_cls_pmr_create(_param, 1, default_cos, cos);
CU_ASSERT(pmr != ODP_PMR_INVAL);
CU_ASSERT(odp_pmr_to_u64(pmr) != odp_pmr_to_u64(ODP_PMR_INVAL));
/* destroy the created PMR */
@@ -254,7 +256,7 @@ void classification_test_pmr_composite_create(void)
 {
odp_pmr_t pmr_composite;
int retval;
-   odp_pmr_match_t pmr_terms[PMR_SET_NUM];
+   odp_pmr_param_t pmr_terms[PMR_SET_NUM];
odp_cos_t default_cos;
odp_cos_t cos;
odp_queue_t default_queue;
@@ -292,9 +294,11 @@ void classification_test_pmr_composite_create(void)
CU_ASSERT(cos != ODP_COS_INVALID);
 
for (i = 0; i < PMR_SET_NUM; i++) {
+   odp_cls_pmr_param_init(_terms[i]);
pmr_terms[i].term = ODP_PMR_TCP_DPORT;
-   pmr_terms[i].val = 
-   pmr_terms[i].mask = 
+   pmr_terms[i].match.value = 
+   pmr_terms[i].range_term = false;
+   pmr_terms[i].match.mask = 
pmr_terms[i].val_sz = sizeof(val);
}
 
diff --git a/test/validation/classification/odp_classification_common.c 
b/test/validation/classification/odp_classification_common.c
index e06d0a9..09ec191 100644
--- a/test/validation/classification/odp_classification_common.c
+++ b/test/validation/classification/odp_classification_common.c
@@ -338,20 +338,21 @@ odp_packet_t create_packet_len(odp_pool_t pool, bool vlan,
return pkt;
 }
 
-odp_pmr_term_t find_first_supported_l3_pmr(void)
+odp_cls_pmr_term_t find_first_supported_l3_pmr(void)
 {
-   unsigned long long cap;
-   odp_pmr_term_t term = ODP_PMR_TCP_DPORT;
+   odp_cls_pmr_term_t term = ODP_PMR_TCP_DPORT;
+   odp_cls_capability_t capability;
+
+   odp_cls_capability();
 
/* choose supported PMR */
-   cap = odp_pmr_terms_cap();
-   if (cap & (1 << ODP_PMR_UDP_SPORT))
+   if (capability.supported_terms.bit.udp_sport)
term = ODP_PMR_UDP_SPORT;
-   else if (cap & (1 << ODP_PMR_UDP_DPORT))
+   else if (capability.supported_terms.bit.udp_dport)
term = ODP_PMR_UDP_DPORT;
-   else if (cap & (1 << ODP_PMR_TCP_SPORT))
+   else if (capability.supported_terms.bit.tcp_sport)
term = ODP_PMR_TCP_SPORT;
-   else if (cap & (1 << ODP_PMR_TCP_DPORT))
+   else if (capability.supported_terms.bit.tcp_dport)
term = ODP_PMR_TCP_DPORT;
else
CU_FAIL("Implementations doesn't support any TCP/UDP PMR");
@@ -363,7 +364,7 @@ int set_first_supported_pmr_port(odp_

[lng-odp] [API-NEXTv4 2/4] linux-generic: classification: Implements capability and PMR range

2016-04-25 Thread Balasubramanian Manoharan
Implements classification capability and PMR range functionality feature.

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 .../include/odp_classification_datamodel.h | 19 -
 .../include/odp_classification_inlines.h   | 24 +++---
 platform/linux-generic/odp_classification.c| 92 +-
 3 files changed, 82 insertions(+), 53 deletions(-)

diff --git a/platform/linux-generic/include/odp_classification_datamodel.h 
b/platform/linux-generic/include/odp_classification_datamodel.h
index 63f3ec6..dc2190d 100644
--- a/platform/linux-generic/include/odp_classification_datamodel.h
+++ b/platform/linux-generic/include/odp_classification_datamodel.h
@@ -52,9 +52,22 @@ Stores the Term and Value mapping for a PMR.
 The maximum size of value currently supported in 64 bits
 **/
 typedef struct pmr_term_value {
-   odp_pmr_term_t  term;   /* PMR Term */
-   uint64_tval;/**< Value to be matched */
-   uint64_tmask;   /**< Masked set of bits to be matched */
+   odp_cls_pmr_term_t  term;   /* PMR Term */
+   odp_bool_t  range_term; /* True if range, false if match */
+   union {
+   struct {
+   /** Value to be matched */
+   uint64_tvalue;
+   /** Masked set of bits to be matched */
+   uint64_tmask;
+   } match;
+   struct {
+   /** Start value of the range */
+   uint64_tval_start;
+   /** End value of the range */
+   uint64_tval_end;
+   } range;
+   };
uint32_toffset; /**< Offset if term == ODP_PMR_CUSTOM_FRAME */
uint32_tval_sz; /**< Size of the value to be matched */
 } pmr_term_value_t;
diff --git a/platform/linux-generic/include/odp_classification_inlines.h 
b/platform/linux-generic/include/odp_classification_inlines.h
index bac5b48..b8b04ce 100644
--- a/platform/linux-generic/include/odp_classification_inlines.h
+++ b/platform/linux-generic/include/odp_classification_inlines.h
@@ -34,8 +34,8 @@ These following functions return 1 on success and 0 on failure
 static inline int verify_pmr_packet_len(odp_packet_hdr_t *pkt_hdr,
pmr_term_value_t *term_value)
 {
-   if (term_value->val == (packet_len(pkt_hdr) &
-term_value->mask))
+   if (term_value->match.value == (packet_len(pkt_hdr) &
+term_value->match.mask))
return 1;
 
return 0;
@@ -51,7 +51,7 @@ static inline int verify_pmr_ip_proto(const uint8_t *pkt_addr,
return 0;
ip = (const odph_ipv4hdr_t *)(pkt_addr + pkt_hdr->l3_offset);
proto = ip->proto;
-   if (term_value->val == (proto & term_value->mask))
+   if (term_value->match.value == (proto & term_value->match.mask))
return 1;
 
return 0;
@@ -67,7 +67,7 @@ static inline int verify_pmr_ipv4_saddr(const uint8_t 
*pkt_addr,
return 0;
ip = (const odph_ipv4hdr_t *)(pkt_addr + pkt_hdr->l3_offset);
ipaddr = odp_be_to_cpu_32(ip->src_addr);
-   if (term_value->val == (ipaddr & term_value->mask))
+   if (term_value->match.value == (ipaddr & term_value->match.mask))
return 1;
 
return 0;
@@ -83,7 +83,7 @@ static inline int verify_pmr_ipv4_daddr(const uint8_t 
*pkt_addr,
return 0;
ip = (const odph_ipv4hdr_t *)(pkt_addr + pkt_hdr->l3_offset);
ipaddr = odp_be_to_cpu_32(ip->dst_addr);
-   if (term_value->val == (ipaddr & term_value->mask))
+   if (term_value->match.value == (ipaddr & term_value->match.mask))
return 1;
 
return 0;
@@ -99,7 +99,7 @@ static inline int verify_pmr_tcp_sport(const uint8_t 
*pkt_addr,
return 0;
tcp = (const odph_tcphdr_t *)(pkt_addr + pkt_hdr->l4_offset);
sport = odp_be_to_cpu_16(tcp->src_port);
-   if (term_value->val == (sport & term_value->mask))
+   if (term_value->match.value == (sport & term_value->match.mask))
return 1;
 
return 0;
@@ -115,7 +115,7 @@ static inline int verify_pmr_tcp_dport(const uint8_t 
*pkt_addr,
return 0;
tcp = (const odph_tcphdr_t *)(pkt_addr + pkt_hdr->l4_offset);
dport = odp_be_to_cpu_16(tcp->dst_port);
-   if (term_value->val == (dport & term_value->mask))
+   if (term_value->match.value == (dport & term_value->match.mask))
return 1;
 
return 0;
@@ -131,7 +131,7 @@ static inline int verify_pmr_udp_dport(const uint8_t 
*pkt_addr,
  

[lng-odp] [API-NEXTv4 4/4] example: classifier: incorporates capability and PMR range

2016-04-25 Thread Balasubramanian Manoharan
Modifies the classifier example to support classification capability and
PMR range functionality.

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 example/classifier/odp_classifier.c | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/example/classifier/odp_classifier.c 
b/example/classifier/odp_classifier.c
index 612ce22..ed2c4b3 100644
--- a/example/classifier/odp_classifier.c
+++ b/example/classifier/odp_classifier.c
@@ -56,7 +56,7 @@ typedef struct {
odp_atomic_u64_t pool_pkt_count; /**< count of received packets */
char cos_name[ODP_COS_NAME_LEN];/**< cos name */
struct {
-   odp_pmr_term_t term;/**< odp pmr term value */
+   odp_cls_pmr_term_t term;/**< odp pmr term value */
uint64_t val;   /**< pmr term value */
uint64_t mask;  /**< pmr term mask */
uint32_t val_sz;/**< size of the pmr term */
@@ -89,7 +89,7 @@ static void print_info(char *progname, appl_args_t 
*appl_args);
 static void usage(char *progname);
 static void configure_cos(odp_cos_t default_cos, appl_args_t *args);
 static odp_cos_t configure_default_cos(odp_pktio_t pktio, appl_args_t *args);
-static int convert_str_to_pmr_enum(char *token, odp_pmr_term_t *term,
+static int convert_str_to_pmr_enum(char *token, odp_cls_pmr_term_t *term,
   uint32_t *offset);
 static int parse_pmr_policy(appl_args_t *appl_args, char *argv[], char 
*optarg);
 
@@ -393,6 +393,7 @@ static void configure_cos(odp_cos_t default_cos, 
appl_args_t *args)
char pool_name[ODP_POOL_NAME_LEN];
odp_pool_param_t pool_params;
odp_cls_cos_param_t cls_param;
+   odp_pmr_param_t pmr_param;
int i;
global_statistics *stats;
odp_queue_param_t qparam;
@@ -438,15 +439,14 @@ static void configure_cos(odp_cos_t default_cos, 
appl_args_t *args)
cls_param.drop_policy = ODP_COS_DROP_POOL;
stats->cos = odp_cls_cos_create(cos_name, _param);
 
-   const odp_pmr_match_t match = {
-   .term = stats->rule.term,
-   .val = >rule.val,
-   .mask = >rule.mask,
-   .val_sz = stats->rule.val_sz,
-   .offset = stats->rule.offset
-   };
+   odp_cls_pmr_param_init(_param);
+   pmr_param.term = stats->rule.term;
+   pmr_param.match.value = >rule.val;
+   pmr_param.match.mask = >rule.mask;
+   pmr_param.val_sz = stats->rule.val_sz;
+   pmr_param.offset = stats->rule.offset;
 
-   stats->pmr = odp_cls_pmr_create(, 1, default_cos,
+   stats->pmr = odp_cls_pmr_create(_param, 1, default_cos,
stats->cos);
if (stats->pmr == ODP_PMR_INVAL) {
EXAMPLE_ERR("odp_pktio_pmr_cos failed");
@@ -665,7 +665,7 @@ static void swap_pkt_addrs(odp_packet_t pkt_tbl[], unsigned 
len)
}
 }
 
-static int convert_str_to_pmr_enum(char *token, odp_pmr_term_t *term,
+static int convert_str_to_pmr_enum(char *token, odp_cls_pmr_term_t *term,
   uint32_t *offset)
 {
if (NULL == token)
@@ -691,7 +691,7 @@ static int parse_pmr_policy(appl_args_t *appl_args, char 
*argv[], char *optarg)
int policy_count;
char *token;
size_t len;
-   odp_pmr_term_t term;
+   odp_cls_pmr_term_t term;
global_statistics *stats;
char *pmr_str;
uint32_t offset;
@@ -904,9 +904,9 @@ static void usage(char *progname)
"\n"
"Mandatory OPTIONS:\n"
"  -i, --interface Eth interface\n"
-   "  -p, --policy 
[|]:::\n"
+   "  -p, --policy 
[|]:::\n"
"\n"
-   "   Packet Matching Rule defined 
with odp_pmr_term_t "
+   "   Packet Matching Rule defined 
with odp_cls_pmr_term_t "
"for the policy\n"
"   Absolute offset in bytes from 
frame start to define a "
"ODP_PMR_CUSTOM_FRAME Packet Matching Rule for the 
policy\n"
-- 
1.9.1

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


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

2016-04-25 Thread Balasubramanian Manoharan
Adds classification capability structure and PMR range functionality.
odp_cls_capability_t structure defines system level classification
capability.

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
v4: fix doxygen error
v3: Change odp_pmr_term_t bitfield to odp_pmr_terms_t
Incorporates review comments from  Bill

 include/odp/api/spec/classification.h | 149 --
 1 file changed, 126 insertions(+), 23 deletions(-)

diff --git a/include/odp/api/spec/classification.h 
b/include/odp/api/spec/classification.h
index 076b3de..0a8d1dd 100644
--- a/include/odp/api/spec/classification.h
+++ b/include/odp/api/spec/classification.h
@@ -55,6 +55,82 @@ extern "C" {
  */
 
 /**
+ * Supported PMR term values
+ *
+ * Supported Packet Matching Rule term values in a bit field structure.
+ */
+typedef union odp_cls_pmr_terms_t {
+   /** Packet Matching Rule term fields */
+   struct {
+   /** Total length of received packet */
+   uint64_tlen:1;
+   /** Initial (outer) Ethertype only */
+   uint64_tethtype_0:1;
+   /** Ethertype of most inner VLAN tag */
+   uint64_tethtype_x:1;
+   /** First VLAN ID (outer) */
+   uint64_tvlan_id_0:1;
+   /** Last VLAN ID (inner) */
+   uint64_tvlan_id_x:1;
+   /** destination MAC address */
+   uint64_tdmac:1;
+   /** IP Protocol or IPv6 Next Header */
+   uint64_tip_proto:1;
+   /** Destination UDP port, implies IPPROTO=17 */
+   uint64_tudp_dport:1;
+   /** Destination TCP port implies IPPROTO=6 */
+   uint64_ttcp_dport:1;
+   /** Source UDP Port */
+   uint64_tudp_sport:1;
+   /** Source TCP port */
+   uint64_ttcp_sport:1;
+   /** Source IP address */
+   uint64_tsip_addr:1;
+   /** Destination IP address */
+   uint64_tdip_addr:1;
+   /** Source IP address */
+   uint64_tsip6_addr:1;
+   /** Destination IP address */
+   uint64_tdip6_addr:1;
+   /** IPsec session identifier */
+   uint64_tipsec_spi:1;
+   /** NVGRE/VXLAN network identifier */
+   uint64_tld_vni:1;
+   /** Custom match rule, offset from start of
+* frame. The match is defined by the offset, the
+* expected value, and its size.
+*/
+   uint64_tcustom_frame:1;
+
+   } bit;
+   /** All bits of the bit field structure */
+   uint64_t all_bits;
+} odp_cls_pmr_terms_t;
+
+/**
+ * Classification capabilities
+ * This capability structure defines system level classfication capability
+ */
+typedef struct odp_cls_capability_t {
+   /** PMR terms supported by the classifier
+* A bit mask of one bit for each of odp_pmr_term_t
+*/
+   odp_cls_pmr_terms_t supported_terms;
+
+   /** Maximum number of PMR terms */
+   unsigned max_pmr_terms;
+
+   /** Number of PMR terms available for use now */
+   unsigned available_pmr_terms;
+
+   /** Maximum number of CoS supported */
+   unsigned max_cos;
+
+   /** A Boolean to denote support of PMR range */
+   odp_bool_t pmr_range_supported;
+} odp_cls_capability_t;
+
+/**
  * class of service packet drop policies
  */
 typedef enum {
@@ -103,6 +179,18 @@ typedef struct odp_cls_cos_param {
 void odp_cls_cos_param_init(odp_cls_cos_param_t *param);
 
 /**
+ * Query classification capabilities
+ *
+ * Outputs classification capabilities on success.
+ *
+ * @param[out] capability  Pointer to classification capability structure.
+ *
+ * @retval 0 on success
+ * @retval <0 on failure
+ */
+int odp_cls_capability(odp_cls_capability_t *capability);
+
+/**
  * Create a class-of-service
  *
  * @param  nameString intended for debugging purposes.
@@ -265,20 +353,49 @@ typedef enum {
 
/** Inner header may repeat above values with this offset */
ODP_PMR_INNER_HDR_OFF = 32
-} odp_pmr_term_t;
+} odp_cls_pmr_term_t;
 
 /**
- * Following structure is used to define a packet matching rule
+ * Packet Matching Rule parameter structure
  */
-typedef struct odp_pmr_match_t {
-   odp_pmr_term_t  term;   /**< PMR term value to be matched */
-   const void  *val;   /**< Value to be matched */
-   const void  *mask;  /**< Masked set of bits to be matched */
+typedef struct odp_pmr_param_t {
+   odp_cls_pmr_term_t  term;   /**< Packet Macthing Rule term */
+
+   /** True if the value is range and false if match */
+   odp_bool_t range_term;
+
+  

[lng-odp] [API-NEXTv3 4/4] example: classifier: incorporates capability and PMR range

2016-04-25 Thread Balasubramanian Manoharan
Modifies the classifier example to support classification capability and
PMR range functionality.

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
Reviewed-by: Bill Fischofer <bill.fischo...@linaro.org>
---
 example/classifier/odp_classifier.c | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/example/classifier/odp_classifier.c 
b/example/classifier/odp_classifier.c
index 612ce22..ed2c4b3 100644
--- a/example/classifier/odp_classifier.c
+++ b/example/classifier/odp_classifier.c
@@ -56,7 +56,7 @@ typedef struct {
odp_atomic_u64_t pool_pkt_count; /**< count of received packets */
char cos_name[ODP_COS_NAME_LEN];/**< cos name */
struct {
-   odp_pmr_term_t term;/**< odp pmr term value */
+   odp_cls_pmr_term_t term;/**< odp pmr term value */
uint64_t val;   /**< pmr term value */
uint64_t mask;  /**< pmr term mask */
uint32_t val_sz;/**< size of the pmr term */
@@ -89,7 +89,7 @@ static void print_info(char *progname, appl_args_t 
*appl_args);
 static void usage(char *progname);
 static void configure_cos(odp_cos_t default_cos, appl_args_t *args);
 static odp_cos_t configure_default_cos(odp_pktio_t pktio, appl_args_t *args);
-static int convert_str_to_pmr_enum(char *token, odp_pmr_term_t *term,
+static int convert_str_to_pmr_enum(char *token, odp_cls_pmr_term_t *term,
   uint32_t *offset);
 static int parse_pmr_policy(appl_args_t *appl_args, char *argv[], char 
*optarg);
 
@@ -393,6 +393,7 @@ static void configure_cos(odp_cos_t default_cos, 
appl_args_t *args)
char pool_name[ODP_POOL_NAME_LEN];
odp_pool_param_t pool_params;
odp_cls_cos_param_t cls_param;
+   odp_pmr_param_t pmr_param;
int i;
global_statistics *stats;
odp_queue_param_t qparam;
@@ -438,15 +439,14 @@ static void configure_cos(odp_cos_t default_cos, 
appl_args_t *args)
cls_param.drop_policy = ODP_COS_DROP_POOL;
stats->cos = odp_cls_cos_create(cos_name, _param);
 
-   const odp_pmr_match_t match = {
-   .term = stats->rule.term,
-   .val = >rule.val,
-   .mask = >rule.mask,
-   .val_sz = stats->rule.val_sz,
-   .offset = stats->rule.offset
-   };
+   odp_cls_pmr_param_init(_param);
+   pmr_param.term = stats->rule.term;
+   pmr_param.match.value = >rule.val;
+   pmr_param.match.mask = >rule.mask;
+   pmr_param.val_sz = stats->rule.val_sz;
+   pmr_param.offset = stats->rule.offset;
 
-   stats->pmr = odp_cls_pmr_create(, 1, default_cos,
+   stats->pmr = odp_cls_pmr_create(_param, 1, default_cos,
stats->cos);
if (stats->pmr == ODP_PMR_INVAL) {
EXAMPLE_ERR("odp_pktio_pmr_cos failed");
@@ -665,7 +665,7 @@ static void swap_pkt_addrs(odp_packet_t pkt_tbl[], unsigned 
len)
}
 }
 
-static int convert_str_to_pmr_enum(char *token, odp_pmr_term_t *term,
+static int convert_str_to_pmr_enum(char *token, odp_cls_pmr_term_t *term,
   uint32_t *offset)
 {
if (NULL == token)
@@ -691,7 +691,7 @@ static int parse_pmr_policy(appl_args_t *appl_args, char 
*argv[], char *optarg)
int policy_count;
char *token;
size_t len;
-   odp_pmr_term_t term;
+   odp_cls_pmr_term_t term;
global_statistics *stats;
char *pmr_str;
uint32_t offset;
@@ -904,9 +904,9 @@ static void usage(char *progname)
"\n"
"Mandatory OPTIONS:\n"
"  -i, --interface Eth interface\n"
-   "  -p, --policy 
[|]:::\n"
+   "  -p, --policy 
[|]:::\n"
"\n"
-   "   Packet Matching Rule defined 
with odp_pmr_term_t "
+   "   Packet Matching Rule defined 
with odp_cls_pmr_term_t "
"for the policy\n"
"   Absolute offset in bytes from 
frame start to define a "
"ODP_PMR_CUSTOM_FRAME Packet Matching Rule for the 
policy\n"
-- 
1.9.1

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


[lng-odp] [API-NEXTv3 3/4] validation: classification: incorporates capability and PMR range

2016-04-25 Thread Balasubramanian Manoharan
Adds validation suite for classification capability and PMR range

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
Reviewed-by: Bill Fischofer <bill.fischo...@linaro.org>
---
 test/validation/classification/classification.h|   2 -
 .../classification/odp_classification_basic.c  |  24 ++--
 .../classification/odp_classification_common.c |  19 +--
 .../classification/odp_classification_test_pmr.c   | 127 +++--
 .../classification/odp_classification_tests.c  |  85 ++
 .../classification/odp_classification_testsuites.h |   2 +-
 6 files changed, 129 insertions(+), 130 deletions(-)

diff --git a/test/validation/classification/classification.h 
b/test/validation/classification/classification.h
index 8645ea5..1c442ce 100644
--- a/test/validation/classification/classification.h
+++ b/test/validation/classification/classification.h
@@ -67,8 +67,6 @@ void classification_test_pmr_composite_destroy(void);
 
 void classification_test_pktio_set_skip(void);
 void classification_test_pktio_set_headroom(void);
-void classification_test_pmr_terms_avail(void);
-void classification_test_pmr_terms_cap(void);
 void classification_test_pktio_configure(void);
 void classification_test_pktio_test(void);
 
diff --git a/test/validation/classification/odp_classification_basic.c 
b/test/validation/classification/odp_classification_basic.c
index 0ad6581..372377d 100644
--- a/test/validation/classification/odp_classification_basic.c
+++ b/test/validation/classification/odp_classification_basic.c
@@ -75,7 +75,7 @@ void classification_test_create_pmr_match(void)
uint16_t val;
uint16_t mask;
int retval;
-   odp_pmr_match_t match;
+   odp_pmr_param_t pmr_param;
odp_cos_t default_cos;
odp_cos_t cos;
odp_queue_t default_queue;
@@ -111,12 +111,14 @@ void classification_test_create_pmr_match(void)
 
val = 1024;
mask = 0x;
-   match.term = find_first_supported_l3_pmr();
-   match.val = 
-   match.mask = 
-   match.val_sz = sizeof(val);
-
-   pmr = odp_cls_pmr_create(, 1, default_cos, cos);
+   odp_cls_pmr_param_init(_param);
+   pmr_param.term = find_first_supported_l3_pmr();
+   pmr_param.range_term = false;
+   pmr_param.match.value = 
+   pmr_param.match.mask = 
+   pmr_param.val_sz = sizeof(val);
+
+   pmr = odp_cls_pmr_create(_param, 1, default_cos, cos);
CU_ASSERT(pmr != ODP_PMR_INVAL);
CU_ASSERT(odp_pmr_to_u64(pmr) != odp_pmr_to_u64(ODP_PMR_INVAL));
/* destroy the created PMR */
@@ -254,7 +256,7 @@ void classification_test_pmr_composite_create(void)
 {
odp_pmr_t pmr_composite;
int retval;
-   odp_pmr_match_t pmr_terms[PMR_SET_NUM];
+   odp_pmr_param_t pmr_terms[PMR_SET_NUM];
odp_cos_t default_cos;
odp_cos_t cos;
odp_queue_t default_queue;
@@ -292,9 +294,11 @@ void classification_test_pmr_composite_create(void)
CU_ASSERT(cos != ODP_COS_INVALID);
 
for (i = 0; i < PMR_SET_NUM; i++) {
+   odp_cls_pmr_param_init(_terms[i]);
pmr_terms[i].term = ODP_PMR_TCP_DPORT;
-   pmr_terms[i].val = 
-   pmr_terms[i].mask = 
+   pmr_terms[i].match.value = 
+   pmr_terms[i].range_term = false;
+   pmr_terms[i].match.mask = 
pmr_terms[i].val_sz = sizeof(val);
}
 
diff --git a/test/validation/classification/odp_classification_common.c 
b/test/validation/classification/odp_classification_common.c
index e06d0a9..09ec191 100644
--- a/test/validation/classification/odp_classification_common.c
+++ b/test/validation/classification/odp_classification_common.c
@@ -338,20 +338,21 @@ odp_packet_t create_packet_len(odp_pool_t pool, bool vlan,
return pkt;
 }
 
-odp_pmr_term_t find_first_supported_l3_pmr(void)
+odp_cls_pmr_term_t find_first_supported_l3_pmr(void)
 {
-   unsigned long long cap;
-   odp_pmr_term_t term = ODP_PMR_TCP_DPORT;
+   odp_cls_pmr_term_t term = ODP_PMR_TCP_DPORT;
+   odp_cls_capability_t capability;
+
+   odp_cls_capability();
 
/* choose supported PMR */
-   cap = odp_pmr_terms_cap();
-   if (cap & (1 << ODP_PMR_UDP_SPORT))
+   if (capability.supported_terms.bit.udp_sport)
term = ODP_PMR_UDP_SPORT;
-   else if (cap & (1 << ODP_PMR_UDP_DPORT))
+   else if (capability.supported_terms.bit.udp_dport)
term = ODP_PMR_UDP_DPORT;
-   else if (cap & (1 << ODP_PMR_TCP_SPORT))
+   else if (capability.supported_terms.bit.tcp_sport)
term = ODP_PMR_TCP_SPORT;
-   else if (cap & (1 << ODP_PMR_TCP_DPORT))
+   else if (capability.supported_terms.bit.tcp_dport)
term = ODP_PMR_TCP_DPORT;
else
CU_FAIL("Implementations doesn't support any TCP/UDP PMR");
@@ -

[lng-odp] [API-NEXTv3 2/4] linux-generic: classification: Implements capability and PMR range

2016-04-25 Thread Balasubramanian Manoharan
Implements classification capability and PMR range functionality feature.

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
Reviewed-by: Bill Fischofer <bill.fischo...@linaro.org>
---
 .../include/odp_classification_datamodel.h | 19 -
 .../include/odp_classification_inlines.h   | 24 +++---
 platform/linux-generic/odp_classification.c| 92 +-
 3 files changed, 82 insertions(+), 53 deletions(-)

diff --git a/platform/linux-generic/include/odp_classification_datamodel.h 
b/platform/linux-generic/include/odp_classification_datamodel.h
index 63f3ec6..dc2190d 100644
--- a/platform/linux-generic/include/odp_classification_datamodel.h
+++ b/platform/linux-generic/include/odp_classification_datamodel.h
@@ -52,9 +52,22 @@ Stores the Term and Value mapping for a PMR.
 The maximum size of value currently supported in 64 bits
 **/
 typedef struct pmr_term_value {
-   odp_pmr_term_t  term;   /* PMR Term */
-   uint64_tval;/**< Value to be matched */
-   uint64_tmask;   /**< Masked set of bits to be matched */
+   odp_cls_pmr_term_t  term;   /* PMR Term */
+   odp_bool_t  range_term; /* True if range, false if match */
+   union {
+   struct {
+   /** Value to be matched */
+   uint64_tvalue;
+   /** Masked set of bits to be matched */
+   uint64_tmask;
+   } match;
+   struct {
+   /** Start value of the range */
+   uint64_tval_start;
+   /** End value of the range */
+   uint64_tval_end;
+   } range;
+   };
uint32_toffset; /**< Offset if term == ODP_PMR_CUSTOM_FRAME */
uint32_tval_sz; /**< Size of the value to be matched */
 } pmr_term_value_t;
diff --git a/platform/linux-generic/include/odp_classification_inlines.h 
b/platform/linux-generic/include/odp_classification_inlines.h
index bac5b48..b8b04ce 100644
--- a/platform/linux-generic/include/odp_classification_inlines.h
+++ b/platform/linux-generic/include/odp_classification_inlines.h
@@ -34,8 +34,8 @@ These following functions return 1 on success and 0 on failure
 static inline int verify_pmr_packet_len(odp_packet_hdr_t *pkt_hdr,
pmr_term_value_t *term_value)
 {
-   if (term_value->val == (packet_len(pkt_hdr) &
-term_value->mask))
+   if (term_value->match.value == (packet_len(pkt_hdr) &
+term_value->match.mask))
return 1;
 
return 0;
@@ -51,7 +51,7 @@ static inline int verify_pmr_ip_proto(const uint8_t *pkt_addr,
return 0;
ip = (const odph_ipv4hdr_t *)(pkt_addr + pkt_hdr->l3_offset);
proto = ip->proto;
-   if (term_value->val == (proto & term_value->mask))
+   if (term_value->match.value == (proto & term_value->match.mask))
return 1;
 
return 0;
@@ -67,7 +67,7 @@ static inline int verify_pmr_ipv4_saddr(const uint8_t 
*pkt_addr,
return 0;
ip = (const odph_ipv4hdr_t *)(pkt_addr + pkt_hdr->l3_offset);
ipaddr = odp_be_to_cpu_32(ip->src_addr);
-   if (term_value->val == (ipaddr & term_value->mask))
+   if (term_value->match.value == (ipaddr & term_value->match.mask))
return 1;
 
return 0;
@@ -83,7 +83,7 @@ static inline int verify_pmr_ipv4_daddr(const uint8_t 
*pkt_addr,
return 0;
ip = (const odph_ipv4hdr_t *)(pkt_addr + pkt_hdr->l3_offset);
ipaddr = odp_be_to_cpu_32(ip->dst_addr);
-   if (term_value->val == (ipaddr & term_value->mask))
+   if (term_value->match.value == (ipaddr & term_value->match.mask))
return 1;
 
return 0;
@@ -99,7 +99,7 @@ static inline int verify_pmr_tcp_sport(const uint8_t 
*pkt_addr,
return 0;
tcp = (const odph_tcphdr_t *)(pkt_addr + pkt_hdr->l4_offset);
sport = odp_be_to_cpu_16(tcp->src_port);
-   if (term_value->val == (sport & term_value->mask))
+   if (term_value->match.value == (sport & term_value->match.mask))
return 1;
 
return 0;
@@ -115,7 +115,7 @@ static inline int verify_pmr_tcp_dport(const uint8_t 
*pkt_addr,
return 0;
tcp = (const odph_tcphdr_t *)(pkt_addr + pkt_hdr->l4_offset);
dport = odp_be_to_cpu_16(tcp->dst_port);
-   if (term_value->val == (dport & term_value->mask))
+   if (term_value->match.value == (dport & term_value->match.mask))
return 1;
 
return 0;
@@ -131,7 +131,7 @@ static inline int verif

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

2016-04-25 Thread Balasubramanian Manoharan
Adds classification capability structure and PMR range functionality.
odp_cls_capability_t structure defines system level classification
capability.

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
Reviewed-by: Bill Fischofer <bill.fischo...@linaro.org>
---
v3: Change odp_pmr_term_t bitfield to odp_pmr_terms_t
Incorporates review comments from  Bill

 include/odp/api/spec/classification.h | 147 --
 1 file changed, 124 insertions(+), 23 deletions(-)

diff --git a/include/odp/api/spec/classification.h 
b/include/odp/api/spec/classification.h
index 076b3de..770fbc6 100644
--- a/include/odp/api/spec/classification.h
+++ b/include/odp/api/spec/classification.h
@@ -55,6 +55,80 @@ extern "C" {
  */
 
 /**
+ * Supported PMR term values
+ *
+ * Supported Packet Matching Rule term values in a bit field structure.
+ */
+typedef union odp_cls_pmr_terms_t {
+   struct {
+   /** Total length of received packet */
+   uint64_tlen:1;
+   /** Initial (outer) Ethertype only */
+   uint64_tethtype_0:1;
+   /** Ethertype of most inner VLAN tag */
+   uint64_tethtype_x:1;
+   /** First VLAN ID (outer) */
+   uint64_tvlan_id_0:1;
+   /** Last VLAN ID (inner) */
+   uint64_tvlan_id_x:1;
+   /** destination MAC address */
+   uint64_tdmac:1;
+   /** IP Protocol or IPv6 Next Header */
+   uint64_tip_proto:1;
+   /** Destination UDP port, implies IPPROTO=17 */
+   uint64_tudp_dport:1;
+   /** Destination TCP port implies IPPROTO=6 */
+   uint64_ttcp_dport:1;
+   /** Source UDP Port */
+   uint64_tudp_sport:1;
+   /** Source TCP port */
+   uint64_ttcp_sport:1;
+   /** Source IP address */
+   uint64_tsip_addr:1;
+   /** Destination IP address */
+   uint64_tdip_addr:1;
+   /** Source IP address */
+   uint64_tsip6_addr:1;
+   /** Destination IP address */
+   uint64_tdip6_addr:1;
+   /** IPsec session identifier */
+   uint64_tipsec_spi:1;
+   /** NVGRE/VXLAN network identifier */
+   uint64_tld_vni:1;
+   /** Custom match rule, offset from start of
+* frame. The match is defined by the offset, the
+* expected value, and its size.
+*/
+   uint64_tcustom_frame:1;
+
+   } bit;
+   uint64_t all_bits;
+} odp_cls_pmr_terms_t;
+
+/**
+ * Classification capabilities
+ * This capability structure defines system level classfication capability
+ */
+typedef struct odp_cls_capability_t {
+   /** PMR terms supported by the classifier
+* A bit mask of one bit for each of odp_pmr_term_t
+*/
+   odp_cls_pmr_terms_t supported_terms;
+
+   /** Maximum number of PMR terms */
+   unsigned max_pmr_terms;
+
+   /** Number of PMR terms available for use now */
+   unsigned available_pmr_terms;
+
+   /** Maximum number of CoS supported */
+   unsigned max_cos;
+
+   /** A Boolean to denote support of PMR range */
+   odp_bool_t pmr_range_supported;
+} odp_cls_capability_t;
+
+/**
  * class of service packet drop policies
  */
 typedef enum {
@@ -103,6 +177,18 @@ typedef struct odp_cls_cos_param {
 void odp_cls_cos_param_init(odp_cls_cos_param_t *param);
 
 /**
+ * Query classification capabilities
+ *
+ * Outputs classification capabilities on success.
+ *
+ * @param[out] capability  Pointer to classification capability structure.
+ *
+ * @retval 0 on success
+ * @retval <0 on failure
+ */
+int odp_cls_capability(odp_cls_capability_t *capability);
+
+/**
  * Create a class-of-service
  *
  * @param  nameString intended for debugging purposes.
@@ -265,20 +351,49 @@ typedef enum {
 
/** Inner header may repeat above values with this offset */
ODP_PMR_INNER_HDR_OFF = 32
-} odp_pmr_term_t;
+} odp_cls_pmr_term_t;
 
 /**
- * Following structure is used to define a packet matching rule
+ * Packet Matching Rule parameter structure
  */
-typedef struct odp_pmr_match_t {
-   odp_pmr_term_t  term;   /**< PMR term value to be matched */
-   const void  *val;   /**< Value to be matched */
-   const void  *mask;  /**< Masked set of bits to be matched */
+typedef struct odp_pmr_param_t {
+   odp_cls_pmr_term_t  term;   /**< Packet Macthing Rule term */
+
+   /**< True if the value is range and false if match */
+   odp_bool_t range_term;
+
+   union {
+   struct {
+   /**< Value to be ma

[lng-odp] [RFC 2/2] api: queue: add queue group creation

2016-04-25 Thread Balasubramanian Manoharan
Adds queue group creation parameter

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 include/odp/api/spec/queue.h | 81 
 1 file changed, 81 insertions(+)

diff --git a/include/odp/api/spec/queue.h b/include/odp/api/spec/queue.h
index 51d94a2..7dde060 100644
--- a/include/odp/api/spec/queue.h
+++ b/include/odp/api/spec/queue.h
@@ -158,6 +158,87 @@ typedef struct odp_queue_param_t {
 odp_queue_t odp_queue_create(const char *name, const odp_queue_param_t *param);
 
 /**
+ * Queue group hash protocols
+ * The list of protocol header fields, which are included in queue
+ * distribution within a queue group.
+ */
+typedef union odp_queue_group_hash_proto_t {
+   /** Protocol header fields for queue group hashing */
+   struct {
+   /** TCP or UDP source port number*/
+   uint32_t tcp_udp_src_port : 1;
+   /** TCP or UDP destination port numbers */
+   uint32_t tcp_udp_dst_port : 1;
+   /** IPv4 or IPv6 source addresses */
+   uint32_t ip_src_addr : 1;
+   /** IPv4 or IPv6 destination address */
+   uint32_t ip_dst_addr : 1;
+   } bit;
+
+   /** All bits of the bit field structure */
+   uint32_t all_bits;
+} odp_queue_group_hash_proto_t;
+
+/**
+ * Queue group capability
+ * This capability structure defines system Queue Group capability
+ */
+typedef struct odp_queue_group_capability_t {
+   /** Maximum number of queues supported per queue group */
+   unsigned max_queues;
+   /** A bit mask of one bit for each supported queue group
+   hash proto fields */
+   odp_queue_group_hash_proto_t supported;
+}
+
+/**
+ * ODP Queue Group parameters
+ * Queue group supports only schedule queues <TBD??>
+ */
+typedef struct odp_queue_group_param_t {
+   /** Number of queue to be created for this queue group
+* implementation may round up the value to nearest power of 2
+* and value should be less than the maximum number of queues
+* supported per queue group
+*/
+   unsigned num_queue;
+
+   /** Protocol field selection for queue group distribution
+* Multiple fields can be selected in combination
+*/
+   odp_queue_group_hash_proto_t hash;
+
+} odp_queue_group_param_t;
+
+/**
+ * Initialize queue group params
+ *
+ * Initialize an odp_queue_group_param_t to its default values for all fields.
+ *
+ * @param param   Address of the odp_queue_group_param_t to be initialized
+ */
+void odp_queue_group_param_init(odp_queue_group_param_t *param);
+
+/**
+ * Queue Group create
+ *
+ * Create a queue group according to the queue group parameters.
+ * The individual queues belonging to a queue group are created by the
+ * implementation and the distribution of packets into those queues are
+ * decided based on the odp_queue_group_hash_proto_t parameters.
+ * The individual queues within a queue group are both created and deleted
+ * by the implementation.
+ *
+ * @param nameQueue Group name
+ * @param param   Queue Group parameters.
+ *
+ * @return Queue group handle
+ * @retval ODP_QUEUE_GROUP_INVALID on failure
+ */
+odp_queue_group_t odp_queue_group_create(const char *name,
+const odp_queue_group_param_t *param);
+
+/**
  * Destroy ODP queue
  *
  * Destroys ODP queue. The queue must be empty and detached from other
-- 
1.9.1

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


[lng-odp] [RFC 1/2] api: classification: Add queue group to classification

2016-04-25 Thread Balasubramanian Manoharan
Adds queue group to classification

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 include/odp/api/spec/classification.h | 19 ++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/include/odp/api/spec/classification.h 
b/include/odp/api/spec/classification.h
index 6eca9ab..cf56852 100644
--- a/include/odp/api/spec/classification.h
+++ b/include/odp/api/spec/classification.h
@@ -126,6 +126,12 @@ typedef struct odp_cls_capability_t {
 
/** A Boolean to denote support of PMR range */
odp_bool_t pmr_range_supported;
+
+   /** A Boolean to denote support of queue group */
+   odp_bool_t queue_group_supported;
+
+   /** A Boolena to denote support of queue */
+   odp_bool_t queue_supported;
 } odp_cls_capability_t;
 
 /**
@@ -162,7 +168,18 @@ typedef enum {
  * Used to communicate class of service creation options
  */
 typedef struct odp_cls_cos_param {
-   odp_queue_t queue;  /**< Queue associated with CoS */
+   /** If True, odp_queue_t is linked with CoS,
+* if False odp_queue_group_t is linked with CoS.
+*/
+   odp_bool_t enable_queue;
+
+   typedef union {
+   /** Queue associated with CoS */
+   odp_queue_t queue;
+
+   /** Queue Group associated with CoS */
+   odp_queue_group_t queue_group;
+   };
odp_pool_t pool;/**< Pool associated with CoS */
odp_cls_drop_t drop_policy; /**< Drop policy associated with CoS */
 } odp_cls_cos_param_t;
-- 
1.9.1

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


[lng-odp] [API-NEXTv2 3/4] validation: classification: incorporates capability and PMR range

2016-04-22 Thread Balasubramanian Manoharan
Adds validation suite for classification capability and PMR range

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 test/validation/classification/classification.h|   2 -
 .../classification/odp_classification_basic.c  |  24 ++--
 .../classification/odp_classification_common.c |  19 +--
 .../classification/odp_classification_test_pmr.c   | 127 +++--
 .../classification/odp_classification_tests.c  |  85 ++
 .../classification/odp_classification_testsuites.h |   2 +-
 6 files changed, 129 insertions(+), 130 deletions(-)

diff --git a/test/validation/classification/classification.h 
b/test/validation/classification/classification.h
index 8645ea5..1c442ce 100644
--- a/test/validation/classification/classification.h
+++ b/test/validation/classification/classification.h
@@ -67,8 +67,6 @@ void classification_test_pmr_composite_destroy(void);
 
 void classification_test_pktio_set_skip(void);
 void classification_test_pktio_set_headroom(void);
-void classification_test_pmr_terms_avail(void);
-void classification_test_pmr_terms_cap(void);
 void classification_test_pktio_configure(void);
 void classification_test_pktio_test(void);
 
diff --git a/test/validation/classification/odp_classification_basic.c 
b/test/validation/classification/odp_classification_basic.c
index 0ad6581..372377d 100644
--- a/test/validation/classification/odp_classification_basic.c
+++ b/test/validation/classification/odp_classification_basic.c
@@ -75,7 +75,7 @@ void classification_test_create_pmr_match(void)
uint16_t val;
uint16_t mask;
int retval;
-   odp_pmr_match_t match;
+   odp_pmr_param_t pmr_param;
odp_cos_t default_cos;
odp_cos_t cos;
odp_queue_t default_queue;
@@ -111,12 +111,14 @@ void classification_test_create_pmr_match(void)
 
val = 1024;
mask = 0x;
-   match.term = find_first_supported_l3_pmr();
-   match.val = 
-   match.mask = 
-   match.val_sz = sizeof(val);
-
-   pmr = odp_cls_pmr_create(, 1, default_cos, cos);
+   odp_cls_pmr_param_init(_param);
+   pmr_param.term = find_first_supported_l3_pmr();
+   pmr_param.range_term = false;
+   pmr_param.match.value = 
+   pmr_param.match.mask = 
+   pmr_param.val_sz = sizeof(val);
+
+   pmr = odp_cls_pmr_create(_param, 1, default_cos, cos);
CU_ASSERT(pmr != ODP_PMR_INVAL);
CU_ASSERT(odp_pmr_to_u64(pmr) != odp_pmr_to_u64(ODP_PMR_INVAL));
/* destroy the created PMR */
@@ -254,7 +256,7 @@ void classification_test_pmr_composite_create(void)
 {
odp_pmr_t pmr_composite;
int retval;
-   odp_pmr_match_t pmr_terms[PMR_SET_NUM];
+   odp_pmr_param_t pmr_terms[PMR_SET_NUM];
odp_cos_t default_cos;
odp_cos_t cos;
odp_queue_t default_queue;
@@ -292,9 +294,11 @@ void classification_test_pmr_composite_create(void)
CU_ASSERT(cos != ODP_COS_INVALID);
 
for (i = 0; i < PMR_SET_NUM; i++) {
+   odp_cls_pmr_param_init(_terms[i]);
pmr_terms[i].term = ODP_PMR_TCP_DPORT;
-   pmr_terms[i].val = 
-   pmr_terms[i].mask = 
+   pmr_terms[i].match.value = 
+   pmr_terms[i].range_term = false;
+   pmr_terms[i].match.mask = 
pmr_terms[i].val_sz = sizeof(val);
}
 
diff --git a/test/validation/classification/odp_classification_common.c 
b/test/validation/classification/odp_classification_common.c
index e06d0a9..8c6eefe 100644
--- a/test/validation/classification/odp_classification_common.c
+++ b/test/validation/classification/odp_classification_common.c
@@ -338,20 +338,21 @@ odp_packet_t create_packet_len(odp_pool_t pool, bool vlan,
return pkt;
 }
 
-odp_pmr_term_t find_first_supported_l3_pmr(void)
+odp_cls_pmr_term_e find_first_supported_l3_pmr(void)
 {
-   unsigned long long cap;
-   odp_pmr_term_t term = ODP_PMR_TCP_DPORT;
+   odp_cls_pmr_term_e term = ODP_PMR_TCP_DPORT;
+   odp_cls_capability_t capability;
+
+   odp_cls_capability();
 
/* choose supported PMR */
-   cap = odp_pmr_terms_cap();
-   if (cap & (1 << ODP_PMR_UDP_SPORT))
+   if (capability.supported_terms.bit.udp_sport)
term = ODP_PMR_UDP_SPORT;
-   else if (cap & (1 << ODP_PMR_UDP_DPORT))
+   else if (capability.supported_terms.bit.udp_dport)
term = ODP_PMR_UDP_DPORT;
-   else if (cap & (1 << ODP_PMR_TCP_SPORT))
+   else if (capability.supported_terms.bit.tcp_sport)
term = ODP_PMR_TCP_SPORT;
-   else if (cap & (1 << ODP_PMR_TCP_DPORT))
+   else if (capability.supported_terms.bit.tcp_dport)
term = ODP_PMR_TCP_DPORT;
else
CU_FAIL("Implementations doesn't support any TCP/UDP PMR");
@@ -363,7 +364,7 @@ int set_first_supported_pmr_port(odp_

[lng-odp] [API-NEXTv2 4/4] example: classifier: incorporates capability and PMR range

2016-04-22 Thread Balasubramanian Manoharan
Modifies the classifier example to support classification capability and
PMR range funcionality.

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 example/classifier/odp_classifier.c | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/example/classifier/odp_classifier.c 
b/example/classifier/odp_classifier.c
index 612ce22..6d228b0 100644
--- a/example/classifier/odp_classifier.c
+++ b/example/classifier/odp_classifier.c
@@ -56,7 +56,7 @@ typedef struct {
odp_atomic_u64_t pool_pkt_count; /**< count of received packets */
char cos_name[ODP_COS_NAME_LEN];/**< cos name */
struct {
-   odp_pmr_term_t term;/**< odp pmr term value */
+   odp_cls_pmr_term_e term;/**< odp pmr term value */
uint64_t val;   /**< pmr term value */
uint64_t mask;  /**< pmr term mask */
uint32_t val_sz;/**< size of the pmr term */
@@ -89,7 +89,7 @@ static void print_info(char *progname, appl_args_t 
*appl_args);
 static void usage(char *progname);
 static void configure_cos(odp_cos_t default_cos, appl_args_t *args);
 static odp_cos_t configure_default_cos(odp_pktio_t pktio, appl_args_t *args);
-static int convert_str_to_pmr_enum(char *token, odp_pmr_term_t *term,
+static int convert_str_to_pmr_enum(char *token, odp_cls_pmr_term_e *term,
   uint32_t *offset);
 static int parse_pmr_policy(appl_args_t *appl_args, char *argv[], char 
*optarg);
 
@@ -393,6 +393,7 @@ static void configure_cos(odp_cos_t default_cos, 
appl_args_t *args)
char pool_name[ODP_POOL_NAME_LEN];
odp_pool_param_t pool_params;
odp_cls_cos_param_t cls_param;
+   odp_pmr_param_t pmr_param;
int i;
global_statistics *stats;
odp_queue_param_t qparam;
@@ -438,15 +439,14 @@ static void configure_cos(odp_cos_t default_cos, 
appl_args_t *args)
cls_param.drop_policy = ODP_COS_DROP_POOL;
stats->cos = odp_cls_cos_create(cos_name, _param);
 
-   const odp_pmr_match_t match = {
-   .term = stats->rule.term,
-   .val = >rule.val,
-   .mask = >rule.mask,
-   .val_sz = stats->rule.val_sz,
-   .offset = stats->rule.offset
-   };
+   odp_cls_pmr_param_init(_param);
+   pmr_param.term = stats->rule.term;
+   pmr_param.match.value = >rule.val;
+   pmr_param.match.mask = >rule.mask;
+   pmr_param.val_sz = stats->rule.val_sz;
+   pmr_param.offset = stats->rule.offset;
 
-   stats->pmr = odp_cls_pmr_create(, 1, default_cos,
+   stats->pmr = odp_cls_pmr_create(_param, 1, default_cos,
stats->cos);
if (stats->pmr == ODP_PMR_INVAL) {
EXAMPLE_ERR("odp_pktio_pmr_cos failed");
@@ -665,7 +665,7 @@ static void swap_pkt_addrs(odp_packet_t pkt_tbl[], unsigned 
len)
}
 }
 
-static int convert_str_to_pmr_enum(char *token, odp_pmr_term_t *term,
+static int convert_str_to_pmr_enum(char *token, odp_cls_pmr_term_e *term,
   uint32_t *offset)
 {
if (NULL == token)
@@ -691,7 +691,7 @@ static int parse_pmr_policy(appl_args_t *appl_args, char 
*argv[], char *optarg)
int policy_count;
char *token;
size_t len;
-   odp_pmr_term_t term;
+   odp_cls_pmr_term_e term;
global_statistics *stats;
char *pmr_str;
uint32_t offset;
@@ -904,9 +904,9 @@ static void usage(char *progname)
"\n"
"Mandatory OPTIONS:\n"
"  -i, --interface Eth interface\n"
-   "  -p, --policy 
[|]:::\n"
+   "  -p, --policy 
[|]:::\n"
"\n"
-   "   Packet Matching Rule defined 
with odp_pmr_term_t "
+   "   Packet Matching Rule defined 
with odp_cls_pmr_term_e "
"for the policy\n"
"   Absolute offset in bytes from 
frame start to define a "
"ODP_PMR_CUSTOM_FRAME Packet Matching Rule for the 
policy\n"
-- 
1.9.1

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


[lng-odp] [API-NEXTv2 2/4] linux-generic: classification: Implements capability and PMR range

2016-04-22 Thread Balasubramanian Manoharan
Implements classification capability and PMR range functionality feature.

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 .../include/odp_classification_datamodel.h | 19 -
 .../include/odp_classification_inlines.h   | 24 +++---
 platform/linux-generic/odp_classification.c| 92 +-
 3 files changed, 82 insertions(+), 53 deletions(-)

diff --git a/platform/linux-generic/include/odp_classification_datamodel.h 
b/platform/linux-generic/include/odp_classification_datamodel.h
index 63f3ec6..550e9d3 100644
--- a/platform/linux-generic/include/odp_classification_datamodel.h
+++ b/platform/linux-generic/include/odp_classification_datamodel.h
@@ -52,9 +52,22 @@ Stores the Term and Value mapping for a PMR.
 The maximum size of value currently supported in 64 bits
 **/
 typedef struct pmr_term_value {
-   odp_pmr_term_t  term;   /* PMR Term */
-   uint64_tval;/**< Value to be matched */
-   uint64_tmask;   /**< Masked set of bits to be matched */
+   odp_cls_pmr_term_e  term;   /* PMR Term */
+   odp_bool_t  range_term; /* True if range, false if match */
+   union {
+   struct {
+   /** Value to be matched */
+   uint64_tvalue;
+   /** Masked set of bits to be matched */
+   uint64_tmask;
+   } match;
+   struct {
+   /** Start value of the range */
+   uint64_tval_start;
+   /** End value of the range */
+   uint64_tval_end;
+   } range;
+   };
uint32_toffset; /**< Offset if term == ODP_PMR_CUSTOM_FRAME */
uint32_tval_sz; /**< Size of the value to be matched */
 } pmr_term_value_t;
diff --git a/platform/linux-generic/include/odp_classification_inlines.h 
b/platform/linux-generic/include/odp_classification_inlines.h
index bac5b48..b8b04ce 100644
--- a/platform/linux-generic/include/odp_classification_inlines.h
+++ b/platform/linux-generic/include/odp_classification_inlines.h
@@ -34,8 +34,8 @@ These following functions return 1 on success and 0 on failure
 static inline int verify_pmr_packet_len(odp_packet_hdr_t *pkt_hdr,
pmr_term_value_t *term_value)
 {
-   if (term_value->val == (packet_len(pkt_hdr) &
-term_value->mask))
+   if (term_value->match.value == (packet_len(pkt_hdr) &
+term_value->match.mask))
return 1;
 
return 0;
@@ -51,7 +51,7 @@ static inline int verify_pmr_ip_proto(const uint8_t *pkt_addr,
return 0;
ip = (const odph_ipv4hdr_t *)(pkt_addr + pkt_hdr->l3_offset);
proto = ip->proto;
-   if (term_value->val == (proto & term_value->mask))
+   if (term_value->match.value == (proto & term_value->match.mask))
return 1;
 
return 0;
@@ -67,7 +67,7 @@ static inline int verify_pmr_ipv4_saddr(const uint8_t 
*pkt_addr,
return 0;
ip = (const odph_ipv4hdr_t *)(pkt_addr + pkt_hdr->l3_offset);
ipaddr = odp_be_to_cpu_32(ip->src_addr);
-   if (term_value->val == (ipaddr & term_value->mask))
+   if (term_value->match.value == (ipaddr & term_value->match.mask))
return 1;
 
return 0;
@@ -83,7 +83,7 @@ static inline int verify_pmr_ipv4_daddr(const uint8_t 
*pkt_addr,
return 0;
ip = (const odph_ipv4hdr_t *)(pkt_addr + pkt_hdr->l3_offset);
ipaddr = odp_be_to_cpu_32(ip->dst_addr);
-   if (term_value->val == (ipaddr & term_value->mask))
+   if (term_value->match.value == (ipaddr & term_value->match.mask))
return 1;
 
return 0;
@@ -99,7 +99,7 @@ static inline int verify_pmr_tcp_sport(const uint8_t 
*pkt_addr,
return 0;
tcp = (const odph_tcphdr_t *)(pkt_addr + pkt_hdr->l4_offset);
sport = odp_be_to_cpu_16(tcp->src_port);
-   if (term_value->val == (sport & term_value->mask))
+   if (term_value->match.value == (sport & term_value->match.mask))
return 1;
 
return 0;
@@ -115,7 +115,7 @@ static inline int verify_pmr_tcp_dport(const uint8_t 
*pkt_addr,
return 0;
tcp = (const odph_tcphdr_t *)(pkt_addr + pkt_hdr->l4_offset);
dport = odp_be_to_cpu_16(tcp->dst_port);
-   if (term_value->val == (dport & term_value->mask))
+   if (term_value->match.value == (dport & term_value->match.mask))
return 1;
 
return 0;
@@ -131,7 +131,7 @@ static inline int verify_pmr_udp_dport(const uint8_t 
*pkt_addr,
  

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

2016-04-22 Thread Balasubramanian Manoharan
Adds classification capability structure and PMR range functionality.
odp_cls_capability_t structure defines system level classification
capability.

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
v2: Incorporates review comments from Petri

 include/odp/api/spec/classification.h | 147 --
 1 file changed, 124 insertions(+), 23 deletions(-)

diff --git a/include/odp/api/spec/classification.h 
b/include/odp/api/spec/classification.h
index 076b3de..6eca9ab 100644
--- a/include/odp/api/spec/classification.h
+++ b/include/odp/api/spec/classification.h
@@ -55,6 +55,80 @@ extern "C" {
  */
 
 /**
+ * Supported PMR term values
+ *
+ * Supported Packet Matching Rule term values in a bit field structure.
+ */
+typedef union odp_cls_pmr_term_t {
+   struct {
+   /** Total length of received packet */
+   uint64_tlen:1;
+   /** Initial (outer) Ethertype only */
+   uint64_tethtype_0:1;
+   /** Ethertype of most inner VLAN tag */
+   uint64_tethtype_x:1;
+   /** First VLAN ID (outer) */
+   uint64_tvlan_id_0:1;
+   /** Last VLAN ID (inner) */
+   uint64_tvlan_id_x:1;
+   /** destination MAC address */
+   uint64_tdmac:1;
+   /** IP Protocol or IPv6 Next Header */
+   uint64_tip_proto:1;
+   /** Destination UDP port, implies IPPROTO=17 */
+   uint64_tudp_dport:1;
+   /** Destination TCP port implies IPPROTO=6 */
+   uint64_ttcp_dport:1;
+   /** Source UDP Port */
+   uint64_tudp_sport:1;
+   /** Source TCP port */
+   uint64_ttcp_sport:1;
+   /** Source IP address */
+   uint64_tsip_addr:1;
+   /** Destination IP address */
+   uint64_tdip_addr:1;
+   /** Source IP address */
+   uint64_tsip6_addr:1;
+   /** Destination IP address */
+   uint64_tdip6_addr:1;
+   /** IPsec session identifier */
+   uint64_tipsec_spi:1;
+   /** NVGRE/VXLAN network identifier */
+   uint64_tld_vni:1;
+   /** Custom match rule, offset from start of
+* frame. The match is defined by the offset, the
+* expected value, and its size.
+*/
+   uint64_tcustom_frame:1;
+
+   } bit;
+   uint64_t all_bits;
+} odp_cls_pmr_term_t;
+
+/**
+ * Classification capabilities
+ * This capability structure defines system level classfication capability
+ */
+typedef struct odp_cls_capability_t {
+   /** PMR terms supported by the classifier
+* A bit mask of one bit for each of odp_pmr_term_t
+*/
+   odp_cls_pmr_term_t supported_terms;
+
+   /** Maximum number of PMR terms */
+   unsigned max_pmr_terms;
+
+   /** Number of PMR terms available for use now */
+   unsigned available_pmr_terms;
+
+   /** Maximum number of CoS supported */
+   unsigned max_cos;
+
+   /** A Boolean to denote support of PMR range */
+   odp_bool_t pmr_range_supported;
+} odp_cls_capability_t;
+
+/**
  * class of service packet drop policies
  */
 typedef enum {
@@ -103,6 +177,18 @@ typedef struct odp_cls_cos_param {
 void odp_cls_cos_param_init(odp_cls_cos_param_t *param);
 
 /**
+ * Query classification capabilities
+ *
+ * Outputs classification capabilities on success.
+ *
+ * @param[out] capability  Pointer to classification capability structure.
+ *
+ * @retval 0 on success
+ * @retval <0 on failure
+ */
+int odp_cls_capability(odp_cls_capability_t *capability);
+
+/**
  * Create a class-of-service
  *
  * @param  nameString intended for debugging purposes.
@@ -265,20 +351,49 @@ typedef enum {
 
/** Inner header may repeat above values with this offset */
ODP_PMR_INNER_HDR_OFF = 32
-} odp_pmr_term_t;
+} odp_cls_pmr_term_e;
 
 /**
- * Following structure is used to define a packet matching rule
+ * Packet Matching Rule parameter structure
  */
-typedef struct odp_pmr_match_t {
-   odp_pmr_term_t  term;   /**< PMR term value to be matched */
-   const void  *val;   /**< Value to be matched */
-   const void  *mask;  /**< Masked set of bits to be matched */
+typedef struct odp_pmr_param_t {
+   odp_cls_pmr_term_e  term;   /**< Packet Macthing Rule term */
+
+   /**< True if the value is range and false if match */
+   odp_bool_t range_term;
+
+   union {
+   struct {
+   /**< Value to be matched */
+   const void  *value;
+
+   /**< Masked set of bits to be 

[lng-odp] [RFC] api: traffic manager: Proposal for Marking APIs

2016-04-22 Thread Balasubramanian Manoharan
Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 include/odp/api/spec/traffic_mngr.h | 96 +
 1 file changed, 96 insertions(+)

diff --git a/include/odp/api/spec/traffic_mngr.h 
b/include/odp/api/spec/traffic_mngr.h
index e4c15df..a32cf4f 100644
--- a/include/odp/api/spec/traffic_mngr.h
+++ b/include/odp/api/spec/traffic_mngr.h
@@ -273,6 +273,102 @@ typedef struct {
  */
 typedef void (*odp_tm_egress_fcn_t) (odp_packet_t odp_pkt);
 
+/** Marking APIs
+ * This Marking functionality entails changes to packet header to reflect the
+ * color marking of the packet on the port level shaper. This is an optional
+ * feature and if available on the platform is used to reflect the packet color
+ * on IPv4/IPv6 DiffServ filed in accordance with RFC 2474. There are three
+ * different packet marking fields supported they are,
+ * 1). Assured forwarding in accordance with RFC 2597, the DSCP is marked to
+ * set the packet Drop precedence in accordance with the color, i.e High Drop
+ * precedence for RED, Medium Drop precedence for YELLOW and leave the DSCP
+ * unchangesd if the color is GREEN.
+ * 2). Explicit Congestion Notification protocol per RFC 3168, where a router
+ * encountering congestion can notifiy it by setting the lower 2 bits in
+ * DiffServ field to "11" Congestion Encountered code, which will ultimately
+ * reduce the transmission rate of the packet sender.
+ * 3). In IEEE 802.1q VLAN tag header contains a DE - Drop Eligibility bit for
+ * marking a packet for Downstream switches, and is valid for Ethernet packet
+ * containing a VLAN tag.
+ *
+ * RFC 3168 is only valid for TCP packets whereas RFC 2597 is valid for 
IPv4/IPv6
+ * traffic.
+ */
+
+/** Drop Eligibility
+ * The odp_tm_drop_eligibility() functions allows one to enable drop
+ * eligibility for packet based on color, if enabled it will set DE
+ * bit for VLAN tagged packets.
+ *
+ * @param  odp_tm  Traffic Manager system
+ * @param  color   The packet color whose DE bit
+ * will be modified
+ * @param  drop_eligibilityIf true then DE bit will be set for
+ * VLAN tagged packets with this color
+ *
+ * @return 0 upon success, < 0 upon failure.
+ */
+int odp_tm_drop_eligibility(odp_tm_t odp_tm, odp_packet_color_t color,
+   odp_bool_t drop_eligibility);
+
+/** Drop Precedence
+ * The odp_tm_drop_precedence() functions allows one to enable drop
+ * precedence for packet based on color, if enabled it will set HIGH Drop
+ * for packets of RED color, MEDIUM drop precedence for packets of YELLOW
+ * color and the value is unchanged for GREEN color packets.
+ *
+ * @param  odp_tm  Traffic Manager system
+ * @param  color   The packet color whose Drop precedence
+ * is enabled.
+ * @param  drop_precedence If true then Drop precedence level will
+ * be set according to packet color.
+ * @return 0 upon success, < 0 upon failure.
+ */
+int odp_tm_drop_precedence(odp_tm_t odp_tm, odp_packet_color_t color,
+  odp_bool_t drop_precedence);
+
+/** Explicit Congestion Notification
+ * The odp_tm_ecn() functions allows one to enable ECN for packets based on
+ * color. If enabled will set the lower 2 bits in DiffServ field to "11"
+ * Congestion Encountered code.
+ *
+ * @param  odp_tm  Traffic Manager system
+ * @param  color   The packet color for which ECN will
+ * be set.
+ * @param  ecn If true then ECN will be set as "11"
+ * Congestion Encountered code.
+ * @return 0 upon success, < 0 upon failure.
+ */
+int odp_tm_ecn(odp_tm_t odp_tm, odp_packet_color_t color,
+  odp_bool_t ecn);
+
+/** Vlan Marking.
+ *
+ * The odp_tm_vlan__marking() function allows one to configure the TM
+ * egress so as to have it set the 4-bit VLAN priority field (but only for
+ * pkts that already carry a VLAN tag) of a pkt based upon the final pkt (or
+ * shaper?) color assigned to the pkt when it reaches the egress node.  When
+ * enable is false, then the given color no longer modifies the priority
+ * field.  When enable is true then a packet exiting this TM system whose
+ * color matches the given color parameter will cause the 4-bit VLAN priority
+ * field to be set to the given priority value.
+ *
+ * @param[in] odp_tm Odp_tm is used to identify the TM system
+ *   whose egress behavior is being changed.
+ * @param[in] color  The packet color whose egress marking is
+ *   

[lng-odp] [API-NEXT 4/4] example: classifier: incorporates capability and PMR range

2016-04-21 Thread Balasubramanian Manoharan
Modifies the classifier example to support classification capability and
PMR range funcionality.

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 example/classifier/odp_classifier.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/example/classifier/odp_classifier.c 
b/example/classifier/odp_classifier.c
index 612ce22..a50a5c1 100644
--- a/example/classifier/odp_classifier.c
+++ b/example/classifier/odp_classifier.c
@@ -393,6 +393,7 @@ static void configure_cos(odp_cos_t default_cos, 
appl_args_t *args)
char pool_name[ODP_POOL_NAME_LEN];
odp_pool_param_t pool_params;
odp_cls_cos_param_t cls_param;
+   odp_pmr_param_t pmr_param;
int i;
global_statistics *stats;
odp_queue_param_t qparam;
@@ -438,15 +439,14 @@ static void configure_cos(odp_cos_t default_cos, 
appl_args_t *args)
cls_param.drop_policy = ODP_COS_DROP_POOL;
stats->cos = odp_cls_cos_create(cos_name, _param);
 
-   const odp_pmr_match_t match = {
-   .term = stats->rule.term,
-   .val = >rule.val,
-   .mask = >rule.mask,
-   .val_sz = stats->rule.val_sz,
-   .offset = stats->rule.offset
-   };
+   odp_cls_pmr_param_init(_param);
+   pmr_param.term = stats->rule.term;
+   pmr_param.match.value = >rule.val;
+   pmr_param.match.mask = >rule.mask;
+   pmr_param.val_sz = stats->rule.val_sz;
+   pmr_param.offset = stats->rule.offset;
 
-   stats->pmr = odp_cls_pmr_create(, 1, default_cos,
+   stats->pmr = odp_cls_pmr_create(_param, 1, default_cos,
stats->cos);
if (stats->pmr == ODP_PMR_INVAL) {
EXAMPLE_ERR("odp_pktio_pmr_cos failed");
-- 
1.9.1

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


[lng-odp] [API-NEXT 2/4] linux-generic: classification: Implements capability and PMR range

2016-04-21 Thread Balasubramanian Manoharan
Implements classification capability and PMR range functionality feature.

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 .../include/odp_classification_datamodel.h | 17 +++-
 .../include/odp_classification_inlines.h   | 24 +++---
 platform/linux-generic/odp_classification.c| 92 +-
 3 files changed, 81 insertions(+), 52 deletions(-)

diff --git a/platform/linux-generic/include/odp_classification_datamodel.h 
b/platform/linux-generic/include/odp_classification_datamodel.h
index 63f3ec6..7a1dd5c 100644
--- a/platform/linux-generic/include/odp_classification_datamodel.h
+++ b/platform/linux-generic/include/odp_classification_datamodel.h
@@ -53,8 +53,21 @@ The maximum size of value currently supported in 64 bits
 **/
 typedef struct pmr_term_value {
odp_pmr_term_t  term;   /* PMR Term */
-   uint64_tval;/**< Value to be matched */
-   uint64_tmask;   /**< Masked set of bits to be matched */
+   odp_bool_t  range_term;
+   union {
+   struct {
+   /** Value to be matched */
+   uint64_tvalue;
+   /** Masked set of bits to be matched */
+   uint64_tmask;
+   } match;
+   struct {
+   /** Start value of the range */
+   uint64_tval_start;
+   /** End value of the range */
+   uint64_tval_end;
+   } range;
+   };
uint32_toffset; /**< Offset if term == ODP_PMR_CUSTOM_FRAME */
uint32_tval_sz; /**< Size of the value to be matched */
 } pmr_term_value_t;
diff --git a/platform/linux-generic/include/odp_classification_inlines.h 
b/platform/linux-generic/include/odp_classification_inlines.h
index bac5b48..b8b04ce 100644
--- a/platform/linux-generic/include/odp_classification_inlines.h
+++ b/platform/linux-generic/include/odp_classification_inlines.h
@@ -34,8 +34,8 @@ These following functions return 1 on success and 0 on failure
 static inline int verify_pmr_packet_len(odp_packet_hdr_t *pkt_hdr,
pmr_term_value_t *term_value)
 {
-   if (term_value->val == (packet_len(pkt_hdr) &
-term_value->mask))
+   if (term_value->match.value == (packet_len(pkt_hdr) &
+term_value->match.mask))
return 1;
 
return 0;
@@ -51,7 +51,7 @@ static inline int verify_pmr_ip_proto(const uint8_t *pkt_addr,
return 0;
ip = (const odph_ipv4hdr_t *)(pkt_addr + pkt_hdr->l3_offset);
proto = ip->proto;
-   if (term_value->val == (proto & term_value->mask))
+   if (term_value->match.value == (proto & term_value->match.mask))
return 1;
 
return 0;
@@ -67,7 +67,7 @@ static inline int verify_pmr_ipv4_saddr(const uint8_t 
*pkt_addr,
return 0;
ip = (const odph_ipv4hdr_t *)(pkt_addr + pkt_hdr->l3_offset);
ipaddr = odp_be_to_cpu_32(ip->src_addr);
-   if (term_value->val == (ipaddr & term_value->mask))
+   if (term_value->match.value == (ipaddr & term_value->match.mask))
return 1;
 
return 0;
@@ -83,7 +83,7 @@ static inline int verify_pmr_ipv4_daddr(const uint8_t 
*pkt_addr,
return 0;
ip = (const odph_ipv4hdr_t *)(pkt_addr + pkt_hdr->l3_offset);
ipaddr = odp_be_to_cpu_32(ip->dst_addr);
-   if (term_value->val == (ipaddr & term_value->mask))
+   if (term_value->match.value == (ipaddr & term_value->match.mask))
return 1;
 
return 0;
@@ -99,7 +99,7 @@ static inline int verify_pmr_tcp_sport(const uint8_t 
*pkt_addr,
return 0;
tcp = (const odph_tcphdr_t *)(pkt_addr + pkt_hdr->l4_offset);
sport = odp_be_to_cpu_16(tcp->src_port);
-   if (term_value->val == (sport & term_value->mask))
+   if (term_value->match.value == (sport & term_value->match.mask))
return 1;
 
return 0;
@@ -115,7 +115,7 @@ static inline int verify_pmr_tcp_dport(const uint8_t 
*pkt_addr,
return 0;
tcp = (const odph_tcphdr_t *)(pkt_addr + pkt_hdr->l4_offset);
dport = odp_be_to_cpu_16(tcp->dst_port);
-   if (term_value->val == (dport & term_value->mask))
+   if (term_value->match.value == (dport & term_value->match.mask))
return 1;
 
return 0;
@@ -131,7 +131,7 @@ static inline int verify_pmr_udp_dport(const uint8_t 
*pkt_addr,
return 0;
udp = (const odph_udphdr_t *)(pkt_addr + pkt_hdr->l4_offset);
dport = odp_be_to_cpu_16(udp->dst_port);
-   if

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

2016-04-21 Thread Balasubramanian Manoharan
Adds classification capability structure and PMR range functionality.
odp_cls_capability_t structure defines system level classification
capability.

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 include/odp/api/spec/classification.h | 134 --
 1 file changed, 112 insertions(+), 22 deletions(-)

diff --git a/include/odp/api/spec/classification.h 
b/include/odp/api/spec/classification.h
index 076b3de..28619a9 100644
--- a/include/odp/api/spec/classification.h
+++ b/include/odp/api/spec/classification.h
@@ -55,6 +55,76 @@ extern "C" {
  */
 
 /**
+ * Supported PMR term values
+ *
+ * Supported Packet Matching Rule term values in a bit field structure.
+ */
+typedef union odp_cls_pmr_supported_t {
+   struct {
+   /** Total length of received packet */
+   uint64_tpmr_len:1;
+   /** Initial (outer) Ethertype only */
+   uint64_tethtype_0:1;
+   /** Ethertype of most inner VLAN tag */
+   uint64_tethtype_x:1;
+   /** First VLAN ID (outer) */
+   uint64_tvlan_id_0:1;
+   /** Last VLAN ID (inner) */
+   uint64_tvlan_id_x:1;
+   /** destination MAC address */
+   uint64_tdmac:1;
+   /** IP Protocol or IPv6 Next Header */
+   uint64_tip_proto:1;
+   /** Destination UDP port, implies IPPROTO=17 */
+   uint64_tudp_dport:1;
+   /** Destination TCP port implies IPPROTO=6 */
+   uint64_ttcp_dport:1;
+   /** Source UDP Port */
+   uint64_tudp_sport:1;
+   /** Source TCP port */
+   uint64_ttcp_sport:1;
+   /** Source IP address */
+   uint64_tsip_addr:1;
+   /** Destination IP address */
+   uint64_tdip_addr:1;
+   /** Source IP address */
+   uint64_tsip6_addr:1;
+   /** Destination IP address */
+   uint64_tdip6_addr:1;
+   /** IPsec session identifier */
+   uint64_tipsec_spi:1;
+   /** NVGRE/VXLAN network identifier */
+   uint64_tld_vni:1;
+   /** Custom match rule, offset from start of
+* frame. The match is defined by the offset, the
+* expected value, and its size.
+*/
+   uint64_tcustom_frame:1;
+
+   } proto;
+   uint64_t all_bits;
+} odp_cls_pmr_supported_t;
+
+/**
+ * Classification capabilities
+ * This capability structure defines system level classfication capability
+ */
+typedef struct odp_cls_capability_t {
+   /** PMR terms supported by the classifier
+* A mask one bit for each of odp_pmr_term_t
+*/
+   odp_cls_pmr_supported_t pmr_terms;
+   /** Maximum number of PMR terms */
+   unsigned max_pmr_terms;
+   /** Number of PMR terms available for use now */
+   unsigned available_pmr_terms;
+   /** Maximum number of CoS supported */
+   unsigned max_cos;
+   /** A Boolean to denote support of PMR range */
+   odp_bool_t pmr_range_supported;
+} odp_cls_capability_t;
+
+/**
  * class of service packet drop policies
  */
 typedef enum {
@@ -103,6 +173,17 @@ typedef struct odp_cls_cos_param {
 void odp_cls_cos_param_init(odp_cls_cos_param_t *param);
 
 /**
+ * Query classification capabilities
+ *
+ * Outputs classification capabilities on success.
+ *
+ * @param[out] capability  Classification capability structure for output
+ * @retval 0 on success
+ * @retval <0 on failure
+ */
+int odp_cls_capability(odp_cls_capability_t *capability);
+
+/**
  * Create a class-of-service
  *
  * @param  nameString intended for debugging purposes.
@@ -268,17 +349,40 @@ typedef enum {
 } odp_pmr_term_t;
 
 /**
- * Following structure is used to define a packet matching rule
+ * Packet Matching Rule parameter structure
  */
-typedef struct odp_pmr_match_t {
-   odp_pmr_term_t  term;   /**< PMR term value to be matched */
-   const void  *val;   /**< Value to be matched */
-   const void  *mask;  /**< Masked set of bits to be matched */
+typedef struct odp_pmr_param_t {
+   odp_pmr_term_t  term;   /**< Packet Macthing Rule term */
+   bool range_term;/**< True if the value is range and false if 
match */
+   union {
+   struct {
+   /**< Value to be matched */
+   const void  *value;
+   /**< Masked set of bits to be matched */
+   const void  *mask;
+   } match;
+   struct {
+   /* Start and End values are included in the range */
+

Re: [lng-odp] [API-NEXT PATCH v2 1/7] api: packet: add extend and trunc

2016-04-14 Thread Balasubramanian Manoharan

These changes looks good to me.
Reviewed-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>

On Thursday 14 April 2016 01:41 PM, Savolainen, Petri (Nokia - FI/Espoo) 
wrote:


Thanks for the review. Although, I’d prefer to get all 6 patches 
merged in one go, since reordering of these will cause conflicts. I’d 
continue to work locally on top of this set. Also the implementation 
patch set should not include these, but go on top. It’s hard to see if 
something was changed in the other set. Bill’s signed-off-by hints 
that something was changed but I guess nothing was changed, except the 
ordering compared to patches 3 and 5.


Bala, are you OK with patches 3 and 5?

-Petri

*From:*EXT Bill Fischofer [mailto:bill.fischo...@linaro.org]
*Sent:* Wednesday, April 13, 2016 5:29 PM
*To:* Savolainen, Petri (Nokia - FI/Espoo) <petri.savolai...@nokia.com>
*Cc:* LNG ODP Mailman List <lng-odp@lists.linaro.org>
*Subject:* Re: [lng-odp] [API-NEXT PATCH v2 1/7] api: packet: add 
extend and trunc


For parts 1, 2, 4, and 6

Reviewed-by: Bill Fischofer <bill.fischo...@linaro.org 
<mailto:bill.fischo...@linaro.org>>


I'm OK with merging those parts into api-next to allow parallel 
implementation/test work on them. I believe we  still need to get more 
input and feedback on parts 3 and 5 before these can be merged.


On Wed, Apr 13, 2016 at 9:19 AM, Bill Fischofer 
<bill.fischo...@linaro.org <mailto:bill.fischo...@linaro.org>> wrote:


This latest definition looks good. I'll post a v4 of my
implementation patch series to reflect it.

On Wed, Apr 13, 2016 at 8:01 AM, Petri Savolainen
<petri.savolai...@nokia.com <mailto:petri.savolai...@nokia.com>>
wrote:

Added functions to extend / truncate packet head / tail more
than current head/tailroom or segment lengths.

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

diff --git a/include/odp/api/spec/packet.h
b/include/odp/api/spec/packet.h
index 7da353b..6c88458 100644
--- a/include/odp/api/spec/packet.h
+++ b/include/odp/api/spec/packet.h
@@ -406,6 +406,150 @@ void *odp_packet_push_tail(odp_packet_t
pkt, uint32_t len);
 void *odp_packet_pull_tail(odp_packet_t pkt, uint32_t len);

 /**
+ * Extend packet head
+ *
+ * Increase packet data length at packet head. Functionality
is analogous to
+ * odp_packet_push_head() when data length is extended up to
headroom size.
+ * When data length is increased more than that, new segments
are added into
+ * the packet head and old segment handles become invalid.
+ *
+ * A successful operation overwrites the packet handle with a
new handle, which
+ * application must use as the reference to the packet
instead of the old
+ * handle. Depending on the implementation, the old and new
handles may be
+ * equal.
+ *
+ * The operation return value indicates if any packet data or
metadata (e.g.
+ * user_area) were moved in memory during the operation. If
some memory areas
+ * were moved, application must use new packet/segment
handles to update
+ * data pointers. Otherwise, all old pointers remain valid.
+ *
+ * User is responsible to update packet metadata offsets when
needed. Packet
+ * is not modified if operation fails.
+ *
+ * @param[in, out] pkt  Pointer to packet handle. A
successful operation outputs
+ *  the new packet handle.
+ * @param len   Number of bytes to extend the head
+ * @param[out] data_ptr Pointer to output the new data pointer.
+ *  Ignored when NULL.
+ * @param[out] seg_len  Pointer to output segment length at
'data_ptr' above.
+ *  Ignored when NULL.
+ *
+ * @retval 0   Operation successful, old pointers remain valid
+ * @retval >0  Operation successful, old pointers need to be
updated
+ * @retval <0  Operation failed (e.g. due to an allocation
failure)
+ */
+int odp_packet_extend_head(odp_packet_t *pkt, uint32_t len,
void **data_ptr,
+  uint32_t *seg_len);
+
+/**
+ * Truncate packet head
+ *
+ * Decrease packet data length at packet head. Functionality
is analogous to
+ * odp_packet_pull_head() when data length is truncated less
than the first
+ * segment data length. When data le

[lng-odp] [RFC] api: classification capability structure

2016-04-11 Thread Balasubramanian Manoharan
This RFC adds classification capability structure and PMR range
functionality. The implementation patch will be posted once consensus
is reached on API definition.

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 include/odp/api/spec/classification.h | 61 ++-
 1 file changed, 45 insertions(+), 16 deletions(-)

diff --git a/include/odp/api/spec/classification.h 
b/include/odp/api/spec/classification.h
index 076b3de..1fcc520 100644
--- a/include/odp/api/spec/classification.h
+++ b/include/odp/api/spec/classification.h
@@ -55,6 +55,24 @@ extern "C" {
  */
 
 /**
+ * Classification capabilities
+ * This capability structure defines system level classfication capability
+ */
+typedef struct odp_cls_capability_t {
+   /** PMR terms supported by the classifier,
+   A mask one bit for each of odp_pmr_term_t */
+   unsigned long long supported_pmr_terms;
+   /** Maximum number of PMR terms */
+   unsigned max_pmr_terms;
+   /** Number of PMR terms available for use now */
+   unsigned available_pmr_terms;
+   /** Maximum number of CoS supported */
+   unsigned max_cos;
+   /* A Boolean to denote support of PMR range */
+   bool pmr_range_supported;
+} odp_cls_capability_t;
+
+/**
  * class of service packet drop policies
  */
 typedef enum {
@@ -103,6 +121,17 @@ typedef struct odp_cls_cos_param {
 void odp_cls_cos_param_init(odp_cls_cos_param_t *param);
 
 /**
+ * Query classification capabilities
+ *
+ * Outputs classification capabilities on success.
+ *
+ * @param[out] capability  Classification capability structure for output
+ * @retval 0 on success
+ * @retval <0 on failure
+ */
+int odp_cls_capability(odp_cls_capability_t *capability);
+
+/**
  * Create a class-of-service
  *
  * @param  nameString intended for debugging purposes.
@@ -272,8 +301,22 @@ typedef enum {
  */
 typedef struct odp_pmr_match_t {
odp_pmr_term_t  term;   /**< PMR term value to be matched */
-   const void  *val;   /**< Value to be matched */
-   const void  *mask;  /**< Masked set of bits to be matched */
+   bool match; /**< True if the value is match and false if range */
+   union {
+   struct {
+   /**< Value to be matched */
+   const void  *val;
+   /**< Masked set of bits to be matched */
+   const void  *mask;
+   } match;
+   struct {
+   /* Start and End values are included in the range */
+   /**< start value of range */
+   const void  *val_start;
+   /**< End value of range */
+   const void  *val_end;
+   } range;
+   };
uint32_tval_sz;  /**< Size of the term value */
uint32_toffset;  /**< User-defined offset in packet
 Used if term == ODP_PMR_CUSTOM_FRAME only,
@@ -323,20 +366,6 @@ odp_pmr_t odp_cls_pmr_create(const odp_pmr_match_t *terms, 
int num_terms,
 int odp_cls_pmr_destroy(odp_pmr_t pmr_id);
 
 /**
- * Inquire about matching terms supported by the classifier
- *
- * @return A mask one bit per enumerated term, one for each of odp_pmr_term_t
- */
-unsigned long long odp_pmr_terms_cap(void);
-
-/**
- * Return the number of packet matching terms available for use
- *
- * @return A number of packet matcher resources available for use.
- */
-unsigned odp_pmr_terms_avail(void);
-
-/**
 * Assigns a packet pool for a specific class of service.
 * All the packets belonging to the given class of service will
 * be allocated from the assigned packet pool.
-- 
1.9.1

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


Re: [lng-odp] [API-NEXT PATCH v2 1/6] api: pktio: add config options for pktin timestamping

2016-04-01 Thread Balasubramanian Manoharan

For the series:
Reviewed-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>

On 31/03/16 9:41 PM, Petri Savolainen wrote:

Added API calls and definitions for pktio interface level
configuration options. Timestamping is one of those options.
Added definitions to query and enable packet input timestamping.
Packet timestamps are stored in odp_time_t, direct nanoseconds
calls can be added later if needed. Timestamp HW resolution is
expressed in hertz to enable high resolution. Advanced time
protocol handling (e.g. PTP packet timestamping on output)
can be added later.

Signed-off-by: Petri Savolainen <petri.savolai...@nokia.com>
---
  include/odp/api/spec/packet.h   |  32 +++
  include/odp/api/spec/packet_flags.h |  24 
  include/odp/api/spec/packet_io.h| 106 +++-
  3 files changed, 160 insertions(+), 2 deletions(-)

diff --git a/include/odp/api/spec/packet.h b/include/odp/api/spec/packet.h
index 9c63b5f..7da353b 100644
--- a/include/odp/api/spec/packet.h
+++ b/include/odp/api/spec/packet.h
@@ -18,6 +18,8 @@
  extern "C" {
  #endif
  
+#include 

+
  /** @defgroup odp_packet ODP PACKET
   *  Operations on a packet.
   *  @{
@@ -691,6 +693,36 @@ uint32_t odp_packet_flow_hash(odp_packet_t pkt);
  void odp_packet_flow_hash_set(odp_packet_t pkt, uint32_t flow_hash);
  
  /**

+ * Packet timestamp
+ *
+ * Returns packet timestamp value as odp_time_t type. Use time API for
+ * additional operations on packet timestamp values or conversion into
+ * nanoseconds. Use odp_packet_has_ts() to check if packet has a valid
+ * timestamp. Packet input interface timestamp resolution can be checked with
+ * odp_pktin_ts_res().
+ *
+ * @param pkt  Packet handle
+ *
+ * @return Timestamp value
+ *
+ * @see odp_pktin_ts_res(), odp_packet_has_ts(), odp_time_to_ns()
+ */
+odp_time_t odp_packet_ts(odp_packet_t pkt);
+
+/**
+ * Set packet timestamp
+ *
+ * Stores timestamp value and sets timestamp flag for the packet.
+ *
+ * @param pktPacket handle
+ * @param timestamp  Timestamp value
+ *
+ * @see odp_packet_ts(), odp_packet_has_ts(),
+ * odp_pktin_ts_from_ns()
+ */
+void odp_packet_ts_set(odp_packet_t pkt, odp_time_t timestamp);
+
+/**
   * Tests if packet is segmented
   *
   * @param pkt  Packet handle
diff --git a/include/odp/api/spec/packet_flags.h 
b/include/odp/api/spec/packet_flags.h
index a095ed7..35d44e1 100644
--- a/include/odp/api/spec/packet_flags.h
+++ b/include/odp/api/spec/packet_flags.h
@@ -285,6 +285,18 @@ int odp_packet_has_icmp(odp_packet_t pkt);
  int odp_packet_has_flow_hash(odp_packet_t pkt);
  
  /**

+ * Check for packet timestamp
+ *
+ * @param pkt Packet handle
+ *
+ * @retval non-zero if packet contains a timestamp value
+ * @retval 0 if packet does not contain a timestamp value
+ *
+ * @see odp_packet_has_ts_clr()
+ */
+int odp_packet_has_ts(odp_packet_t pkt);
+
+/**
   * Set flag for L2 header, e.g. ethernet
   *
   * @param pkt Packet handle
@@ -462,6 +474,18 @@ void odp_packet_has_icmp_set(odp_packet_t pkt, int val);
  void odp_packet_has_flow_hash_clr(odp_packet_t pkt);
  
  /**

+ * Clear flag for packet timestamp
+ *
+ * This call clears the timestamp flag. A odp_packet_ts_set() call sets
+ * the flag in addition to the timestamp value.
+ *
+ * @param pkt Packet handle
+ *
+ * @see odp_packet_has_ts(), odp_packet_ts_set()
+ */
+void odp_packet_has_ts_clr(odp_packet_t pkt);
+
+/**
   * @}
   */
  
diff --git a/include/odp/api/spec/packet_io.h b/include/odp/api/spec/packet_io.h

index 3695e52..58b341b 100644
--- a/include/odp/api/spec/packet_io.h
+++ b/include/odp/api/spec/packet_io.h
@@ -20,6 +20,7 @@ extern "C" {
  
  #include 

  #include 
+#include 
  
  /** @defgroup odp_packet_io ODP PACKET IO

   *  Operations on a packet Input/Output interface.
@@ -206,21 +207,63 @@ typedef struct odp_pktout_queue_param_t {
  /**
   * Packet IO parameters
   *
- * In minimum, user must select input and output modes. Use 0 for defaults.
- * Initialize entire struct with zero to maintain API compatibility.
+ * Packet IO interface level parameters. Use odp_pktio_param_init() to
+ * initialize the structure with default values.
   */
  typedef struct odp_pktio_param_t {
/** Packet input mode
  *
  * The default value is ODP_PKTIN_MODE_DIRECT. */
odp_pktin_mode_t in_mode;
+
/** Packet output mode
  *
  * The default value is ODP_PKTOUT_MODE_DIRECT. */
odp_pktout_mode_t out_mode;
+
  } odp_pktio_param_t;
  
  /**

+ * Packet input configuration options bit field
+ *
+ * Packet input configuration options listed in a bit field structure. Packet
+ * input timestamping may be enabled for all packets or at least for those that
+ * belong to time synchronization protocol (PTP).
+ */
+typedef union odp_pktin_config_opt_t {
+   /** Option flags */
+   struct {
+   /** Timestamp all packets on packet input */
+ 

Re: [lng-odp] [PATCH 0/2] linux-generic: pool: add more debug print for pool_destroy

2016-04-01 Thread Balasubramanian Manoharan

For the series:
Reviewed-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>

On Tuesday 29 March 2016 07:29 PM, Maxim Uvarov wrote:

Maxim Uvarov (2):
   linux-generic: pool: add more debug print for pool_destroy
   example: classifier: add termination path

  example/classifier/odp_classifier.c | 45 -
  platform/linux-generic/odp_pool.c   |  2 ++
  2 files changed, 36 insertions(+), 11 deletions(-)



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


[lng-odp] [PATCHv2] linux-generic: traffic-manager: fix integer handling issue

2016-03-29 Thread Balasubramanian Manoharan
Fixes: https://bugs.linaro.org/show_bug.cgi?id=2122

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
v2: Incorporates comments from Maxim

 platform/linux-generic/odp_timer_wheel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/platform/linux-generic/odp_timer_wheel.c 
b/platform/linux-generic/odp_timer_wheel.c
index 638edf4..bf43654 100644
--- a/platform/linux-generic/odp_timer_wheel.c
+++ b/platform/linux-generic/odp_timer_wheel.c
@@ -167,7 +167,7 @@ static uint32_t _odp_internal_ilog2(uint64_t value)
uint32_t bit_shift;
 
for (bit_shift = 0; bit_shift < 64; bit_shift++) {
-   pwr_of_2 = 1 << bit_shift;
+   pwr_of_2 = 1ULL << bit_shift;
if (value == pwr_of_2)
return bit_shift;
else if (value < pwr_of_2)
-- 
1.9.1

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


[lng-odp] [PATCH] linux-generic: traffic-manager: fix integer handling issue

2016-03-27 Thread Balasubramanian Manoharan
Fixes: https://bugs.linaro.org/show_bug.cgi?id=2122

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 platform/linux-generic/odp_timer_wheel.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/platform/linux-generic/odp_timer_wheel.c 
b/platform/linux-generic/odp_timer_wheel.c
index 638edf4..8b8ca87 100644
--- a/platform/linux-generic/odp_timer_wheel.c
+++ b/platform/linux-generic/odp_timer_wheel.c
@@ -167,7 +167,8 @@ static uint32_t _odp_internal_ilog2(uint64_t value)
uint32_t bit_shift;
 
for (bit_shift = 0; bit_shift < 64; bit_shift++) {
-   pwr_of_2 = 1 << bit_shift;
+   /* FIX: BUG2122 Coverity issue */
+   pwr_of_2 = (uint64_t)1 << bit_shift;
if (value == pwr_of_2)
return bit_shift;
else if (value < pwr_of_2)
-- 
1.9.1

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


[lng-odp] [API-NEXT v6] doc: user-guide documentation for classification

2016-02-29 Thread Balasubramanian Manoharan
User guide documentation for classification

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
Reviewed-by: Christophe Milard <christophe.mil...@linaro.org>
---
v6: Incorporates format changes done by Christophe
v5: Proper documentation for example code
v4: Adds example code into source code section
v3: Incorporates classification user guide to main document
Adds Practical example section
v2: Incorporates review comments from Christophe
 doc/users-guide/users-guide-cls.adoc | 224 +++
 doc/users-guide/users-guide.adoc |   2 +
 2 files changed, 226 insertions(+)
 create mode 100644 doc/users-guide/users-guide-cls.adoc

diff --git a/doc/users-guide/users-guide-cls.adoc 
b/doc/users-guide/users-guide-cls.adoc
new file mode 100644
index 000..9e433f2
--- /dev/null
+++ b/doc/users-guide/users-guide-cls.adoc
@@ -0,0 +1,224 @@
+== Classification (CLS)
+
+ODP is a framework for software-based packet forwarding/filtering applications,
+and the purpose of the Packet Classification API is to enable applications to
+program the platform hardware or software implementation to assist in
+prioritization, classification and scheduling of each packet, so that the
+software application can run faster, scale better and adhere to QoS
+requirements.
+
+The following API abstraction are not modelled after any existing product
+implementation, but is instead defined in terms of what a typical data-plane
+application may require from such a platform, without sacrificing simplicity 
and
+avoiding ambiguity. Certain terms that are being used within the context of
+existing products in relation to packet parsing and classification, such as
+access lists are avoided such that not to suggest any relationship
+between the abstraction used within this API and any particular manner in which
+they may be implemented in hardware.
+
+=== Functional Description
+
+Following is the functionality that is required of the classification API, and
+its underlying implementation. The details and order of the following paragraph
+is informative, and is only intended to help convey the functional scope of a
+classifier and provide context for the API. In reality, implementations may
+execute many of these steps concurrently, or in different order while
+maintaining the evident dependencies:
+
+1. Apply a set of classification rules to the header of an incoming packet,
+identify the header fields, e.g. ethertype, IP version, IP protocol, transport
+layer port numbers, IP DiffServ, VLAN id, 802.1p priority.
+
+2. Store these fields as packet meta data for application use, and for the
+remainder of parser operations. The odp_pktio is also stored as one of the meta
+data fields for subsequent use.
+
+3. Compute an odp_cos (Class of Service) value from a subset of supported 
fields
+from 1) above.
+
+4. Based on the odp_cos from 3) above, select the odp_queue through which the
+packet is delivered to the application.
+
+5. Validate the packet data integrity (checksums, FCS)  and correctness (e.g.,
+length fields) and store the validation result, along with optional error layer
+and type indicator, in packet meta data. Optionally, if a packet fails
+validation, override the odp_cos selection in step 3 to a class of service
+designated for errored packets.
+
+6. Based on the odp_cos from 3) above, select the odp_buffer_pool that should 
be
+used to acquire a buffer to store the packet data and meta data.
+
+7. Allocate a buffer from odp_buffer_pool selected in 6) above and logically[1]
+store the packet data and meta data to the allocated buffer, or in accordance
+with class-of-service drop policy and subject to pool buffer availability,
+optionally discard the packet.
+
+8. Enqueue the buffer into the odp_queue selected in 4) above.
+
+The above is an abstract description of the classifier functionality, and may 
be
+applied to a variety of applications in many different ways. The ultimate
+meaning of how this functionality applies to an application also depends on
+other ODP modules, so the above may not complete a full depiction. For 
instance,
+the exact meaning of priority, which is a per-queue attribute is influenced by
+the ODP scheduler semantics, and the system behavior under stress depends on 
the
+ODP buffer pool module behavior.
+
+For the sole purpose of illustrating the above abstract functionality, here is
+an example of a Layer-2 (IEEE 802.1D)  bridge application: Such a forwarding
+application that also adheres to IEEE 802.1p/q priority, which has 8 traffic
+priority levels, might create 8 odp_buffer_pool instances, one for each PCP
+priority level, and 8 odp_queue instances one per priority level. Incoming
+packets will be inspected for a VLAN header; the PCP field will be extracted,
+and used to select both the pool and the queue. Because each queue will be
+assigned a priority value, the packets with highest PCP values will be 
scheduled
+before any packet with

[lng-odp] [API-NEXT v5] doc: user-guide documentation for classification

2016-02-26 Thread Balasubramanian Manoharan
User guide documentation for classification

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
v5: Proper documentation for example code
v4: Adds example code into source code section
v3: Incorporates classification user guide to main document
Adds Practical example section
v2: Incorporates review comments from Christophe
 doc/users-guide/users-guide-cls.adoc | 223 +++
 doc/users-guide/users-guide.adoc |   2 +
 2 files changed, 225 insertions(+)
 create mode 100644 doc/users-guide/users-guide-cls.adoc

diff --git a/doc/users-guide/users-guide-cls.adoc 
b/doc/users-guide/users-guide-cls.adoc
new file mode 100644
index 000..01211d4
--- /dev/null
+++ b/doc/users-guide/users-guide-cls.adoc
@@ -0,0 +1,223 @@
+== Classification (CLS)
+
+ODP is a framework for software-based packet forwarding/filtering applications,
+and the purpose of the Packet Classification API is to enable applications to
+program the platform hardware or software implementation to assist in
+prioritization, classification and scheduling of each packet, so that the
+software application can run faster, scale better and adhere to QoS
+requirements.
+
+The following API abstraction are not modelled after any existing product
+implementation, but is instead defined in terms of what a typical data-plane
+application may require from such a platform, without sacrificing simplicity 
and
+avoiding ambiguity. Certain terms that are being used within the context of
+existing products in relation to packet parsing and classification, such as
+access lists are avoided such that not to suggest any relationship
+between the abstraction used within this API and any particular manner in which
+they may be implemented in hardware.
+
+=== Functional Description
+
+Following is the functionality that is required of the classification API, and
+its underlying implementation. The details and order of the following paragraph
+is informative, and is only intended to help convey the functional scope of a
+classifier and provide context for the API. In reality, implementations may
+execute many of these steps concurrently, or in different order while
+maintaining the evident dependencies:
+
+1. Apply a set of classification rules to the header of an incoming packet,
+identify the header fields, e.g. ,ethertype, IP version, IP protocol, transport
+layer port numbers, IP DiffServ, VLAN id, 802.1p priority.
+
+2. Store these fields as packet meta data for application use, and for the
+remainder of parser operations. The odp_pktio is also stored as one of the meta
+data fields for subsequent use.
+
+3. Compute an odp_cos (Class of Service) value from a subset of supported 
fields
+from 1) above.
+
+4. Based on the odp_cos from 3) above, select the odp_queue through which the
+packet is delivered to the application.
+
+5. Validate the packet data integrity (checksums, FCS)  and correctness (e.g.,
+length fields) and store the validation result, along with optional error layer
+and type indicator, in packet meta data. Optionally, if a packet fails
+validation, override the odp_cos selection in step 3 to a class of service
+designated for errored packets.
+
+6. Based on the odp_cos from 3) above, select the odp_buffer_pool that should 
be
+used to acquire a buffer to store the packet data and meta data.
+
+7. Allocate a buffer from odp_buffer_pool selected in 6) above and logically[1]
+store the packet data and meta data to the allocated buffer, or in accordance
+with class-of-service drop policy and subject to pool buffer availability,
+optionally discard the packet.
+
+8. Enqueue the buffer into the odp_queue selected in 4) above.
+
+The above is an abstract description of the classifier functionality, and may 
be
+applied to a variety of applications in many different ways. The ultimate
+meaning of how this functionality applies to an application also depends on
+other ODP modules, so the above may not complete a full depiction. For 
instance,
+the exact meaning of priority, which is a per-queue attribute is influenced by
+the ODP scheduler semantics, and the system behavior under stress depends on 
the
+ODP buffer pool module behavior.
+
+For the sole purpose of illustrating the above abstract functionality, here is
+an example of a Layer-2 (IEEE 802.1D)  bridge application: Such a forwarding
+application that also adheres to IEEE 802.1p/q priority, which has 8 traffic
+priority levels, might create 8 odp_buffer_pool instances, one for each PCP
+priority level, and 8 odp_queue instances one per priority level. Incoming
+packets will be inspected for a VLAN header; the PCP field will be extracted,
+and used to select both the pool and the queue. Because each queue will be
+assigned a priority value, the packets with highest PCP values will be 
scheduled
+before any packet with a lower PCP value. Also, in a case of congestion, buffer
+pools for lower priority packets will be depleted earlie

[lng-odp] [API-NEXT v4] doc: user-guide documentation for classification

2016-02-25 Thread Balasubramanian Manoharan
User guide documentation for classification

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
v4: Adds example code into source code section
v3: Incorporates classification user guide to main document
Adds Practical example section
v2: Incorporates review comments from Christophe
 doc/users-guide/users-guide-cls.adoc | 226 +++
 doc/users-guide/users-guide.adoc |   2 +
 2 files changed, 228 insertions(+)
 create mode 100644 doc/users-guide/users-guide-cls.adoc

diff --git a/doc/users-guide/users-guide-cls.adoc 
b/doc/users-guide/users-guide-cls.adoc
new file mode 100644
index 000..50114d9
--- /dev/null
+++ b/doc/users-guide/users-guide-cls.adoc
@@ -0,0 +1,226 @@
+== Classification (CLS)
+
+ODP is a framework for software-based packet forwarding/filtering applications,
+and the purpose of the Packet Classification API is to enable applications to
+program the platform hardware or software implementation to assist in
+prioritization, classification and scheduling of each packet, so that the
+software application can run faster, scale better and adhere to QoS
+requirements.
+
+The following API abstraction are not modelled after any existing product
+implementation, but is instead defined in terms of what a typical data-plane
+application may require from such a platform, without sacrificing simplicity 
and
+avoiding ambiguity. Certain terms that are being used within the context of
+existing products in relation to packet parsing and classification, such as
+access lists are avoided such that not to suggest any relationship
+between the abstraction used within this API and any particular manner in which
+they may be implemented in hardware.
+
+=== Functional Description
+
+Following is the functionality that is required of the classification API, and
+its underlying implementation. The details and order of the following paragraph
+is informative, and is only intended to help convey the functional scope of a
+classifier and provide context for the API. In reality, implementations may
+execute many of these steps concurrently, or in different order while
+maintaining the evident dependencies:
+
+1. Apply a set of classification rules to the header of an incoming packet,
+identify the header fields, e.g. ,ethertype, IP version, IP protocol, transport
+layer port numbers, IP DiffServ, VLAN id, 802.1p priority.
+
+2. Store these fields as packet meta data for application use, and for the
+remainder of parser operations. The odp_pktio is also stored as one of the meta
+data fields for subsequent use.
+
+3. Compute an odp_cos (Class of Service) value from a subset of supported 
fields
+from 1) above.
+
+4. Based on the odp_cos from 3) above, select the odp_queue through which the
+packet is delivered to the application.
+
+5. Validate the packet data integrity (checksums, FCS)  and correctness (e.g.,
+length fields) and store the validation result, along with optional error layer
+and type indicator, in packet meta data. Optionally, if a packet fails
+validation, override the odp_cos selection in step 3 to a class of service
+designated for errored packets.
+
+6. Based on the odp_cos from 3) above, select the odp_buffer_pool that should 
be
+used to acquire a buffer to store the packet data and meta data.
+
+7. Allocate a buffer from odp_buffer_pool selected in 6) above and logically[1]
+store the packet data and meta data to the allocated buffer, or in accordance
+with class-of-service drop policy and subject to pool buffer availability,
+optionally discard the packet.
+
+8. Enqueue the buffer into the odp_queue selected in 4) above.
+
+The above is an abstract description of the classifier functionality, and may 
be
+applied to a variety of applications in many different ways. The ultimate
+meaning of how this functionality applies to an application also depends on
+other ODP modules, so the above may not complete a full depiction. For 
instance,
+the exact meaning of priority, which is a per-queue attribute is influenced by
+the ODP scheduler semantics, and the system behavior under stress depends on 
the
+ODP buffer pool module behavior.
+
+For the sole purpose of illustrating the above abstract functionality, here is
+an example of a Layer-2 (IEEE 802.1D)  bridge application: Such a forwarding
+application that also adheres to IEEE 802.1p/q priority, which has 8 traffic
+priority levels, might create 8 odp_buffer_pool instances, one for each PCP
+priority level, and 8 odp_queue instances one per priority level. Incoming
+packets will be inspected for a VLAN header; the PCP field will be extracted,
+and used to select both the pool and the queue. Because each queue will be
+assigned a priority value, the packets with highest PCP values will be 
scheduled
+before any packet with a lower PCP value. Also, in a case of congestion, buffer
+pools for lower priority packets will be depleted earlier than the pools
+containing packets of th

[lng-odp] [API-NEXT v3] doc: user-guide documentation for classification

2016-02-25 Thread Balasubramanian Manoharan
Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
v3: Incorporates classification user guide to main document
Adds Practical example section
v2: Incorporates review comments from Christophe
 doc/users-guide/users-guide-cls.adoc | 220 +++
 doc/users-guide/users-guide.adoc |   2 +
 2 files changed, 222 insertions(+)
 create mode 100644 doc/users-guide/users-guide-cls.adoc

diff --git a/doc/users-guide/users-guide-cls.adoc 
b/doc/users-guide/users-guide-cls.adoc
new file mode 100644
index 000..8dd8f76
--- /dev/null
+++ b/doc/users-guide/users-guide-cls.adoc
@@ -0,0 +1,220 @@
+== Classification (CLS)
+
+ODP is a framework for software-based packet forwarding/filtering applications,
+and the purpose of the Packet Classification API is to enable applications to
+program the platform hardware or software implementation to assist in
+prioritization, classification and scheduling of each packet, so that the
+software application can run faster, scale better and adhere to QoS
+requirements.
+
+The following API abstraction are not modelled after any existing product
+implementation, but is instead defined in terms of what a typical data-plane
+application may require from such a platform, without sacrificing simplicity 
and
+avoiding ambiguity. Certain terms that are being used within the context of
+existing products in relation to packet parsing and classification, such as
+access lists are avoided such that not to suggest any relationship
+between the abstraction used within this API and any particular manner in which
+they may be implemented in hardware.
+
+=== Functional Description
+
+Following is the functionality that is required of the classification API, and
+its underlying implementation. The details and order of the following paragraph
+is informative, and is only intended to help convey the functional scope of a
+classifier and provide context for the API. In reality, implementations may
+execute many of these steps concurrently, or in different order while
+maintaining the evident dependencies:
+
+1. Apply a set of classification rules to the header of an incoming packet,
+identify the header fields, e.g. ,ethertype, IP version, IP protocol, transport
+layer port numbers, IP DiffServ, VLAN id, 802.1p priority.
+
+2. Store these fields as packet meta data for application use, and for the
+remainder of parser operations. The odp_pktio is also stored as one of the meta
+data fields for subsequent use.
+
+3. Compute an odp_cos (Class of Service) value from a subset of supported 
fields
+from 1) above.
+
+4. Based on the odp_cos from 3) above, select the odp_queue through which the
+packet is delivered to the application.
+
+5. Validate the packet data integrity (checksums, FCS)  and correctness (e.g.,
+length fields) and store the validation result, along with optional error layer
+and type indicator, in packet meta data. Optionally, if a packet fails
+validation, override the odp_cos selection in step 3 to a class of service
+designated for errored packets.
+
+6. Based on the odp_cos from 3) above, select the odp_buffer_pool that should 
be
+used to acquire a buffer to store the packet data and meta data.
+
+7. Allocate a buffer from odp_buffer_pool selected in 6) above and logically[1]
+store the packet data and meta data to the allocated buffer, or in accordance
+with class-of-service drop policy and subject to pool buffer availability,
+optionally discard the packet.
+
+8. Enqueue the buffer into the odp_queue selected in 4) above.
+
+The above is an abstract description of the classifier functionality, and may 
be
+applied to a variety of applications in many different ways. The ultimate
+meaning of how this functionality applies to an application also depends on
+other ODP modules, so the above may not complete a full depiction. For 
instance,
+the exact meaning of priority, which is a per-queue attribute is influenced by
+the ODP scheduler semantics, and the system behavior under stress depends on 
the
+ODP buffer pool module behavior.
+
+For the sole purpose of illustrating the above abstract functionality, here is
+an example of a Layer-2 (IEEE 802.1D)  bridge application: Such a forwarding
+application that also adheres to IEEE 802.1p/q priority, which has 8 traffic
+priority levels, might create 8 odp_buffer_pool instances, one for each PCP
+priority level, and 8 odp_queue instances one per priority level. Incoming
+packets will be inspected for a VLAN header; the PCP field will be extracted,
+and used to select both the pool and the queue. Because each queue will be
+assigned a priority value, the packets with highest PCP values will be 
scheduled
+before any packet with a lower PCP value. Also, in a case of congestion, buffer
+pools for lower priority packets will be depleted earlier than the pools
+containing packets of the high priority, and hence the lower priority packets
+will be dropped (assuming that is the onl

[lng-odp] [PATCH v1] validation: classification: add test case for odp_cos_drop() function

2016-02-18 Thread Balasubramanian Manoharan
Fixes: https://bugs.linaro.org/show_bug.cgi?id=2016

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 test/validation/classification/odp_classification_basic.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/test/validation/classification/odp_classification_basic.c 
b/test/validation/classification/odp_classification_basic.c
index 81077b6..8fbad5f 100644
--- a/test/validation/classification/odp_classification_basic.c
+++ b/test/validation/classification/odp_classification_basic.c
@@ -215,8 +215,11 @@ void classification_test_cos_set_drop(void)
 
retval = odp_cos_drop_set(cos_drop, ODP_COS_DROP_POOL);
CU_ASSERT(retval == 0);
+   CU_ASSERT(ODP_COS_DROP_POOL == odp_cos_drop(cos_drop));
+
retval = odp_cos_drop_set(cos_drop, ODP_COS_DROP_NEVER);
CU_ASSERT(retval == 0);
+   CU_ASSERT(ODP_COS_DROP_NEVER == odp_cos_drop(cos_drop));
odp_cos_destroy(cos_drop);
odp_pool_destroy(pool);
odp_queue_destroy(queue);
-- 
1.9.1

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


[lng-odp] [PATCH API-NEXTv2] doc: user-guide documentation for classification

2016-02-17 Thread Balasubramanian Manoharan
Adds user-guide documentation for classification module

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
v2: Incorporates review comments from Christophe

 doc/users-guide/users-guide-cls.adoc | 220 +++
 1 file changed, 220 insertions(+)
 create mode 100644 doc/users-guide/users-guide-cls.adoc

diff --git a/doc/users-guide/users-guide-cls.adoc 
b/doc/users-guide/users-guide-cls.adoc
new file mode 100644
index 000..74cdcaa
--- /dev/null
+++ b/doc/users-guide/users-guide-cls.adoc
@@ -0,0 +1,220 @@
+== Classification \(CLS)
+
+ODP is a framework for software-based packet forwarding/filtering applications,
+and the purpose of the Packet Classification API is to enable applications to
+program the platform hardware or software implementation to assist in
+prioritization, classification and scheduling of each packet, so that the
+software application can run faster, scale better and adhere to QoS
+requirements.
+
+The following API abstraction are not modelled after any existing product
+implementation, but is instead defined in terms of what a typical data-plane
+application may require from such a platform, without sacrificing simplicity 
and
+avoiding ambiguity. Certain terms that are being used within the context of
+existing products in relation to packet parsing and classification, such as
+access lists are avoided such that not to suggest any relationship
+between the abstraction used within this API and any particular manner in which
+they may be implemented in hardware.
+
+=== Functional Description
+
+Following is the functionality that is required of the classification API, and
+its underlying implementation. The details and order of the following paragraph
+is informative, and is only intended to help convey the functional scope of a
+classifier and provide context for the API. In reality, implementations may
+execute many of these steps concurrently, or in different order while
+maintaining the evident dependencies:
+
+1. Apply a set of classification rules to the header of an incoming packet,
+identify the header fields, e.g. ,ethertype, IP version, IP protocol, transport
+layer port numbers, IP DiffServ, VLAN id, 802.1p priority.
+
+2. Store these fields as packet meta data for application use, and for the
+remainder of parser operations. The odp_pktio is also stored as one of the meta
+data fields for subsequent use.
+
+3. Compute an odp_cos (Class of Service) value from a subset of supported 
fields
+from 1) above.
+
+4. Based on the odp_cos from 3) above, select the odp_queue through which the
+packet is delivered to the application.
+
+5. Validate the packet data integrity (checksums, FCS)  and correctness (e.g.,
+length fields) and store the validation result, along with optional error layer
+and type indicator, in packet meta data. Optionally, if a packet fails
+validation, override the odp_cos selection in step 3 to a class of service
+designated for errored packets.
+
+6. Based on the odp_cos from 3) above, select the odp_buffer_pool that should 
be
+used to acquire a buffer to store the packet data and meta data.
+
+7. Allocate a buffer from odp_buffer_pool selected in 6) above and logically[1]
+store the packet data and meta data to the allocated buffer, or in accordance
+with class-of-service drop policy and subject to pool buffer availability,
+optionally discard the packet.
+
+8. Enqueue the buffer into the odp_queue selected in 4) above.
+
+The above is an abstract description of the classifier functionality, and may 
be
+applied to a variety of applications in many different ways. The ultimate
+meaning of how this functionality applies to an application also depends on
+other ODP modules, so the above may not complete a full depiction. For 
instance,
+the exact meaning of priority, which is a per-queue attribute is influenced by
+the ODP scheduler semantics, and the system behavior under stress depends on 
the
+ODP buffer pool module behavior.
+
+For the sole purpose of illustrating the above abstract functionality, here is
+an example of a Layer-2 (IEEE 802.1D)  bridge application: Such a forwarding
+application that also adheres to IEEE 802.1p/q priority, which has 8 traffic
+priority levels, might create 8 odp_buffer_pool instances, one for each PCP
+priority level, and 8 odp_queue instances one per priority level. Incoming
+packets will be inspected for a VLAN header; the PCP field will be extracted,
+and used to select both the pool and the queue. Because each queue will be
+assigned a priority value, the packets with highest PCP values will be 
scheduled
+before any packet with a lower PCP value. Also, in a case of congestion, buffer
+pools for lower priority packets will be depleted earlier than the pools
+containing packets of the high priority, and hence the lower priority packets
+will be dropped (assuming that is the only flow control method that is 
supported
+in the platform) while higher priority p

[lng-odp] [API-NEXT PATCH] doc: user-guide documentation for classification

2016-02-15 Thread Balasubramanian Manoharan
Adds user-guide documentation for classification module

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 doc/users-guide/users-guide-cls.adoc | 220 +++
 1 file changed, 220 insertions(+)
 create mode 100644 doc/users-guide/users-guide-cls.adoc

diff --git a/doc/users-guide/users-guide-cls.adoc 
b/doc/users-guide/users-guide-cls.adoc
new file mode 100644
index 000..3089f86
--- /dev/null
+++ b/doc/users-guide/users-guide-cls.adoc
@@ -0,0 +1,220 @@
+== Classification \(CLS)
+
+ODP is a framework for software-based packet forwarding/filtering applications,
+and the purpose of the Packet Classification API is to enable applications to
+program the platform hardware or software implementation to assist in
+prioritization, classification and scheduling of each packet, so that the
+software application can run faster, scale better and adhere to QoS
+requirements.
+
+The following API abstraction are not modelled after any existing product
+implementation, but is instead defined in terms of what a typical data-plane
+application may require from such a platform, without sacrificing simplicity 
and
+avoiding ambiguity. Certain terms that are being used within the context of
+existing products in relation to packet parsing and classification, such as
+access lists are avoided such that not to suggest any relationship
+between the abstraction used within this API and any particular manner in which
+they may be implemented in hardware.
+
+=== Functional Description
+
+Following is the functionality that is required of the classification API, and
+its underlying implementation. The details and order of the following paragraph
+is informative, and is only intended to help convey the functional scope of a
+classifier aznd provide context for the API. In reality, implementations may
+execute many of these steps concurrently, or in different order while
+maintaining the evident dependencies:
+
+1. Apply a set of classification rules to the header of an incoming packet,
+identify the header fields, e.g. ,ethertype, IP version, IP protocol, transport
+layer port numbers, IP DiffServ, VLAN id, 802.1p priority.
+
+2. Store these fields as packet meta data for application use, and for the
+remainder of parser operations. The odp_pktio is also stored as one of the meta
+data fields for subsequent use.
+
+3. Compute an odp_cos (Class of Service) value from a subset of supported 
fields
+from 1) above.
+
+4. Based on the odp_cos from 3) above, select the odp_queue through which the
+packet is delivered to the application.
+
+5. Validate the packet data integrity (checksums, FCS)  and correctness (e.g.,
+length fields) and store the validation result, along with optional error layer
+and type indicator, in packet meta data. Optionally, if a packet fails
+validation, override the odp_cos selection in step 3 to a class of service
+designated for errored packets.
+
+6. Based on the odp_cos from 3) above, select the odp_buffer_pool that should 
be
+used to acquire a buffer to store the packet data and meta data.
+
+7. Allocate a buffer from odp_buffer_pool selected in 6) above and logically[1]
+store the packet data and meta data to the allocated buffer, or in accordance
+with class-of-service drop policy and subject to pool buffer availability,
+optionally discard the packet.
+
+8. Enqueue the buffer into the odp_queue selected in 4) above.
+
+The above is an abstract description of the classifier functionality, and may 
be
+applied to a variety of applications in many different ways. The ultimate
+meaning of how this functionality applies to an application also depends on
+other ODP modules, so the above may not complete a full depiction. For 
instance,
+the exact meaning of priority, which is a per-queue attribute is influenced by
+the ODP scheduler semantics, and the system behavior under stress depends on 
the
+ODP buffer pool module behavior.
+
+For the sole purpose of illustrating the above abstract functionality, here is
+an example of a Layer-2 (IEEE 802.1D)  bridge application: Such a forwarding
+application that also adheres to IEEE 802.1p/q priority, which has 8 traffic
+priority levels, might create 8 odp_buffer_pool instances, one for each PCP
+priority level, and 8 odp_queue instances one per priority level. Incoming
+packets will be inspected for a VLAN header; the PCP field will be extracted,
+and used to select both the pool and the queue. Because each queue will be
+assigned a priority value, the packets with highest PCP values will be 
scheduled
+before any packet with a lower PCP value. Also, in a case of congestion, buffer
+pools for lower priority packets will be depleted earlier than the pools
+containing packets of the high priority, and hence the lower priority packets
+will be dropped (assuming that is the only flow control method that is 
supported
+in the platform) while higher priority packets will continue to be received 
into
+b

[lng-odp] [API-NEXT PATCHv5 0/4] add PMR create api

2016-02-03 Thread Balasubramanian Manoharan
Packet match rule creation is modified to include source and destination
class of service. Removes the ability to add any class of service directly
with pktio. If a PMR needs to be applied at the pktio level the same
should be applied to default class of service.

Packet match rule destroy function is updated to removes the link between
the source and destination class of service.

odp_pmr_match_set_t handle is removed and pmr create function is modified
to take number of terms and composite rule is created by providing more
than one term.

Since this patch changes the API, the entire set has to be merged before
applying to prevent compilation error in the middle.

v4: Rebase to HEAD

v3: Incorporates Review comments from Petri
 - API reviewed-by from Petri

v2: Removes pmr match set
   - Modifies pmr create function to create composite pmr rules

v1: Initial version for pmr create api change
   - Introduces pmr create api and linux-generic changes

Balasubramanian Manoharan (4):
  api: classification: add pmr create api
  linux-generic: classification: implement pmr create api
  validation: classification: adds validation suite for pmr create api
  example: classifier: modifications for pmr create api

 example/classifier/odp_classifier.c|  38 +--
 include/odp/api/classification.h   | 140 ++---
 .../include/odp/plat/classification_types.h|   9 -
 .../include/odp_classification_datamodel.h |  48 +---
 .../include/odp_classification_internal.h  |  25 +-
 platform/linux-generic/odp_classification.c| 314 +
 platform/linux-generic/odp_packet_io.c |  24 +-
 test/validation/classification/classification.h|   5 +-
 .../classification/odp_classification_basic.c  | 145 ++
 .../classification/odp_classification_common.c |  26 ++
 .../classification/odp_classification_test_pmr.c   | 240 ++--
 .../classification/odp_classification_tests.c  |  97 +++
 .../classification/odp_classification_testsuites.h |   6 +-
 13 files changed, 400 insertions(+), 717 deletions(-)

-- 
1.9.1

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


[lng-odp] [API-NEXT PATCHv5 2/4] linux-generic: classification: implement pmr create api

2016-02-03 Thread Balasubramanian Manoharan
Implements packet match rule create functions.
If a packet match rule needs to be applied at the pktio level it has to be
configured to the default class of service.

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 .../include/odp/plat/classification_types.h|   9 -
 .../include/odp_classification_datamodel.h |  48 +---
 .../include/odp_classification_internal.h  |  25 +-
 platform/linux-generic/odp_classification.c| 314 +
 platform/linux-generic/odp_packet_io.c |  24 +-
 5 files changed, 94 insertions(+), 326 deletions(-)

diff --git a/platform/linux-generic/include/odp/plat/classification_types.h 
b/platform/linux-generic/include/odp/plat/classification_types.h
index 767da7d..d9b9c77 100644
--- a/platform/linux-generic/include/odp/plat/classification_types.h
+++ b/platform/linux-generic/include/odp/plat/classification_types.h
@@ -34,9 +34,6 @@ typedef uint16_t odp_cos_flow_set_t;
 typedef ODP_HANDLE_T(odp_pmr_t);
 #define ODP_PMR_INVAL _odp_cast_scalar(odp_pmr_t, ~0)
 
-typedef ODP_HANDLE_T(odp_pmr_set_t);
-#define ODP_PMR_SET_INVAL _odp_cast_scalar(odp_pmr_set_t, ~0)
-
 /** Get printable format of odp_cos_t */
 static inline uint64_t odp_cos_to_u64(odp_cos_t hdl)
 {
@@ -49,12 +46,6 @@ static inline uint64_t odp_pmr_to_u64(odp_pmr_t hdl)
return _odp_pri(hdl);
 }
 
-/** Get printable format of odp_pmr_set_t */
-static inline uint64_t odp_pmr_set_to_u64(odp_pmr_set_t hdl)
-{
-   return _odp_pri(hdl);
-}
-
 /**
  * @}
  */
diff --git a/platform/linux-generic/include/odp_classification_datamodel.h 
b/platform/linux-generic/include/odp_classification_datamodel.h
index 27d8a52..6301f18 100644
--- a/platform/linux-generic/include/odp_classification_datamodel.h
+++ b/platform/linux-generic/include/odp_classification_datamodel.h
@@ -28,14 +28,12 @@ extern "C" {
 
 /* Maximum Class Of Service Entry */
 #define ODP_COS_MAX_ENTRY  64
-/* Maximum PMR Set Entry */
-#define ODP_PMRSET_MAX_ENTRY   64
 /* Maximum PMR Entry */
-#define ODP_PMR_MAX_ENTRY  64
+#define ODP_PMR_MAX_ENTRY  256
 /* Maximum PMR Terms in a PMR Set */
 #define ODP_PMRTERM_MAX8
 /* Maximum PMRs attached in PKTIO Level */
-#define ODP_PKTIO_MAX_PMR  8
+#define ODP_PMR_PER_COS_MAX8
 /* L2 Priority Bits */
 #define ODP_COS_L2_QOS_BITS3
 /* Max L2 QoS value */
@@ -67,15 +65,16 @@ Class Of Service
 struct cos_s {
queue_entry_t *queue;   /* Associated Queue */
pool_entry_t *pool; /* Associated Buffer pool */
-   union pmr_u *pmr;   /* Chained PMR */
-   union cos_u *linked_cos;/* CoS linked with the PMR */
+   union pmr_u *pmr[ODP_PMR_PER_COS_MAX];  /* Chained PMR */
+   union cos_u *linked_cos[ODP_PMR_PER_COS_MAX]; /* Chained CoS with PMR*/
uint32_t valid; /* validity Flag */
-   odp_cls_drop_t drop_policy; /* Associated Drop Policy */
+   odp_cls_drop_t drop_policy; /* Associated Drop Policy */
odp_queue_group_t queue_group;  /* Associated Queue Group */
odp_cos_flow_set_t flow_set;/* Assigned Flow Set */
-   char name[ODP_COS_NAME_LEN];/* name */
size_t headroom;/* Headroom for this CoS */
odp_spinlock_t lock;/* cos lock */
+   odp_atomic_u32_t num_rule;  /* num of PMRs attached with this CoS */
+   char name[ODP_COS_NAME_LEN];/* name */
 };
 
 typedef union cos_u {
@@ -93,7 +92,9 @@ struct pmr_s {
odp_atomic_u32_t count; /* num of packets matching this rule */
uint32_t num_pmr;   /* num of PMR Term Values*/
odp_spinlock_t lock;/* pmr lock*/
-   pmr_term_value_t  pmr_term_value[1];/* Associated PMR Term */
+   cos_t *src_cos; /* source CoS where PMR is attached */
+   pmr_term_value_t  pmr_term_value[ODP_PMRTERM_MAX];
+   /* List of associated PMR Terms */
 };
 
 typedef union pmr_u {
@@ -102,24 +103,6 @@ typedef union pmr_u {
 } pmr_t;
 
 /**
-Packet Matching Rule Set
-
-This structure is implemented as a extension over struct pmr_s
-In order to use same pointer to access both pmr_s and pmr_set_s
-'num_pmr' value is used to differentiate between pmr_s and pmr_set_s struct
-**/
-struct pmr_set_s {
-   pmr_t pmr;
-   pmr_term_value_t  pmr_term_value[ODP_PMRTERM_MAX - 1];
-   /* List of associated PMR Terms */
-};
-
-typedef union pmr_set_u {
-   struct pmr_set_s s;
-   uint8_t pad[ODP_CACHE_LINE_SIZE_ROUNDUP(sizeof(struct pmr_set_s))];
-} pmr_set_t;
-
-/**
 L2 QoS and CoS Map
 
 This structure holds the mapping between L2 QoS value and
@@ -148,10 +131,6 @@ This structure is stored in pktio_entry and holds all
 the classifier configuration value.
 **/
 typedef struct classifier {
- 

[lng-odp] [API-NEXT PATCHv5 4/4] example: classifier: modifications for pmr create api

2016-02-03 Thread Balasubramanian Manoharan
Changes for packet match rule create function.

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 example/classifier/odp_classifier.c| 38 --
 test/validation/classification/classification.h|  4 +--
 .../classification/odp_classification_basic.c  | 14 
 .../classification/odp_classification_tests.c  | 10 +++---
 .../classification/odp_classification_testsuites.h |  2 +-
 5 files changed, 36 insertions(+), 32 deletions(-)

diff --git a/example/classifier/odp_classifier.c 
b/example/classifier/odp_classifier.c
index 57a58d9..8e0a200 100644
--- a/example/classifier/odp_classifier.c
+++ b/example/classifier/odp_classifier.c
@@ -87,8 +87,8 @@ static void swap_pkt_addrs(odp_packet_t pkt_tbl[], unsigned 
len);
 static void parse_args(int argc, char *argv[], appl_args_t *appl_args);
 static void print_info(char *progname, appl_args_t *appl_args);
 static void usage(char *progname);
-static void configure_cos(odp_pktio_t pktio, appl_args_t *args);
-static void configure_default_cos(odp_pktio_t pktio, appl_args_t *args);
+static void configure_cos(odp_cos_t default_cos, appl_args_t *args);
+static odp_cos_t configure_default_cos(odp_pktio_t pktio, appl_args_t *args);
 static int convert_str_to_pmr_enum(char *token, odp_pmr_term_t *term,
   uint32_t *offset);
 static int parse_pmr_policy(appl_args_t *appl_args, char *argv[], char 
*optarg);
@@ -355,7 +355,7 @@ static void *pktio_receive_thread(void *arg)
return NULL;
 }
 
-static void configure_default_cos(odp_pktio_t pktio, appl_args_t *args)
+static odp_cos_t configure_default_cos(odp_pktio_t pktio, appl_args_t *args)
 {
odp_queue_param_t qparam;
const char *queue_name = "DefaultQueue";
@@ -417,9 +417,10 @@ static void configure_default_cos(odp_pktio_t pktio, 
appl_args_t *args)
odp_atomic_init_u64([args->policy_count].queue_pkt_count, 0);
odp_atomic_init_u64([args->policy_count].pool_pkt_count, 0);
args->policy_count++;
+   return cos_default;
 }
 
-static void configure_cos(odp_pktio_t pktio, appl_args_t *args)
+static void configure_cos(odp_cos_t default_cos, appl_args_t *args)
 {
char cos_name[ODP_COS_NAME_LEN];
char queue_name[ODP_QUEUE_NAME_LEN];
@@ -433,15 +434,6 @@ static void configure_cos(odp_pktio_t pktio, appl_args_t 
*args)
for (i = 0; i < args->policy_count; i++) {
stats = >stats[i];
 
-   const odp_pmr_match_t match = {
-   .term = stats->rule.term,
-   .val = >rule.val,
-   .mask = >rule.mask,
-   .val_sz = stats->rule.val_sz,
-   .offset = stats->rule.offset
-   };
-
-   stats->pmr = odp_pmr_create();
odp_queue_param_init();
qparam.type   = ODP_QUEUE_TYPE_SCHED;
qparam.sched.prio = i % odp_schedule_num_prio();
@@ -480,7 +472,17 @@ static void configure_cos(odp_pktio_t pktio, appl_args_t 
*args)
cls_param.drop_policy = ODP_COS_DROP_POOL;
stats->cos = odp_cls_cos_create(cos_name, _param);
 
-   if (0 > odp_pktio_pmr_cos(stats->pmr, pktio, stats->cos)) {
+   const odp_pmr_match_t match = {
+   .term = stats->rule.term,
+   .val = >rule.val,
+   .mask = >rule.mask,
+   .val_sz = stats->rule.val_sz,
+   .offset = stats->rule.offset
+   };
+
+   stats->pmr = odp_cls_pmr_create(, 1, default_cos,
+   stats->cos);
+   if (stats->pmr == ODP_PMR_INVAL) {
EXAMPLE_ERR("odp_pktio_pmr_cos failed");
exit(EXIT_FAILURE);
}
@@ -505,6 +507,7 @@ int main(int argc, char *argv[])
odp_pool_param_t params;
odp_pktio_t pktio;
appl_args_t *args;
+   odp_cos_t default_cos;
odp_queue_t inq;
odp_shm_t shm;
 
@@ -576,10 +579,10 @@ int main(int argc, char *argv[])
/* create pktio per interface */
pktio = create_pktio(args->if_name, pool);
 
-   configure_cos(pktio, args);
-
/* configure default Cos */
-   configure_default_cos(pktio, args);
+   default_cos = configure_default_cos(pktio, args);
+
+   configure_cos(default_cos, args);
 
if (odp_pktio_start(pktio)) {
EXAMPLE_ERR("Error: unable to start pktio.\n");
@@ -606,6 +609,7 @@ int main(int argc, char *argv[])
print_cls_statistics(args);
 
for (i = 0; i < args->policy_count; i++) {
+   odp_cls_pmr_destroy(args->stats[i].pmr);
odp_cos_destroy(args->stats[i].cos);
  

[lng-odp] [API-NEXT PATCHv5 3/4] validation: classification: adds validation suite for pmr create api

2016-02-03 Thread Balasubramanian Manoharan
Adds validation suite for packet match rule create functions.

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 test/validation/classification/classification.h|   1 -
 .../classification/odp_classification_basic.c  | 141 +++-
 .../classification/odp_classification_common.c |  26 +++
 .../classification/odp_classification_test_pmr.c   | 240 -
 .../classification/odp_classification_tests.c  |  87 
 .../classification/odp_classification_testsuites.h |   4 +-
 6 files changed, 245 insertions(+), 254 deletions(-)

diff --git a/test/validation/classification/classification.h 
b/test/validation/classification/classification.h
index 5508af7..c987cca 100644
--- a/test/validation/classification/classification.h
+++ b/test/validation/classification/classification.h
@@ -59,7 +59,6 @@
 void classification_test_create_cos(void);
 void classification_test_destroy_cos(void);
 void classification_test_create_pmr_match(void);
-void classification_test_destroy_pmr(void);
 void classification_test_cos_set_queue(void);
 void classification_test_cos_set_pool(void);
 void classification_test_cos_set_drop(void);
diff --git a/test/validation/classification/odp_classification_basic.c 
b/test/validation/classification/odp_classification_basic.c
index 81077b6..1336955 100644
--- a/test/validation/classification/odp_classification_basic.c
+++ b/test/validation/classification/odp_classification_basic.c
@@ -74,28 +74,40 @@ void classification_test_create_pmr_match(void)
odp_pmr_t pmr;
uint16_t val;
uint16_t mask;
+   int retval;
odp_pmr_match_t match;
+   odp_cos_t default_cos;
+   odp_cos_t cos;
+   odp_queue_t default_queue;
+   odp_queue_t queue;
+   odp_pool_t default_pool;
+   odp_pool_t pool;
+   odp_pool_t pkt_pool;
+   odp_cls_cos_param_t cls_param;
+   odp_pktio_t pktio;
 
-   val = 1024;
-   mask = 0x;
-   match.term = find_first_supported_l3_pmr();
-   match.val = 
-   match.mask = 
-   match.val_sz = sizeof(val);
+   pkt_pool = pool_create("pkt_pool");
+   CU_ASSERT_FATAL(pkt_pool != ODP_POOL_INVALID);
 
-   pmr = odp_pmr_create();
-   CU_ASSERT(pmr != ODP_PMR_INVAL);
-   CU_ASSERT(odp_pmr_to_u64(pmr) != odp_pmr_to_u64(ODP_PMR_INVAL));
-   odp_pmr_destroy(pmr);
-}
+   pktio = create_pktio(ODP_QUEUE_TYPE_SCHED, pkt_pool);
+   CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID);
 
-void classification_test_destroy_pmr(void)
-{
-   odp_pmr_t pmr;
-   uint16_t val;
-   uint16_t mask;
-   int retval;
-   odp_pmr_match_t match;
+   configure_default_cos(pktio, _cos,
+ _queue, _pool);
+
+   queue = queue_create("pmr_match", true);
+   CU_ASSERT(queue != ODP_QUEUE_INVALID);
+
+   pool = pool_create("pmr_match");
+   CU_ASSERT_FATAL(pool != ODP_POOL_INVALID);
+
+   odp_cls_cos_param_init(_param);
+   cls_param.pool = pool;
+   cls_param.queue = queue;
+   cls_param.drop_policy = ODP_COS_DROP_POOL;
+
+   cos = odp_cls_cos_create("pmr_match", _param);
+   CU_ASSERT(cos != ODP_COS_INVALID);
 
val = 1024;
mask = 0x;
@@ -104,12 +116,25 @@ void classification_test_destroy_pmr(void)
match.mask = 
match.val_sz = sizeof(val);
 
-   pmr = odp_pmr_create();
-   retval = odp_pmr_destroy(pmr);
+   pmr = odp_cls_pmr_create(, 1, default_cos, cos);
+   CU_ASSERT(pmr != ODP_PMR_INVAL);
+   CU_ASSERT(odp_pmr_to_u64(pmr) != odp_pmr_to_u64(ODP_PMR_INVAL));
+   /* destroy the created PMR */
+   retval = odp_cls_pmr_destroy(pmr);
CU_ASSERT(retval == 0);
-   retval = odp_pmr_destroy(ODP_PMR_INVAL);
-   retval = odp_pmr_destroy(ODP_PMR_INVAL);
+
+   /* destroy an INVALID PMR */
+   retval = odp_cls_pmr_destroy(ODP_PMR_INVAL);
CU_ASSERT(retval < 0);
+
+   odp_queue_destroy(queue);
+   odp_pool_destroy(pool);
+   odp_pool_destroy(pkt_pool);
+   odp_cos_destroy(cos);
+   odp_queue_destroy(default_queue);
+   odp_pool_destroy(default_pool);
+   odp_cos_destroy(default_cos);
+   odp_pktio_close(pktio);
 }
 
 void classification_test_cos_set_queue(void)
@@ -224,39 +249,44 @@ void classification_test_cos_set_drop(void)
 
 void classification_test_pmr_match_set_create(void)
 {
-   odp_pmr_set_t pmr_set;
+   odp_pmr_t pmr_set;
int retval;
odp_pmr_match_t pmr_terms[PMR_SET_NUM];
+   odp_cos_t default_cos;
+   odp_cos_t cos;
+   odp_queue_t default_queue;
+   odp_queue_t queue;
+   odp_pool_t default_pool;
+   odp_pool_t pool;
+   odp_pool_t pkt_pool;
+   odp_cls_cos_param_t cls_param;
+   odp_pktio_t pktio;
uint16_t val = 1024;
uint16_t mask = 0x;
int i;
-   for (i = 0; i < PMR_SET_NUM; i++) {
-

[lng-odp] [API-NEXT PATCHv5 1/4] api: classification: add pmr create api

2016-02-03 Thread Balasubramanian Manoharan
Packet match rule creation is modified to include source and destination
class of service. Removes the ability to add any class of service directly
with pktio. If a PMR needs to be applied at the pktio level the same
should be applied to default class of service.

Packet match rule destroy function is updated to removes the link between
the source and destination class of service.

odp_pmr_match_set_t handle is removed and pmr create function is modified
to take number of terms and composite rule is created by providing more
than one term.

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
Reviewed-by: Petri Savolainen <petri.savolai...@nokia.com>
---
 include/odp/api/classification.h | 140 +--
 1 file changed, 30 insertions(+), 110 deletions(-)

diff --git a/include/odp/api/classification.h b/include/odp/api/classification.h
index f46912e..076b3de 100644
--- a/include/odp/api/classification.h
+++ b/include/odp/api/classification.h
@@ -50,16 +50,11 @@ extern "C" {
 /**
  * @def ODP_PMR_INVAL
  * Invalid odp_pmr_t value.
- * This value is returned from odp_pmr_create()
+ * This value is returned from odp_cls_pmr_create()
  * function on failure.
  */
 
 /**
- * @def ODP_PMR_SET_INVAL
- * Invalid odp_pmr_set_t value.
- */
-
-/**
  * class of service packet drop policies
  */
 typedef enum {
@@ -286,50 +281,46 @@ typedef struct odp_pmr_match_t {
 } odp_pmr_match_t;
 
 /**
- * Create a packet match rule with mask and value
+ * Create a packet match rule between source and destination class of service.
+ * This packet matching rule is applied on all packets arriving at the source
+ * class of service and packets satisfying this PMR are sent to the destination
+ * class of service.
+ * A composite PMR rule is created when the number of terms in the match rule
+ * is more than one. The composite rule is considered as matching only if
+ * the packet satisfies all the terms in Packet Match Rule.
+ * The underlying platform may not support all or any specific combination
+ * of value match rules, and the application should take care
+ * of inspecting the return value when installing such rules, and perform
+ * appropriate fallback action.
  *
- * @param[in]  match   packet matching rule definition
+ * @param[in]  terms   Array of odp_pmr_match_t entries, one entry per
+ * term desired.
+ * @param[in]  num_terms   Number of terms in the match rule.
+ * @param[in]  src_cos source CoS handle
+ * @param[in]  dst_cos destination CoS handle
  *
- * @return Handle of the matching rule
- * @retval ODP_PMR_INVAL on failure
+ * @return Handle to the Packet Match Rule.
+ * @retval ODP_PMR_INVAL on failure
  */
-odp_pmr_t odp_pmr_create(const odp_pmr_match_t *match);
+odp_pmr_t odp_cls_pmr_create(const odp_pmr_match_t *terms, int num_terms,
+odp_cos_t src_cos, odp_cos_t dst_cos);
 
 /**
- * Invalidate a packet match rule and vacate its resources
+ * Function to destroy a packet match rule
+ * Destroying a PMR removes the link between the source and destination
+ * class of service and this PMR will no longer be applied for packets arriving
+ * at the source class of service. All the resource associated with the PMR
+ * be release but the class of service will remain intact.
+ * Depending on the implementation details, destroying a composite rule
+ * may not guarantee the availability of hardware resources to create the
+ * same or essentially similar rule.
  *
  * @param[in]  pmr_id  Identifier of the PMR to be destroyed
  *
  * @retval 0 on success
  * @retval <0 on failure
  */
-int odp_pmr_destroy(odp_pmr_t pmr_id);
-
-/**
- * Apply a PMR to a pktio to assign a CoS.
- *
- * @param[in]  pmr_id  PMR to be activated
- * @param[in]  src_pktio   pktio to which this PMR is to be applied
- * @param[in]  dst_cos CoS to be assigned by this PMR
- *
- * @retval 0 on success
- * @retval <0 on failure
- */
-int odp_pktio_pmr_cos(odp_pmr_t pmr_id,
- odp_pktio_t src_pktio, odp_cos_t dst_cos);
-
-/**
- * Cascade a PMR to refine packets from one CoS to another.
- *
- * @param[in]  pmr_id  PMR to be activated
- * @param[in]  src_cos CoS to be filtered
- * @param[in]  dst_cos CoS to be assigned to packets filtered
- * from src_cos that match pmr_id.
- *
- * @retval 0 on success
- * @retval <0 on failure
- */
-int odp_cos_pmr_cos(odp_pmr_t pmr_id, odp_cos_t src_cos, odp_cos_t dst_cos);
+int odp_cls_pmr_destroy(odp_pmr_t pmr_id);
 
 /**
  * Inquire about matching terms supported by the classifier
@@ -346,64 +337,6 @@ unsigned long long odp_pmr_terms_cap(void);
 unsigned odp_pmr_terms_avail(void);
 
 /**
- * @typedef odp_pmr_set_t
- * An opaque handle t

[lng-odp] [API-NEXT PATCHv4 1/4] api: classification: add pmr create api

2016-02-03 Thread Balasubramanian Manoharan
Packet match rule creation is modified to include source and destination
class of service. Removes the ability to add any class of service directly
with pktio. If a PMR needs to be applied at the pktio level the same
should be applied to default class of service.

Packet match rule destroy function is updated to removes the link between
the source and destination class of service.

odp_pmr_match_set_t handle is removed and pmr create function is modified
to take number of terms and composite rule is created by providing more
than one term.

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
Reviewed-by: Petri Savolainen <petri.savolai...@nokia.com>
---
 include/odp/api/classification.h | 140 +--
 1 file changed, 30 insertions(+), 110 deletions(-)

diff --git a/include/odp/api/classification.h b/include/odp/api/classification.h
index f46912e..076b3de 100644
--- a/include/odp/api/classification.h
+++ b/include/odp/api/classification.h
@@ -50,16 +50,11 @@ extern "C" {
 /**
  * @def ODP_PMR_INVAL
  * Invalid odp_pmr_t value.
- * This value is returned from odp_pmr_create()
+ * This value is returned from odp_cls_pmr_create()
  * function on failure.
  */
 
 /**
- * @def ODP_PMR_SET_INVAL
- * Invalid odp_pmr_set_t value.
- */
-
-/**
  * class of service packet drop policies
  */
 typedef enum {
@@ -286,50 +281,46 @@ typedef struct odp_pmr_match_t {
 } odp_pmr_match_t;
 
 /**
- * Create a packet match rule with mask and value
+ * Create a packet match rule between source and destination class of service.
+ * This packet matching rule is applied on all packets arriving at the source
+ * class of service and packets satisfying this PMR are sent to the destination
+ * class of service.
+ * A composite PMR rule is created when the number of terms in the match rule
+ * is more than one. The composite rule is considered as matching only if
+ * the packet satisfies all the terms in Packet Match Rule.
+ * The underlying platform may not support all or any specific combination
+ * of value match rules, and the application should take care
+ * of inspecting the return value when installing such rules, and perform
+ * appropriate fallback action.
  *
- * @param[in]  match   packet matching rule definition
+ * @param[in]  terms   Array of odp_pmr_match_t entries, one entry per
+ * term desired.
+ * @param[in]  num_terms   Number of terms in the match rule.
+ * @param[in]  src_cos source CoS handle
+ * @param[in]  dst_cos destination CoS handle
  *
- * @return Handle of the matching rule
- * @retval ODP_PMR_INVAL on failure
+ * @return Handle to the Packet Match Rule.
+ * @retval ODP_PMR_INVAL on failure
  */
-odp_pmr_t odp_pmr_create(const odp_pmr_match_t *match);
+odp_pmr_t odp_cls_pmr_create(const odp_pmr_match_t *terms, int num_terms,
+odp_cos_t src_cos, odp_cos_t dst_cos);
 
 /**
- * Invalidate a packet match rule and vacate its resources
+ * Function to destroy a packet match rule
+ * Destroying a PMR removes the link between the source and destination
+ * class of service and this PMR will no longer be applied for packets arriving
+ * at the source class of service. All the resource associated with the PMR
+ * be release but the class of service will remain intact.
+ * Depending on the implementation details, destroying a composite rule
+ * may not guarantee the availability of hardware resources to create the
+ * same or essentially similar rule.
  *
  * @param[in]  pmr_id  Identifier of the PMR to be destroyed
  *
  * @retval 0 on success
  * @retval <0 on failure
  */
-int odp_pmr_destroy(odp_pmr_t pmr_id);
-
-/**
- * Apply a PMR to a pktio to assign a CoS.
- *
- * @param[in]  pmr_id  PMR to be activated
- * @param[in]  src_pktio   pktio to which this PMR is to be applied
- * @param[in]  dst_cos CoS to be assigned by this PMR
- *
- * @retval 0 on success
- * @retval <0 on failure
- */
-int odp_pktio_pmr_cos(odp_pmr_t pmr_id,
- odp_pktio_t src_pktio, odp_cos_t dst_cos);
-
-/**
- * Cascade a PMR to refine packets from one CoS to another.
- *
- * @param[in]  pmr_id  PMR to be activated
- * @param[in]  src_cos CoS to be filtered
- * @param[in]  dst_cos CoS to be assigned to packets filtered
- * from src_cos that match pmr_id.
- *
- * @retval 0 on success
- * @retval <0 on failure
- */
-int odp_cos_pmr_cos(odp_pmr_t pmr_id, odp_cos_t src_cos, odp_cos_t dst_cos);
+int odp_cls_pmr_destroy(odp_pmr_t pmr_id);
 
 /**
  * Inquire about matching terms supported by the classifier
@@ -346,64 +337,6 @@ unsigned long long odp_pmr_terms_cap(void);
 unsigned odp_pmr_terms_avail(void);
 
 /**
- * @typedef odp_pmr_set_t
- * An opaque handle t

[lng-odp] [API-NEXT PATCHv4 4/4] example: classifier: modifications for pmr create api

2016-02-03 Thread Balasubramanian Manoharan
Changes for packet match rule create function.

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 example/classifier/odp_classifier.c | 38 -
 1 file changed, 21 insertions(+), 17 deletions(-)

diff --git a/example/classifier/odp_classifier.c 
b/example/classifier/odp_classifier.c
index 57a58d9..8e0a200 100644
--- a/example/classifier/odp_classifier.c
+++ b/example/classifier/odp_classifier.c
@@ -87,8 +87,8 @@ static void swap_pkt_addrs(odp_packet_t pkt_tbl[], unsigned 
len);
 static void parse_args(int argc, char *argv[], appl_args_t *appl_args);
 static void print_info(char *progname, appl_args_t *appl_args);
 static void usage(char *progname);
-static void configure_cos(odp_pktio_t pktio, appl_args_t *args);
-static void configure_default_cos(odp_pktio_t pktio, appl_args_t *args);
+static void configure_cos(odp_cos_t default_cos, appl_args_t *args);
+static odp_cos_t configure_default_cos(odp_pktio_t pktio, appl_args_t *args);
 static int convert_str_to_pmr_enum(char *token, odp_pmr_term_t *term,
   uint32_t *offset);
 static int parse_pmr_policy(appl_args_t *appl_args, char *argv[], char 
*optarg);
@@ -355,7 +355,7 @@ static void *pktio_receive_thread(void *arg)
return NULL;
 }
 
-static void configure_default_cos(odp_pktio_t pktio, appl_args_t *args)
+static odp_cos_t configure_default_cos(odp_pktio_t pktio, appl_args_t *args)
 {
odp_queue_param_t qparam;
const char *queue_name = "DefaultQueue";
@@ -417,9 +417,10 @@ static void configure_default_cos(odp_pktio_t pktio, 
appl_args_t *args)
odp_atomic_init_u64([args->policy_count].queue_pkt_count, 0);
odp_atomic_init_u64([args->policy_count].pool_pkt_count, 0);
args->policy_count++;
+   return cos_default;
 }
 
-static void configure_cos(odp_pktio_t pktio, appl_args_t *args)
+static void configure_cos(odp_cos_t default_cos, appl_args_t *args)
 {
char cos_name[ODP_COS_NAME_LEN];
char queue_name[ODP_QUEUE_NAME_LEN];
@@ -433,15 +434,6 @@ static void configure_cos(odp_pktio_t pktio, appl_args_t 
*args)
for (i = 0; i < args->policy_count; i++) {
stats = >stats[i];
 
-   const odp_pmr_match_t match = {
-   .term = stats->rule.term,
-   .val = >rule.val,
-   .mask = >rule.mask,
-   .val_sz = stats->rule.val_sz,
-   .offset = stats->rule.offset
-   };
-
-   stats->pmr = odp_pmr_create();
odp_queue_param_init();
qparam.type   = ODP_QUEUE_TYPE_SCHED;
qparam.sched.prio = i % odp_schedule_num_prio();
@@ -480,7 +472,17 @@ static void configure_cos(odp_pktio_t pktio, appl_args_t 
*args)
cls_param.drop_policy = ODP_COS_DROP_POOL;
stats->cos = odp_cls_cos_create(cos_name, _param);
 
-   if (0 > odp_pktio_pmr_cos(stats->pmr, pktio, stats->cos)) {
+   const odp_pmr_match_t match = {
+   .term = stats->rule.term,
+   .val = >rule.val,
+   .mask = >rule.mask,
+   .val_sz = stats->rule.val_sz,
+   .offset = stats->rule.offset
+   };
+
+   stats->pmr = odp_cls_pmr_create(, 1, default_cos,
+   stats->cos);
+   if (stats->pmr == ODP_PMR_INVAL) {
EXAMPLE_ERR("odp_pktio_pmr_cos failed");
exit(EXIT_FAILURE);
}
@@ -505,6 +507,7 @@ int main(int argc, char *argv[])
odp_pool_param_t params;
odp_pktio_t pktio;
appl_args_t *args;
+   odp_cos_t default_cos;
odp_queue_t inq;
odp_shm_t shm;
 
@@ -576,10 +579,10 @@ int main(int argc, char *argv[])
/* create pktio per interface */
pktio = create_pktio(args->if_name, pool);
 
-   configure_cos(pktio, args);
-
/* configure default Cos */
-   configure_default_cos(pktio, args);
+   default_cos = configure_default_cos(pktio, args);
+
+   configure_cos(default_cos, args);
 
if (odp_pktio_start(pktio)) {
EXAMPLE_ERR("Error: unable to start pktio.\n");
@@ -606,6 +609,7 @@ int main(int argc, char *argv[])
print_cls_statistics(args);
 
for (i = 0; i < args->policy_count; i++) {
+   odp_cls_pmr_destroy(args->stats[i].pmr);
odp_cos_destroy(args->stats[i].cos);
odp_pool_destroy(args->stats[i].pool);
odp_queue_destroy(args->stats[i].queue);
-- 
1.9.1

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


[lng-odp] [API-NEXT PATCHv4 0/4] add PMR create API

2016-02-03 Thread Balasubramanian Manoharan
Packet match rule creation is modified to include source and destination
class of service. Removes the ability to add any class of service directly
with pktio. If a PMR needs to be applied at the pktio level the same
should be applied to default class of service.

Packet match rule destroy function is updated to removes the link between
the source and destination class of service.

odp_pmr_match_set_t handle is removed and pmr create function is modified
to take number of terms and composite rule is created by providing more
than one term.

Since this patch changes the API, the entire set has to be merged before
applying to prevent compilation error in the middle.

v4: Rebase to HEAD

v3: Incorporates Review comments from Petri
 - API reviewed-by from Petri

v2: Removes pmr match set
   - Modifies pmr create function to create composite pmr rules

v1: Initial version for pmr create api change
   - Introduces pmr create api and linux-generic changes

Balasubramanian Manoharan (4):
  api: classification: add pmr create api
  linux-generic: classification: implement pmr create api
  validation: classification: adds validation suite for pmr create api
  example: classifier: modifications for pmr create api

 example/classifier/odp_classifier.c|  38 +--
 include/odp/api/classification.h   | 140 ++---
 .../include/odp_classification_datamodel.h |  48 +---
 .../include/odp_classification_internal.h  |  21 +-
 platform/linux-generic/odp_classification.c| 314 +
 platform/linux-generic/odp_packet_io.c |  24 +-
 test/validation/classification/classification.h|   1 -
 .../classification/odp_classification_basic.c  | 141 +
 .../classification/odp_classification_common.c |  26 ++
 .../classification/odp_classification_test_pmr.c   | 240 ++--
 .../classification/odp_classification_tests.c  |  87 +++---
 .../classification/odp_classification_testsuites.h |   4 +-
 12 files changed, 388 insertions(+), 696 deletions(-)

-- 
1.9.1

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


[lng-odp] [API-NEXT PATCHv4 2/4] linux-generic: classification: implement pmr create api

2016-02-03 Thread Balasubramanian Manoharan
Implements packet match rule create functions.
If a packet match rule needs to be applied at the pktio level it has to be
configured to the default class of service.

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 .../include/odp_classification_datamodel.h |  48 +---
 .../include/odp_classification_internal.h  |  21 +-
 platform/linux-generic/odp_classification.c| 314 +
 platform/linux-generic/odp_packet_io.c |  24 +-
 4 files changed, 92 insertions(+), 315 deletions(-)

diff --git a/platform/linux-generic/include/odp_classification_datamodel.h 
b/platform/linux-generic/include/odp_classification_datamodel.h
index 27d8a52..6301f18 100644
--- a/platform/linux-generic/include/odp_classification_datamodel.h
+++ b/platform/linux-generic/include/odp_classification_datamodel.h
@@ -28,14 +28,12 @@ extern "C" {
 
 /* Maximum Class Of Service Entry */
 #define ODP_COS_MAX_ENTRY  64
-/* Maximum PMR Set Entry */
-#define ODP_PMRSET_MAX_ENTRY   64
 /* Maximum PMR Entry */
-#define ODP_PMR_MAX_ENTRY  64
+#define ODP_PMR_MAX_ENTRY  256
 /* Maximum PMR Terms in a PMR Set */
 #define ODP_PMRTERM_MAX8
 /* Maximum PMRs attached in PKTIO Level */
-#define ODP_PKTIO_MAX_PMR  8
+#define ODP_PMR_PER_COS_MAX8
 /* L2 Priority Bits */
 #define ODP_COS_L2_QOS_BITS3
 /* Max L2 QoS value */
@@ -67,15 +65,16 @@ Class Of Service
 struct cos_s {
queue_entry_t *queue;   /* Associated Queue */
pool_entry_t *pool; /* Associated Buffer pool */
-   union pmr_u *pmr;   /* Chained PMR */
-   union cos_u *linked_cos;/* CoS linked with the PMR */
+   union pmr_u *pmr[ODP_PMR_PER_COS_MAX];  /* Chained PMR */
+   union cos_u *linked_cos[ODP_PMR_PER_COS_MAX]; /* Chained CoS with PMR*/
uint32_t valid; /* validity Flag */
-   odp_cls_drop_t drop_policy; /* Associated Drop Policy */
+   odp_cls_drop_t drop_policy; /* Associated Drop Policy */
odp_queue_group_t queue_group;  /* Associated Queue Group */
odp_cos_flow_set_t flow_set;/* Assigned Flow Set */
-   char name[ODP_COS_NAME_LEN];/* name */
size_t headroom;/* Headroom for this CoS */
odp_spinlock_t lock;/* cos lock */
+   odp_atomic_u32_t num_rule;  /* num of PMRs attached with this CoS */
+   char name[ODP_COS_NAME_LEN];/* name */
 };
 
 typedef union cos_u {
@@ -93,7 +92,9 @@ struct pmr_s {
odp_atomic_u32_t count; /* num of packets matching this rule */
uint32_t num_pmr;   /* num of PMR Term Values*/
odp_spinlock_t lock;/* pmr lock*/
-   pmr_term_value_t  pmr_term_value[1];/* Associated PMR Term */
+   cos_t *src_cos; /* source CoS where PMR is attached */
+   pmr_term_value_t  pmr_term_value[ODP_PMRTERM_MAX];
+   /* List of associated PMR Terms */
 };
 
 typedef union pmr_u {
@@ -102,24 +103,6 @@ typedef union pmr_u {
 } pmr_t;
 
 /**
-Packet Matching Rule Set
-
-This structure is implemented as a extension over struct pmr_s
-In order to use same pointer to access both pmr_s and pmr_set_s
-'num_pmr' value is used to differentiate between pmr_s and pmr_set_s struct
-**/
-struct pmr_set_s {
-   pmr_t pmr;
-   pmr_term_value_t  pmr_term_value[ODP_PMRTERM_MAX - 1];
-   /* List of associated PMR Terms */
-};
-
-typedef union pmr_set_u {
-   struct pmr_set_s s;
-   uint8_t pad[ODP_CACHE_LINE_SIZE_ROUNDUP(sizeof(struct pmr_set_s))];
-} pmr_set_t;
-
-/**
 L2 QoS and CoS Map
 
 This structure holds the mapping between L2 QoS value and
@@ -148,10 +131,6 @@ This structure is stored in pktio_entry and holds all
 the classifier configuration value.
 **/
 typedef struct classifier {
-   odp_spinlock_t lock;/*pktio_cos lock */
-   uint32_t num_pmr;   /* num of PMRs linked to given PKTIO*/
-   pmr_t *pmr[ODP_PKTIO_MAX_PMR];  /* PMRs linked with this PKTIO */
-   cos_t *cos[ODP_PKTIO_MAX_PMR];  /* CoS linked with this PKTIO */
cos_t *error_cos;   /* Associated Error CoS */
cos_t *default_cos; /* Associated Default CoS */
uint32_t l3_precedence; /* L3 QoS precedence */
@@ -171,13 +150,6 @@ typedef struct odp_cos_table {
 } cos_tbl_t;
 
 /**
-PMR set table
-**/
-typedef struct pmr_set_tbl {
-   pmr_set_t pmr_set[ODP_PMRSET_MAX_ENTRY];
-} pmr_set_tbl_t;
-
-/**
 PMR table
 **/
 typedef struct pmr_tbl {
diff --git a/platform/linux-generic/include/odp_classification_internal.h 
b/platform/linux-generic/include/odp_classification_internal.h
index 1e8f291..3fa18ad 100644
--- a/platform/linux-generic/include/odp_classification_internal.h
+++ b/platform/linux

[lng-odp] [API-NEXT PATCHv4 3/4] validation: classification: adds validation suite for pmr create api

2016-02-03 Thread Balasubramanian Manoharan
Adds validation suite for packet match rule create functions.

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 test/validation/classification/classification.h|   1 -
 .../classification/odp_classification_basic.c  | 141 +++-
 .../classification/odp_classification_common.c |  26 +++
 .../classification/odp_classification_test_pmr.c   | 240 -
 .../classification/odp_classification_tests.c  |  87 
 .../classification/odp_classification_testsuites.h |   4 +-
 6 files changed, 245 insertions(+), 254 deletions(-)

diff --git a/test/validation/classification/classification.h 
b/test/validation/classification/classification.h
index 5508af7..c987cca 100644
--- a/test/validation/classification/classification.h
+++ b/test/validation/classification/classification.h
@@ -59,7 +59,6 @@
 void classification_test_create_cos(void);
 void classification_test_destroy_cos(void);
 void classification_test_create_pmr_match(void);
-void classification_test_destroy_pmr(void);
 void classification_test_cos_set_queue(void);
 void classification_test_cos_set_pool(void);
 void classification_test_cos_set_drop(void);
diff --git a/test/validation/classification/odp_classification_basic.c 
b/test/validation/classification/odp_classification_basic.c
index 81077b6..1336955 100644
--- a/test/validation/classification/odp_classification_basic.c
+++ b/test/validation/classification/odp_classification_basic.c
@@ -74,28 +74,40 @@ void classification_test_create_pmr_match(void)
odp_pmr_t pmr;
uint16_t val;
uint16_t mask;
+   int retval;
odp_pmr_match_t match;
+   odp_cos_t default_cos;
+   odp_cos_t cos;
+   odp_queue_t default_queue;
+   odp_queue_t queue;
+   odp_pool_t default_pool;
+   odp_pool_t pool;
+   odp_pool_t pkt_pool;
+   odp_cls_cos_param_t cls_param;
+   odp_pktio_t pktio;
 
-   val = 1024;
-   mask = 0x;
-   match.term = find_first_supported_l3_pmr();
-   match.val = 
-   match.mask = 
-   match.val_sz = sizeof(val);
+   pkt_pool = pool_create("pkt_pool");
+   CU_ASSERT_FATAL(pkt_pool != ODP_POOL_INVALID);
 
-   pmr = odp_pmr_create();
-   CU_ASSERT(pmr != ODP_PMR_INVAL);
-   CU_ASSERT(odp_pmr_to_u64(pmr) != odp_pmr_to_u64(ODP_PMR_INVAL));
-   odp_pmr_destroy(pmr);
-}
+   pktio = create_pktio(ODP_QUEUE_TYPE_SCHED, pkt_pool);
+   CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID);
 
-void classification_test_destroy_pmr(void)
-{
-   odp_pmr_t pmr;
-   uint16_t val;
-   uint16_t mask;
-   int retval;
-   odp_pmr_match_t match;
+   configure_default_cos(pktio, _cos,
+ _queue, _pool);
+
+   queue = queue_create("pmr_match", true);
+   CU_ASSERT(queue != ODP_QUEUE_INVALID);
+
+   pool = pool_create("pmr_match");
+   CU_ASSERT_FATAL(pool != ODP_POOL_INVALID);
+
+   odp_cls_cos_param_init(_param);
+   cls_param.pool = pool;
+   cls_param.queue = queue;
+   cls_param.drop_policy = ODP_COS_DROP_POOL;
+
+   cos = odp_cls_cos_create("pmr_match", _param);
+   CU_ASSERT(cos != ODP_COS_INVALID);
 
val = 1024;
mask = 0x;
@@ -104,12 +116,25 @@ void classification_test_destroy_pmr(void)
match.mask = 
match.val_sz = sizeof(val);
 
-   pmr = odp_pmr_create();
-   retval = odp_pmr_destroy(pmr);
+   pmr = odp_cls_pmr_create(, 1, default_cos, cos);
+   CU_ASSERT(pmr != ODP_PMR_INVAL);
+   CU_ASSERT(odp_pmr_to_u64(pmr) != odp_pmr_to_u64(ODP_PMR_INVAL));
+   /* destroy the created PMR */
+   retval = odp_cls_pmr_destroy(pmr);
CU_ASSERT(retval == 0);
-   retval = odp_pmr_destroy(ODP_PMR_INVAL);
-   retval = odp_pmr_destroy(ODP_PMR_INVAL);
+
+   /* destroy an INVALID PMR */
+   retval = odp_cls_pmr_destroy(ODP_PMR_INVAL);
CU_ASSERT(retval < 0);
+
+   odp_queue_destroy(queue);
+   odp_pool_destroy(pool);
+   odp_pool_destroy(pkt_pool);
+   odp_cos_destroy(cos);
+   odp_queue_destroy(default_queue);
+   odp_pool_destroy(default_pool);
+   odp_cos_destroy(default_cos);
+   odp_pktio_close(pktio);
 }
 
 void classification_test_cos_set_queue(void)
@@ -224,39 +249,44 @@ void classification_test_cos_set_drop(void)
 
 void classification_test_pmr_match_set_create(void)
 {
-   odp_pmr_set_t pmr_set;
+   odp_pmr_t pmr_set;
int retval;
odp_pmr_match_t pmr_terms[PMR_SET_NUM];
+   odp_cos_t default_cos;
+   odp_cos_t cos;
+   odp_queue_t default_queue;
+   odp_queue_t queue;
+   odp_pool_t default_pool;
+   odp_pool_t pool;
+   odp_pool_t pkt_pool;
+   odp_cls_cos_param_t cls_param;
+   odp_pktio_t pktio;
uint16_t val = 1024;
uint16_t mask = 0x;
int i;
-   for (i = 0; i < PMR_SET_NUM; i++) {
-

[lng-odp] [API-NEXT PATCHv3 1/4] api: classification: add pmr create api

2016-02-02 Thread Balasubramanian Manoharan
Packet match rule creation is modified to include source and destination
class of service. Removes the ability to add any class of service directly
with pktio. If a PMR needs to be applied at the pktio level the same
should be applied to default class of service.

Packet match rule destroy function is updated to removes the link between
the source and destination class of service.

odp_pmr_match_set_t handle is removed and pmr create function is modified
to take number of terms and composite rule is created by providing more
than one term.

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
v3: Incorporate review comments from Petri
v2: remove pmr match set api

 include/odp/api/classification.h | 140 +--
 1 file changed, 30 insertions(+), 110 deletions(-)

diff --git a/include/odp/api/classification.h b/include/odp/api/classification.h
index f46912e..076b3de 100644
--- a/include/odp/api/classification.h
+++ b/include/odp/api/classification.h
@@ -50,16 +50,11 @@ extern "C" {
 /**
  * @def ODP_PMR_INVAL
  * Invalid odp_pmr_t value.
- * This value is returned from odp_pmr_create()
+ * This value is returned from odp_cls_pmr_create()
  * function on failure.
  */
 
 /**
- * @def ODP_PMR_SET_INVAL
- * Invalid odp_pmr_set_t value.
- */
-
-/**
  * class of service packet drop policies
  */
 typedef enum {
@@ -286,50 +281,46 @@ typedef struct odp_pmr_match_t {
 } odp_pmr_match_t;
 
 /**
- * Create a packet match rule with mask and value
+ * Create a packet match rule between source and destination class of service.
+ * This packet matching rule is applied on all packets arriving at the source
+ * class of service and packets satisfying this PMR are sent to the destination
+ * class of service.
+ * A composite PMR rule is created when the number of terms in the match rule
+ * is more than one. The composite rule is considered as matching only if
+ * the packet satisfies all the terms in Packet Match Rule.
+ * The underlying platform may not support all or any specific combination
+ * of value match rules, and the application should take care
+ * of inspecting the return value when installing such rules, and perform
+ * appropriate fallback action.
  *
- * @param[in]  match   packet matching rule definition
+ * @param[in]  terms   Array of odp_pmr_match_t entries, one entry per
+ * term desired.
+ * @param[in]  num_terms   Number of terms in the match rule.
+ * @param[in]  src_cos source CoS handle
+ * @param[in]  dst_cos destination CoS handle
  *
- * @return Handle of the matching rule
- * @retval ODP_PMR_INVAL on failure
+ * @return Handle to the Packet Match Rule.
+ * @retval ODP_PMR_INVAL on failure
  */
-odp_pmr_t odp_pmr_create(const odp_pmr_match_t *match);
+odp_pmr_t odp_cls_pmr_create(const odp_pmr_match_t *terms, int num_terms,
+odp_cos_t src_cos, odp_cos_t dst_cos);
 
 /**
- * Invalidate a packet match rule and vacate its resources
+ * Function to destroy a packet match rule
+ * Destroying a PMR removes the link between the source and destination
+ * class of service and this PMR will no longer be applied for packets arriving
+ * at the source class of service. All the resource associated with the PMR
+ * be release but the class of service will remain intact.
+ * Depending on the implementation details, destroying a composite rule
+ * may not guarantee the availability of hardware resources to create the
+ * same or essentially similar rule.
  *
  * @param[in]  pmr_id  Identifier of the PMR to be destroyed
  *
  * @retval 0 on success
  * @retval <0 on failure
  */
-int odp_pmr_destroy(odp_pmr_t pmr_id);
-
-/**
- * Apply a PMR to a pktio to assign a CoS.
- *
- * @param[in]  pmr_id  PMR to be activated
- * @param[in]  src_pktio   pktio to which this PMR is to be applied
- * @param[in]  dst_cos CoS to be assigned by this PMR
- *
- * @retval 0 on success
- * @retval <0 on failure
- */
-int odp_pktio_pmr_cos(odp_pmr_t pmr_id,
- odp_pktio_t src_pktio, odp_cos_t dst_cos);
-
-/**
- * Cascade a PMR to refine packets from one CoS to another.
- *
- * @param[in]  pmr_id  PMR to be activated
- * @param[in]  src_cos CoS to be filtered
- * @param[in]  dst_cos CoS to be assigned to packets filtered
- * from src_cos that match pmr_id.
- *
- * @retval 0 on success
- * @retval <0 on failure
- */
-int odp_cos_pmr_cos(odp_pmr_t pmr_id, odp_cos_t src_cos, odp_cos_t dst_cos);
+int odp_cls_pmr_destroy(odp_pmr_t pmr_id);
 
 /**
  * Inquire about matching terms supported by the classifier
@@ -346,64 +337,6 @@ unsigned long long odp_pmr_terms_cap(void);
 unsigned odp_pmr_terms_avail(void);
 
 /**
- * @typedef odp_pmr_set_t
- * An opa

[lng-odp] [API-NEXT PATCHv3 2/4] linux-generic: classification: implement pmr create api

2016-02-02 Thread Balasubramanian Manoharan
Implements packet match rule create functions.
If a packet match rule needs to be applied at the pktio level it has to be
configured to the default class of service.

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 .../include/odp_classification_datamodel.h |  48 +---
 .../include/odp_classification_internal.h  |  21 +-
 platform/linux-generic/odp_classification.c| 314 +
 platform/linux-generic/odp_packet_io.c |  24 +-
 4 files changed, 92 insertions(+), 315 deletions(-)

diff --git a/platform/linux-generic/include/odp_classification_datamodel.h 
b/platform/linux-generic/include/odp_classification_datamodel.h
index 27d8a52..6301f18 100644
--- a/platform/linux-generic/include/odp_classification_datamodel.h
+++ b/platform/linux-generic/include/odp_classification_datamodel.h
@@ -28,14 +28,12 @@ extern "C" {
 
 /* Maximum Class Of Service Entry */
 #define ODP_COS_MAX_ENTRY  64
-/* Maximum PMR Set Entry */
-#define ODP_PMRSET_MAX_ENTRY   64
 /* Maximum PMR Entry */
-#define ODP_PMR_MAX_ENTRY  64
+#define ODP_PMR_MAX_ENTRY  256
 /* Maximum PMR Terms in a PMR Set */
 #define ODP_PMRTERM_MAX8
 /* Maximum PMRs attached in PKTIO Level */
-#define ODP_PKTIO_MAX_PMR  8
+#define ODP_PMR_PER_COS_MAX8
 /* L2 Priority Bits */
 #define ODP_COS_L2_QOS_BITS3
 /* Max L2 QoS value */
@@ -67,15 +65,16 @@ Class Of Service
 struct cos_s {
queue_entry_t *queue;   /* Associated Queue */
pool_entry_t *pool; /* Associated Buffer pool */
-   union pmr_u *pmr;   /* Chained PMR */
-   union cos_u *linked_cos;/* CoS linked with the PMR */
+   union pmr_u *pmr[ODP_PMR_PER_COS_MAX];  /* Chained PMR */
+   union cos_u *linked_cos[ODP_PMR_PER_COS_MAX]; /* Chained CoS with PMR*/
uint32_t valid; /* validity Flag */
-   odp_cls_drop_t drop_policy; /* Associated Drop Policy */
+   odp_cls_drop_t drop_policy; /* Associated Drop Policy */
odp_queue_group_t queue_group;  /* Associated Queue Group */
odp_cos_flow_set_t flow_set;/* Assigned Flow Set */
-   char name[ODP_COS_NAME_LEN];/* name */
size_t headroom;/* Headroom for this CoS */
odp_spinlock_t lock;/* cos lock */
+   odp_atomic_u32_t num_rule;  /* num of PMRs attached with this CoS */
+   char name[ODP_COS_NAME_LEN];/* name */
 };
 
 typedef union cos_u {
@@ -93,7 +92,9 @@ struct pmr_s {
odp_atomic_u32_t count; /* num of packets matching this rule */
uint32_t num_pmr;   /* num of PMR Term Values*/
odp_spinlock_t lock;/* pmr lock*/
-   pmr_term_value_t  pmr_term_value[1];/* Associated PMR Term */
+   cos_t *src_cos; /* source CoS where PMR is attached */
+   pmr_term_value_t  pmr_term_value[ODP_PMRTERM_MAX];
+   /* List of associated PMR Terms */
 };
 
 typedef union pmr_u {
@@ -102,24 +103,6 @@ typedef union pmr_u {
 } pmr_t;
 
 /**
-Packet Matching Rule Set
-
-This structure is implemented as a extension over struct pmr_s
-In order to use same pointer to access both pmr_s and pmr_set_s
-'num_pmr' value is used to differentiate between pmr_s and pmr_set_s struct
-**/
-struct pmr_set_s {
-   pmr_t pmr;
-   pmr_term_value_t  pmr_term_value[ODP_PMRTERM_MAX - 1];
-   /* List of associated PMR Terms */
-};
-
-typedef union pmr_set_u {
-   struct pmr_set_s s;
-   uint8_t pad[ODP_CACHE_LINE_SIZE_ROUNDUP(sizeof(struct pmr_set_s))];
-} pmr_set_t;
-
-/**
 L2 QoS and CoS Map
 
 This structure holds the mapping between L2 QoS value and
@@ -148,10 +131,6 @@ This structure is stored in pktio_entry and holds all
 the classifier configuration value.
 **/
 typedef struct classifier {
-   odp_spinlock_t lock;/*pktio_cos lock */
-   uint32_t num_pmr;   /* num of PMRs linked to given PKTIO*/
-   pmr_t *pmr[ODP_PKTIO_MAX_PMR];  /* PMRs linked with this PKTIO */
-   cos_t *cos[ODP_PKTIO_MAX_PMR];  /* CoS linked with this PKTIO */
cos_t *error_cos;   /* Associated Error CoS */
cos_t *default_cos; /* Associated Default CoS */
uint32_t l3_precedence; /* L3 QoS precedence */
@@ -171,13 +150,6 @@ typedef struct odp_cos_table {
 } cos_tbl_t;
 
 /**
-PMR set table
-**/
-typedef struct pmr_set_tbl {
-   pmr_set_t pmr_set[ODP_PMRSET_MAX_ENTRY];
-} pmr_set_tbl_t;
-
-/**
 PMR table
 **/
 typedef struct pmr_tbl {
diff --git a/platform/linux-generic/include/odp_classification_internal.h 
b/platform/linux-generic/include/odp_classification_internal.h
index 1e8f291..3fa18ad 100644
--- a/platform/linux-generic/include/odp_classification_internal.h
+++ b/platform/linux

[lng-odp] [API-NEXT PATCHv3 4/4] example: classifier: modifications for pmr create api

2016-02-02 Thread Balasubramanian Manoharan
Modifications for packet match rule create function.

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 example/classifier/odp_classifier.c | 38 -
 1 file changed, 21 insertions(+), 17 deletions(-)

diff --git a/example/classifier/odp_classifier.c 
b/example/classifier/odp_classifier.c
index 9e5bec9..245ab2d 100644
--- a/example/classifier/odp_classifier.c
+++ b/example/classifier/odp_classifier.c
@@ -87,8 +87,8 @@ static void swap_pkt_addrs(odp_packet_t pkt_tbl[], unsigned 
len);
 static void parse_args(int argc, char *argv[], appl_args_t *appl_args);
 static void print_info(char *progname, appl_args_t *appl_args);
 static void usage(char *progname);
-static void configure_cos(odp_pktio_t pktio, appl_args_t *args);
-static void configure_default_cos(odp_pktio_t pktio, appl_args_t *args);
+static void configure_cos(odp_cos_t default_cos, appl_args_t *args);
+static odp_cos_t configure_default_cos(odp_pktio_t pktio, appl_args_t *args);
 static int convert_str_to_pmr_enum(char *token, odp_pmr_term_t *term,
   uint32_t *offset);
 static int parse_pmr_policy(appl_args_t *appl_args, char *argv[], char 
*optarg);
@@ -354,7 +354,7 @@ static void *pktio_receive_thread(void *arg)
return NULL;
 }
 
-static void configure_default_cos(odp_pktio_t pktio, appl_args_t *args)
+static odp_cos_t configure_default_cos(odp_pktio_t pktio, appl_args_t *args)
 {
odp_queue_param_t qparam;
const char *queue_name = "DefaultQueue";
@@ -416,9 +416,10 @@ static void configure_default_cos(odp_pktio_t pktio, 
appl_args_t *args)
odp_atomic_init_u64([args->policy_count].queue_pkt_count, 0);
odp_atomic_init_u64([args->policy_count].pool_pkt_count, 0);
args->policy_count++;
+   return cos_default;
 }
 
-static void configure_cos(odp_pktio_t pktio, appl_args_t *args)
+static void configure_cos(odp_cos_t default_cos, appl_args_t *args)
 {
char cos_name[ODP_COS_NAME_LEN];
char queue_name[ODP_QUEUE_NAME_LEN];
@@ -432,15 +433,6 @@ static void configure_cos(odp_pktio_t pktio, appl_args_t 
*args)
for (i = 0; i < args->policy_count; i++) {
stats = >stats[i];
 
-   const odp_pmr_match_t match = {
-   .term = stats->rule.term,
-   .val = >rule.val,
-   .mask = >rule.mask,
-   .val_sz = stats->rule.val_sz,
-   .offset = stats->rule.offset
-   };
-
-   stats->pmr = odp_pmr_create();
odp_queue_param_init();
qparam.sched.prio = i % odp_schedule_num_prio();
qparam.sched.sync = ODP_SCHED_SYNC_NONE;
@@ -480,7 +472,17 @@ static void configure_cos(odp_pktio_t pktio, appl_args_t 
*args)
cls_param.drop_policy = ODP_COS_DROP_POOL;
stats->cos = odp_cls_cos_create(cos_name, _param);
 
-   if (0 > odp_pktio_pmr_cos(stats->pmr, pktio, stats->cos)) {
+   const odp_pmr_match_t match = {
+   .term = stats->rule.term,
+   .val = >rule.val,
+   .mask = >rule.mask,
+   .val_sz = stats->rule.val_sz,
+   .offset = stats->rule.offset
+   };
+
+   stats->pmr = odp_cls_pmr_create(, 1, default_cos,
+   stats->cos);
+   if (stats->pmr == ODP_PMR_INVAL) {
EXAMPLE_ERR("odp_pktio_pmr_cos failed");
exit(EXIT_FAILURE);
}
@@ -505,6 +507,7 @@ int main(int argc, char *argv[])
odp_pool_param_t params;
odp_pktio_t pktio;
appl_args_t *args;
+   odp_cos_t default_cos;
odp_queue_t inq;
odp_shm_t shm;
 
@@ -576,10 +579,10 @@ int main(int argc, char *argv[])
/* create pktio per interface */
pktio = create_pktio(args->if_name, pool);
 
-   configure_cos(pktio, args);
-
/* configure default Cos */
-   configure_default_cos(pktio, args);
+   default_cos = configure_default_cos(pktio, args);
+
+   configure_cos(default_cos, args);
 
if (odp_pktio_start(pktio)) {
EXAMPLE_ERR("Error: unable to start pktio.\n");
@@ -606,6 +609,7 @@ int main(int argc, char *argv[])
print_cls_statistics(args);
 
for (i = 0; i < args->policy_count; i++) {
+   odp_cls_pmr_destroy(args->stats[i].pmr);
odp_cos_destroy(args->stats[i].cos);
odp_pool_destroy(args->stats[i].pool);
odp_queue_destroy(args->stats[i].queue);
-- 
1.9.1

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


[lng-odp] [API-NEXT PATCHv3 3/4] validation: classification: adds validation suite for pmr create api

2016-02-02 Thread Balasubramanian Manoharan
Adds validation suite for packet match rule create functions.

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 test/validation/classification/classification.h|   1 -
 .../classification/odp_classification_basic.c  | 141 +++-
 .../classification/odp_classification_common.c |  26 +++
 .../classification/odp_classification_test_pmr.c   | 239 -
 .../classification/odp_classification_tests.c  |  87 
 .../classification/odp_classification_testsuites.h |   4 +-
 6 files changed, 245 insertions(+), 253 deletions(-)

diff --git a/test/validation/classification/classification.h 
b/test/validation/classification/classification.h
index 5508af7..c987cca 100644
--- a/test/validation/classification/classification.h
+++ b/test/validation/classification/classification.h
@@ -59,7 +59,6 @@
 void classification_test_create_cos(void);
 void classification_test_destroy_cos(void);
 void classification_test_create_pmr_match(void);
-void classification_test_destroy_pmr(void);
 void classification_test_cos_set_queue(void);
 void classification_test_cos_set_pool(void);
 void classification_test_cos_set_drop(void);
diff --git a/test/validation/classification/odp_classification_basic.c 
b/test/validation/classification/odp_classification_basic.c
index 81077b6..1336955 100644
--- a/test/validation/classification/odp_classification_basic.c
+++ b/test/validation/classification/odp_classification_basic.c
@@ -74,28 +74,40 @@ void classification_test_create_pmr_match(void)
odp_pmr_t pmr;
uint16_t val;
uint16_t mask;
+   int retval;
odp_pmr_match_t match;
+   odp_cos_t default_cos;
+   odp_cos_t cos;
+   odp_queue_t default_queue;
+   odp_queue_t queue;
+   odp_pool_t default_pool;
+   odp_pool_t pool;
+   odp_pool_t pkt_pool;
+   odp_cls_cos_param_t cls_param;
+   odp_pktio_t pktio;
 
-   val = 1024;
-   mask = 0x;
-   match.term = find_first_supported_l3_pmr();
-   match.val = 
-   match.mask = 
-   match.val_sz = sizeof(val);
+   pkt_pool = pool_create("pkt_pool");
+   CU_ASSERT_FATAL(pkt_pool != ODP_POOL_INVALID);
 
-   pmr = odp_pmr_create();
-   CU_ASSERT(pmr != ODP_PMR_INVAL);
-   CU_ASSERT(odp_pmr_to_u64(pmr) != odp_pmr_to_u64(ODP_PMR_INVAL));
-   odp_pmr_destroy(pmr);
-}
+   pktio = create_pktio(ODP_QUEUE_TYPE_SCHED, pkt_pool);
+   CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID);
 
-void classification_test_destroy_pmr(void)
-{
-   odp_pmr_t pmr;
-   uint16_t val;
-   uint16_t mask;
-   int retval;
-   odp_pmr_match_t match;
+   configure_default_cos(pktio, _cos,
+ _queue, _pool);
+
+   queue = queue_create("pmr_match", true);
+   CU_ASSERT(queue != ODP_QUEUE_INVALID);
+
+   pool = pool_create("pmr_match");
+   CU_ASSERT_FATAL(pool != ODP_POOL_INVALID);
+
+   odp_cls_cos_param_init(_param);
+   cls_param.pool = pool;
+   cls_param.queue = queue;
+   cls_param.drop_policy = ODP_COS_DROP_POOL;
+
+   cos = odp_cls_cos_create("pmr_match", _param);
+   CU_ASSERT(cos != ODP_COS_INVALID);
 
val = 1024;
mask = 0x;
@@ -104,12 +116,25 @@ void classification_test_destroy_pmr(void)
match.mask = 
match.val_sz = sizeof(val);
 
-   pmr = odp_pmr_create();
-   retval = odp_pmr_destroy(pmr);
+   pmr = odp_cls_pmr_create(, 1, default_cos, cos);
+   CU_ASSERT(pmr != ODP_PMR_INVAL);
+   CU_ASSERT(odp_pmr_to_u64(pmr) != odp_pmr_to_u64(ODP_PMR_INVAL));
+   /* destroy the created PMR */
+   retval = odp_cls_pmr_destroy(pmr);
CU_ASSERT(retval == 0);
-   retval = odp_pmr_destroy(ODP_PMR_INVAL);
-   retval = odp_pmr_destroy(ODP_PMR_INVAL);
+
+   /* destroy an INVALID PMR */
+   retval = odp_cls_pmr_destroy(ODP_PMR_INVAL);
CU_ASSERT(retval < 0);
+
+   odp_queue_destroy(queue);
+   odp_pool_destroy(pool);
+   odp_pool_destroy(pkt_pool);
+   odp_cos_destroy(cos);
+   odp_queue_destroy(default_queue);
+   odp_pool_destroy(default_pool);
+   odp_cos_destroy(default_cos);
+   odp_pktio_close(pktio);
 }
 
 void classification_test_cos_set_queue(void)
@@ -224,39 +249,44 @@ void classification_test_cos_set_drop(void)
 
 void classification_test_pmr_match_set_create(void)
 {
-   odp_pmr_set_t pmr_set;
+   odp_pmr_t pmr_set;
int retval;
odp_pmr_match_t pmr_terms[PMR_SET_NUM];
+   odp_cos_t default_cos;
+   odp_cos_t cos;
+   odp_queue_t default_queue;
+   odp_queue_t queue;
+   odp_pool_t default_pool;
+   odp_pool_t pool;
+   odp_pool_t pkt_pool;
+   odp_cls_cos_param_t cls_param;
+   odp_pktio_t pktio;
uint16_t val = 1024;
uint16_t mask = 0x;
int i;
-   for (i = 0; i < PMR_SET_NUM; i++) {
-

[lng-odp] [API-NEXT PATCHv2 4/4] example: classifier: modifications for pmr create api

2016-02-01 Thread Balasubramanian Manoharan
Modifications for packet match rule create function.

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 example/classifier/odp_classifier.c | 38 -
 1 file changed, 21 insertions(+), 17 deletions(-)

diff --git a/example/classifier/odp_classifier.c 
b/example/classifier/odp_classifier.c
index 9e5bec9..da76b3d 100644
--- a/example/classifier/odp_classifier.c
+++ b/example/classifier/odp_classifier.c
@@ -87,8 +87,8 @@ static void swap_pkt_addrs(odp_packet_t pkt_tbl[], unsigned 
len);
 static void parse_args(int argc, char *argv[], appl_args_t *appl_args);
 static void print_info(char *progname, appl_args_t *appl_args);
 static void usage(char *progname);
-static void configure_cos(odp_pktio_t pktio, appl_args_t *args);
-static void configure_default_cos(odp_pktio_t pktio, appl_args_t *args);
+static void configure_cos(odp_cos_t default_cos, appl_args_t *args);
+static odp_cos_t configure_default_cos(odp_pktio_t pktio, appl_args_t *args);
 static int convert_str_to_pmr_enum(char *token, odp_pmr_term_t *term,
   uint32_t *offset);
 static int parse_pmr_policy(appl_args_t *appl_args, char *argv[], char 
*optarg);
@@ -354,7 +354,7 @@ static void *pktio_receive_thread(void *arg)
return NULL;
 }
 
-static void configure_default_cos(odp_pktio_t pktio, appl_args_t *args)
+static odp_cos_t configure_default_cos(odp_pktio_t pktio, appl_args_t *args)
 {
odp_queue_param_t qparam;
const char *queue_name = "DefaultQueue";
@@ -416,9 +416,10 @@ static void configure_default_cos(odp_pktio_t pktio, 
appl_args_t *args)
odp_atomic_init_u64([args->policy_count].queue_pkt_count, 0);
odp_atomic_init_u64([args->policy_count].pool_pkt_count, 0);
args->policy_count++;
+   return cos_default;
 }
 
-static void configure_cos(odp_pktio_t pktio, appl_args_t *args)
+static void configure_cos(odp_cos_t default_cos, appl_args_t *args)
 {
char cos_name[ODP_COS_NAME_LEN];
char queue_name[ODP_QUEUE_NAME_LEN];
@@ -432,15 +433,6 @@ static void configure_cos(odp_pktio_t pktio, appl_args_t 
*args)
for (i = 0; i < args->policy_count; i++) {
stats = >stats[i];
 
-   const odp_pmr_match_t match = {
-   .term = stats->rule.term,
-   .val = >rule.val,
-   .mask = >rule.mask,
-   .val_sz = stats->rule.val_sz,
-   .offset = stats->rule.offset
-   };
-
-   stats->pmr = odp_pmr_create();
odp_queue_param_init();
qparam.sched.prio = i % odp_schedule_num_prio();
qparam.sched.sync = ODP_SCHED_SYNC_NONE;
@@ -480,7 +472,17 @@ static void configure_cos(odp_pktio_t pktio, appl_args_t 
*args)
cls_param.drop_policy = ODP_COS_DROP_POOL;
stats->cos = odp_cls_cos_create(cos_name, _param);
 
-   if (0 > odp_pktio_pmr_cos(stats->pmr, pktio, stats->cos)) {
+   const odp_pmr_match_t match = {
+   .term = stats->rule.term,
+   .val = >rule.val,
+   .mask = >rule.mask,
+   .val_sz = stats->rule.val_sz,
+   .offset = stats->rule.offset
+   };
+
+   stats->pmr = odp_cls_pmr_create(1, , default_cos,
+   stats->cos);
+   if (stats->pmr == ODP_PMR_INVAL) {
EXAMPLE_ERR("odp_pktio_pmr_cos failed");
exit(EXIT_FAILURE);
}
@@ -505,6 +507,7 @@ int main(int argc, char *argv[])
odp_pool_param_t params;
odp_pktio_t pktio;
appl_args_t *args;
+   odp_cos_t default_cos;
odp_queue_t inq;
odp_shm_t shm;
 
@@ -576,10 +579,10 @@ int main(int argc, char *argv[])
/* create pktio per interface */
pktio = create_pktio(args->if_name, pool);
 
-   configure_cos(pktio, args);
-
/* configure default Cos */
-   configure_default_cos(pktio, args);
+   default_cos = configure_default_cos(pktio, args);
+
+   configure_cos(default_cos, args);
 
if (odp_pktio_start(pktio)) {
EXAMPLE_ERR("Error: unable to start pktio.\n");
@@ -606,6 +609,7 @@ int main(int argc, char *argv[])
print_cls_statistics(args);
 
for (i = 0; i < args->policy_count; i++) {
+   odp_cls_pmr_destroy(args->stats[i].pmr);
odp_cos_destroy(args->stats[i].cos);
odp_pool_destroy(args->stats[i].pool);
odp_queue_destroy(args->stats[i].queue);
-- 
1.9.1

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


[lng-odp] [API-NEXT PATCHv2 1/4] api: classification: add pmr create api

2016-02-01 Thread Balasubramanian Manoharan
Packet match rule creation is modified to include source and destination
class of service. Removes the ability to add any class of service directly
with pktio. If a PMR needs to be applied at the pktio level the same
should be applied to default class of service.

Packet match rule destroy function is updated to removes the link between
the source and destination class of service.

odp_pmr_match_set_t handle is removed and pmr create function is modified
to take number of terms and composite rule is created by providing more
than one term.

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
v2: removes pmr match set

 include/odp/api/classification.h | 142 ++-
 1 file changed, 35 insertions(+), 107 deletions(-)

diff --git a/include/odp/api/classification.h b/include/odp/api/classification.h
index f46912e..263ea7c 100644
--- a/include/odp/api/classification.h
+++ b/include/odp/api/classification.h
@@ -50,16 +50,11 @@ extern "C" {
 /**
  * @def ODP_PMR_INVAL
  * Invalid odp_pmr_t value.
- * This value is returned from odp_pmr_create()
+ * This value is returned from odp_cls_pmr_create()
  * function on failure.
  */
 
 /**
- * @def ODP_PMR_SET_INVAL
- * Invalid odp_pmr_set_t value.
- */
-
-/**
  * class of service packet drop policies
  */
 typedef enum {
@@ -286,50 +281,54 @@ typedef struct odp_pmr_match_t {
 } odp_pmr_match_t;
 
 /**
- * Create a packet match rule with mask and value
+ * Create a packet match rule between source and destination class of service.
+ * This packet matching rule is applied on all packets arriving at the source
+ * class of service and packets satisfying this PMR are sent to the destination
+ * class of service.
+ * A composite PMR rule is created when the number of terms in the match rule
+ * is more than one. The composite rule is considered as matching only if
+ * the packet satisfies all the terms in Packet Match Rule.
+ * The underlying platform may not support all or any specific combination
+ * of value match rules, and the application should take care
+ * of inspecting the return value when installing such rules, and perform
+ * appropriate fallback action.
  *
- * @param[in]  match   packet matching rule definition
+ * @param[in]  num_terms   Number of terms in the match rule.
+ * @param[in]  terms   Array of odp_pmr_match_t entries, one entry per
+ * term desired.
+ * @param[in]  src_cos source CoS handle
+ * @param[in]  dst_cos destination CoS handle
  *
- * @return Handle of the matching rule
- * @retval ODP_PMR_INVAL on failure
+ * @retval Hanlde to the Packet Match Rule.
+ * @retval ODP_PMR_INVAL on failure
  */
-odp_pmr_t odp_pmr_create(const odp_pmr_match_t *match);
+odp_pmr_t odp_cls_pmr_create(int num_terms, const odp_pmr_match_t *terms,
+odp_cos_t src_cos, odp_cos_t dst_cos);
 
 /**
- * Invalidate a packet match rule and vacate its resources
+ * Function to destroy a packet match rule
+ * Destroying a PMR removes the link between the source and destination
+ * class of service and this PMR will no longer be applied for packets arriving
+ * at the source class of service. All the resource associated with the PMR
+ * be release but the class of service will remain intact.
+ * Depending on the implementation details, destroying a composite rule
+ * may not guarantee the availability of hardware resources to create the
+ * same or essentially similar rule.
  *
  * @param[in]  pmr_id  Identifier of the PMR to be destroyed
  *
  * @retval 0 on success
  * @retval <0 on failure
  */
-int odp_pmr_destroy(odp_pmr_t pmr_id);
+int odp_cls_pmr_destroy(odp_pmr_t pmr_id);
 
-/**
- * Apply a PMR to a pktio to assign a CoS.
- *
- * @param[in]  pmr_id  PMR to be activated
- * @param[in]  src_pktio   pktio to which this PMR is to be applied
- * @param[in]  dst_cos CoS to be assigned by this PMR
+/* Return the maximum number of packet matching terms supported for
+ * a Packet match rule.
  *
- * @retval 0 on success
- * @retval <0 on failure
+ * @param[out] Maximum number of packet matching terms per
+ * PMR rule.
  */
-int odp_pktio_pmr_cos(odp_pmr_t pmr_id,
- odp_pktio_t src_pktio, odp_cos_t dst_cos);
-
-/**
- * Cascade a PMR to refine packets from one CoS to another.
- *
- * @param[in]  pmr_id  PMR to be activated
- * @param[in]  src_cos CoS to be filtered
- * @param[in]  dst_cos CoS to be assigned to packets filtered
- * from src_cos that match pmr_id.
- *
- * @retval 0 on success
- * @retval <0 on failure
- */
-int odp_cos_pmr_cos(odp_pmr_t pmr_id, odp_cos_t src_cos, odp_cos_t dst_cos);
+int odp_cls_pmr_num_terms(void);
 
 /**
  * Inquire about matching terms su

[lng-odp] [API-NEXT PATCHv2 2/4] linux-generic: classification: implement pmr create api

2016-02-01 Thread Balasubramanian Manoharan
Implements packet match rule create functions.
If a packet match rule needs to be applied at the pktio level it has to be
configured to the default class of service.

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 .../include/odp_classification_datamodel.h |  48 +---
 .../include/odp_classification_internal.h  |  21 +-
 platform/linux-generic/odp_classification.c| 313 ++---
 platform/linux-generic/odp_packet_io.c |  24 +-
 4 files changed, 94 insertions(+), 312 deletions(-)

diff --git a/platform/linux-generic/include/odp_classification_datamodel.h 
b/platform/linux-generic/include/odp_classification_datamodel.h
index 27d8a52..6301f18 100644
--- a/platform/linux-generic/include/odp_classification_datamodel.h
+++ b/platform/linux-generic/include/odp_classification_datamodel.h
@@ -28,14 +28,12 @@ extern "C" {
 
 /* Maximum Class Of Service Entry */
 #define ODP_COS_MAX_ENTRY  64
-/* Maximum PMR Set Entry */
-#define ODP_PMRSET_MAX_ENTRY   64
 /* Maximum PMR Entry */
-#define ODP_PMR_MAX_ENTRY  64
+#define ODP_PMR_MAX_ENTRY  256
 /* Maximum PMR Terms in a PMR Set */
 #define ODP_PMRTERM_MAX8
 /* Maximum PMRs attached in PKTIO Level */
-#define ODP_PKTIO_MAX_PMR  8
+#define ODP_PMR_PER_COS_MAX8
 /* L2 Priority Bits */
 #define ODP_COS_L2_QOS_BITS3
 /* Max L2 QoS value */
@@ -67,15 +65,16 @@ Class Of Service
 struct cos_s {
queue_entry_t *queue;   /* Associated Queue */
pool_entry_t *pool; /* Associated Buffer pool */
-   union pmr_u *pmr;   /* Chained PMR */
-   union cos_u *linked_cos;/* CoS linked with the PMR */
+   union pmr_u *pmr[ODP_PMR_PER_COS_MAX];  /* Chained PMR */
+   union cos_u *linked_cos[ODP_PMR_PER_COS_MAX]; /* Chained CoS with PMR*/
uint32_t valid; /* validity Flag */
-   odp_cls_drop_t drop_policy; /* Associated Drop Policy */
+   odp_cls_drop_t drop_policy; /* Associated Drop Policy */
odp_queue_group_t queue_group;  /* Associated Queue Group */
odp_cos_flow_set_t flow_set;/* Assigned Flow Set */
-   char name[ODP_COS_NAME_LEN];/* name */
size_t headroom;/* Headroom for this CoS */
odp_spinlock_t lock;/* cos lock */
+   odp_atomic_u32_t num_rule;  /* num of PMRs attached with this CoS */
+   char name[ODP_COS_NAME_LEN];/* name */
 };
 
 typedef union cos_u {
@@ -93,7 +92,9 @@ struct pmr_s {
odp_atomic_u32_t count; /* num of packets matching this rule */
uint32_t num_pmr;   /* num of PMR Term Values*/
odp_spinlock_t lock;/* pmr lock*/
-   pmr_term_value_t  pmr_term_value[1];/* Associated PMR Term */
+   cos_t *src_cos; /* source CoS where PMR is attached */
+   pmr_term_value_t  pmr_term_value[ODP_PMRTERM_MAX];
+   /* List of associated PMR Terms */
 };
 
 typedef union pmr_u {
@@ -102,24 +103,6 @@ typedef union pmr_u {
 } pmr_t;
 
 /**
-Packet Matching Rule Set
-
-This structure is implemented as a extension over struct pmr_s
-In order to use same pointer to access both pmr_s and pmr_set_s
-'num_pmr' value is used to differentiate between pmr_s and pmr_set_s struct
-**/
-struct pmr_set_s {
-   pmr_t pmr;
-   pmr_term_value_t  pmr_term_value[ODP_PMRTERM_MAX - 1];
-   /* List of associated PMR Terms */
-};
-
-typedef union pmr_set_u {
-   struct pmr_set_s s;
-   uint8_t pad[ODP_CACHE_LINE_SIZE_ROUNDUP(sizeof(struct pmr_set_s))];
-} pmr_set_t;
-
-/**
 L2 QoS and CoS Map
 
 This structure holds the mapping between L2 QoS value and
@@ -148,10 +131,6 @@ This structure is stored in pktio_entry and holds all
 the classifier configuration value.
 **/
 typedef struct classifier {
-   odp_spinlock_t lock;/*pktio_cos lock */
-   uint32_t num_pmr;   /* num of PMRs linked to given PKTIO*/
-   pmr_t *pmr[ODP_PKTIO_MAX_PMR];  /* PMRs linked with this PKTIO */
-   cos_t *cos[ODP_PKTIO_MAX_PMR];  /* CoS linked with this PKTIO */
cos_t *error_cos;   /* Associated Error CoS */
cos_t *default_cos; /* Associated Default CoS */
uint32_t l3_precedence; /* L3 QoS precedence */
@@ -171,13 +150,6 @@ typedef struct odp_cos_table {
 } cos_tbl_t;
 
 /**
-PMR set table
-**/
-typedef struct pmr_set_tbl {
-   pmr_set_t pmr_set[ODP_PMRSET_MAX_ENTRY];
-} pmr_set_tbl_t;
-
-/**
 PMR table
 **/
 typedef struct pmr_tbl {
diff --git a/platform/linux-generic/include/odp_classification_internal.h 
b/platform/linux-generic/include/odp_classification_internal.h
index 1e8f291..3fa18ad 100644
--- a/platform/linux-generic/include/odp_classification_internal.h
+++ b/platform/linux

[lng-odp] [API-NEXT PATCHv2 3/4] validation: classification: adds validation suite for pmr create api

2016-02-01 Thread Balasubramanian Manoharan
Adds validation suite for packet match rule create functions.

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 test/validation/classification/classification.h|   1 -
 .../classification/odp_classification_basic.c  | 141 +++-
 .../classification/odp_classification_common.c |  26 +++
 .../classification/odp_classification_test_pmr.c   | 239 -
 .../classification/odp_classification_tests.c  |  83 +++
 .../classification/odp_classification_testsuites.h |   2 +-
 6 files changed, 242 insertions(+), 250 deletions(-)

diff --git a/test/validation/classification/classification.h 
b/test/validation/classification/classification.h
index 5508af7..c987cca 100644
--- a/test/validation/classification/classification.h
+++ b/test/validation/classification/classification.h
@@ -59,7 +59,6 @@
 void classification_test_create_cos(void);
 void classification_test_destroy_cos(void);
 void classification_test_create_pmr_match(void);
-void classification_test_destroy_pmr(void);
 void classification_test_cos_set_queue(void);
 void classification_test_cos_set_pool(void);
 void classification_test_cos_set_drop(void);
diff --git a/test/validation/classification/odp_classification_basic.c 
b/test/validation/classification/odp_classification_basic.c
index 81077b6..55f10ac 100644
--- a/test/validation/classification/odp_classification_basic.c
+++ b/test/validation/classification/odp_classification_basic.c
@@ -74,28 +74,40 @@ void classification_test_create_pmr_match(void)
odp_pmr_t pmr;
uint16_t val;
uint16_t mask;
+   int retval;
odp_pmr_match_t match;
+   odp_cos_t default_cos;
+   odp_cos_t cos;
+   odp_queue_t default_queue;
+   odp_queue_t queue;
+   odp_pool_t default_pool;
+   odp_pool_t pool;
+   odp_pool_t pkt_pool;
+   odp_cls_cos_param_t cls_param;
+   odp_pktio_t pktio;
 
-   val = 1024;
-   mask = 0x;
-   match.term = find_first_supported_l3_pmr();
-   match.val = 
-   match.mask = 
-   match.val_sz = sizeof(val);
+   pkt_pool = pool_create("pkt_pool");
+   CU_ASSERT_FATAL(pkt_pool != ODP_POOL_INVALID);
 
-   pmr = odp_pmr_create();
-   CU_ASSERT(pmr != ODP_PMR_INVAL);
-   CU_ASSERT(odp_pmr_to_u64(pmr) != odp_pmr_to_u64(ODP_PMR_INVAL));
-   odp_pmr_destroy(pmr);
-}
+   pktio = create_pktio(ODP_QUEUE_TYPE_SCHED, pkt_pool);
+   CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID);
 
-void classification_test_destroy_pmr(void)
-{
-   odp_pmr_t pmr;
-   uint16_t val;
-   uint16_t mask;
-   int retval;
-   odp_pmr_match_t match;
+   configure_default_cos(pktio, _cos,
+ _queue, _pool);
+
+   queue = queue_create("pmr_match", true);
+   CU_ASSERT(queue != ODP_QUEUE_INVALID);
+
+   pool = pool_create("pmr_match");
+   CU_ASSERT_FATAL(pool != ODP_POOL_INVALID);
+
+   odp_cls_cos_param_init(_param);
+   cls_param.pool = pool;
+   cls_param.queue = queue;
+   cls_param.drop_policy = ODP_COS_DROP_POOL;
+
+   cos = odp_cls_cos_create("pmr_match", _param);
+   CU_ASSERT(cos != ODP_COS_INVALID);
 
val = 1024;
mask = 0x;
@@ -104,12 +116,25 @@ void classification_test_destroy_pmr(void)
match.mask = 
match.val_sz = sizeof(val);
 
-   pmr = odp_pmr_create();
-   retval = odp_pmr_destroy(pmr);
+   pmr = odp_cls_pmr_create(1, , default_cos, cos);
+   CU_ASSERT(pmr != ODP_PMR_INVAL);
+   CU_ASSERT(odp_pmr_to_u64(pmr) != odp_pmr_to_u64(ODP_PMR_INVAL));
+   /* destroy the created PMR */
+   retval = odp_cls_pmr_destroy(pmr);
CU_ASSERT(retval == 0);
-   retval = odp_pmr_destroy(ODP_PMR_INVAL);
-   retval = odp_pmr_destroy(ODP_PMR_INVAL);
+
+   /* destroy an INVALID PMR */
+   retval = odp_cls_pmr_destroy(ODP_PMR_INVAL);
CU_ASSERT(retval < 0);
+
+   odp_queue_destroy(queue);
+   odp_pool_destroy(pool);
+   odp_pool_destroy(pkt_pool);
+   odp_cos_destroy(cos);
+   odp_queue_destroy(default_queue);
+   odp_pool_destroy(default_pool);
+   odp_cos_destroy(default_cos);
+   odp_pktio_close(pktio);
 }
 
 void classification_test_cos_set_queue(void)
@@ -224,39 +249,44 @@ void classification_test_cos_set_drop(void)
 
 void classification_test_pmr_match_set_create(void)
 {
-   odp_pmr_set_t pmr_set;
+   odp_pmr_t pmr_set;
int retval;
odp_pmr_match_t pmr_terms[PMR_SET_NUM];
+   odp_cos_t default_cos;
+   odp_cos_t cos;
+   odp_queue_t default_queue;
+   odp_queue_t queue;
+   odp_pool_t default_pool;
+   odp_pool_t pool;
+   odp_pool_t pkt_pool;
+   odp_cls_cos_param_t cls_param;
+   odp_pktio_t pktio;
uint16_t val = 1024;
uint16_t mask = 0x;
int i;
-   for (i = 0; i < PMR_SET_NUM; i++) {
-

[lng-odp] [API-NEXT PATCHv1 1/4] api: classification: add pmr create api

2016-01-22 Thread Balasubramanian Manoharan
Packet match rule creation is modified to include source and destination
class of service. Removes the ability to add any class of service directly
with pktio. If a PMR needs to be applied at the pktio level the same
should be applied to default class of service.

Packet match rule destroy function is updated to removes the link between
the source and destination class of service.

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 include/odp/api/classification.h | 74 +---
 1 file changed, 24 insertions(+), 50 deletions(-)

diff --git a/include/odp/api/classification.h b/include/odp/api/classification.h
index f46912e..59bd01d 100644
--- a/include/odp/api/classification.h
+++ b/include/odp/api/classification.h
@@ -50,7 +50,7 @@ extern "C" {
 /**
  * @def ODP_PMR_INVAL
  * Invalid odp_pmr_t value.
- * This value is returned from odp_pmr_create()
+ * This value is returned from odp_cls_pmr_create()
  * function on failure.
  */
 
@@ -286,50 +286,33 @@ typedef struct odp_pmr_match_t {
 } odp_pmr_match_t;
 
 /**
- * Create a packet match rule with mask and value
+ * Create a packet match rule between source and destination class of service.
+ * This packet matching rule is applied on all packets arriving at the source
+ * class of service and packets satisfying this PMR are sent to the destination
+ * class of service.
  *
  * @param[in]  match   packet matching rule definition
+ * @param[in]  src_cos source CoS handle
+ * @param[in]  dst_cos destination CoS handle
  *
  * @return Handle of the matching rule
  * @retval ODP_PMR_INVAL on failure
  */
-odp_pmr_t odp_pmr_create(const odp_pmr_match_t *match);
-
+odp_pmr_t odp_cls_pmr_create(const odp_pmr_match_t *match, odp_cos_t src_cos,
+odp_cos_t dst_cos);
 /**
- * Invalidate a packet match rule and vacate its resources
+ * Function to destroy a packet match rule
+ * Destroying a PMR removes the link between the source and destination
+ * class of service and this PMR will no longer be applied for packets arriving
+ * at the source class of service. All the resource associated with the PMR
+ * be release but the class of service will remain intact.
  *
  * @param[in]  pmr_id  Identifier of the PMR to be destroyed
  *
  * @retval 0 on success
  * @retval <0 on failure
  */
-int odp_pmr_destroy(odp_pmr_t pmr_id);
-
-/**
- * Apply a PMR to a pktio to assign a CoS.
- *
- * @param[in]  pmr_id  PMR to be activated
- * @param[in]  src_pktio   pktio to which this PMR is to be applied
- * @param[in]  dst_cos CoS to be assigned by this PMR
- *
- * @retval 0 on success
- * @retval <0 on failure
- */
-int odp_pktio_pmr_cos(odp_pmr_t pmr_id,
- odp_pktio_t src_pktio, odp_cos_t dst_cos);
-
-/**
- * Cascade a PMR to refine packets from one CoS to another.
- *
- * @param[in]  pmr_id  PMR to be activated
- * @param[in]  src_cos CoS to be filtered
- * @param[in]  dst_cos CoS to be assigned to packets filtered
- * from src_cos that match pmr_id.
- *
- * @retval 0 on success
- * @retval <0 on failure
- */
-int odp_cos_pmr_cos(odp_pmr_t pmr_id, odp_cos_t src_cos, odp_cos_t dst_cos);
+int odp_cls_pmr_destroy(odp_pmr_t pmr_id);
 
 /**
  * Inquire about matching terms supported by the classifier
@@ -357,19 +340,24 @@ unsigned odp_pmr_terms_avail(void);
  * of value match rules, and the application should take care
  * of inspecting the return value when installing such rules, and perform
  * appropriate fallback action.
+ * This is same as odp_cls_pmr_create() except that it creates the link
+ * using pmr match set instead of a single PMR.
  *
  * @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[out] pmr_set_id  Returned handle to the composite rule set.
+ * @param[in]  src_cos source CoS handle
+ * @param[in]  dst_cos destination CoS handle
  *
  * @return the number of terms elements
  * that have been successfully mapped to the
  * underlying platform classification engine
  * @retval <0 on failure
  */
-int odp_pmr_match_set_create(int num_terms, const odp_pmr_match_t *terms,
-odp_pmr_set_t *pmr_set_id);
+int odp_cls_pmr_match_set_create(int num_terms, const odp_pmr_match_t *terms,
+odp_pmr_set_t *pmr_set_id, odp_cos_t src_cos,
+odp_cos_t dst_cos);
 
 /**
  * Function to delete a composite packet match rule set
@@ -378,7 +366,7 @@ int odp_pmr_match_set_create(int num_terms, const 
odp_pmr_match_t *terms,
  * same or essentially s

[lng-odp] [API-NEXT PATCHv1 3/4] validation: classification: validation suite changes for pmr create api

2016-01-22 Thread Balasubramanian Manoharan
Adds validation suite for packet match rule create functions.

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 test/validation/classification/classification.h|   1 -
 .../classification/odp_classification_basic.c  | 138 +++-
 .../classification/odp_classification_common.c |  26 +++
 .../classification/odp_classification_test_pmr.c   | 239 -
 .../classification/odp_classification_tests.c  |  81 +++
 .../classification/odp_classification_testsuites.h |   2 +-
 6 files changed, 241 insertions(+), 246 deletions(-)

diff --git a/test/validation/classification/classification.h 
b/test/validation/classification/classification.h
index 5508af7..c987cca 100644
--- a/test/validation/classification/classification.h
+++ b/test/validation/classification/classification.h
@@ -59,7 +59,6 @@
 void classification_test_create_cos(void);
 void classification_test_destroy_cos(void);
 void classification_test_create_pmr_match(void);
-void classification_test_destroy_pmr(void);
 void classification_test_cos_set_queue(void);
 void classification_test_cos_set_pool(void);
 void classification_test_cos_set_drop(void);
diff --git a/test/validation/classification/odp_classification_basic.c 
b/test/validation/classification/odp_classification_basic.c
index 81077b6..50eeab8 100644
--- a/test/validation/classification/odp_classification_basic.c
+++ b/test/validation/classification/odp_classification_basic.c
@@ -74,28 +74,40 @@ void classification_test_create_pmr_match(void)
odp_pmr_t pmr;
uint16_t val;
uint16_t mask;
+   int retval;
odp_pmr_match_t match;
+   odp_cos_t default_cos;
+   odp_cos_t cos;
+   odp_queue_t default_queue;
+   odp_queue_t queue;
+   odp_pool_t default_pool;
+   odp_pool_t pool;
+   odp_pool_t pkt_pool;
+   odp_cls_cos_param_t cls_param;
+   odp_pktio_t pktio;
 
-   val = 1024;
-   mask = 0x;
-   match.term = find_first_supported_l3_pmr();
-   match.val = 
-   match.mask = 
-   match.val_sz = sizeof(val);
+   pkt_pool = pool_create("pkt_pool");
+   CU_ASSERT_FATAL(pkt_pool != ODP_POOL_INVALID);
 
-   pmr = odp_pmr_create();
-   CU_ASSERT(pmr != ODP_PMR_INVAL);
-   CU_ASSERT(odp_pmr_to_u64(pmr) != odp_pmr_to_u64(ODP_PMR_INVAL));
-   odp_pmr_destroy(pmr);
-}
+   pktio = create_pktio(ODP_QUEUE_TYPE_SCHED, pkt_pool);
+   CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID);
 
-void classification_test_destroy_pmr(void)
-{
-   odp_pmr_t pmr;
-   uint16_t val;
-   uint16_t mask;
-   int retval;
-   odp_pmr_match_t match;
+   configure_default_cos(pktio, _cos,
+ _queue, _pool);
+
+   queue = queue_create("pmr_match", true);
+   CU_ASSERT(queue != ODP_QUEUE_INVALID);
+
+   pool = pool_create("pmr_match");
+   CU_ASSERT_FATAL(pool != ODP_POOL_INVALID);
+
+   odp_cls_cos_param_init(_param);
+   cls_param.pool = pool;
+   cls_param.queue = queue;
+   cls_param.drop_policy = ODP_COS_DROP_POOL;
+
+   cos = odp_cls_cos_create("pmr_match", _param);
+   CU_ASSERT(cos != ODP_COS_INVALID);
 
val = 1024;
mask = 0x;
@@ -104,12 +116,25 @@ void classification_test_destroy_pmr(void)
match.mask = 
match.val_sz = sizeof(val);
 
-   pmr = odp_pmr_create();
-   retval = odp_pmr_destroy(pmr);
+   pmr = odp_cls_pmr_create(, default_cos, cos);
+   CU_ASSERT(pmr != ODP_PMR_INVAL);
+   CU_ASSERT(odp_pmr_to_u64(pmr) != odp_pmr_to_u64(ODP_PMR_INVAL));
+   /* destroy the created PMR */
+   retval = odp_cls_pmr_destroy(pmr);
CU_ASSERT(retval == 0);
-   retval = odp_pmr_destroy(ODP_PMR_INVAL);
-   retval = odp_pmr_destroy(ODP_PMR_INVAL);
+
+   /* destroy an INVALID PMR */
+   retval = odp_cls_pmr_destroy(ODP_PMR_INVAL);
CU_ASSERT(retval < 0);
+
+   odp_queue_destroy(queue);
+   odp_pool_destroy(pool);
+   odp_pool_destroy(pkt_pool);
+   odp_cos_destroy(cos);
+   odp_queue_destroy(default_queue);
+   odp_pool_destroy(default_pool);
+   odp_cos_destroy(default_cos);
+   odp_pktio_close(pktio);
 }
 
 void classification_test_cos_set_queue(void)
@@ -227,36 +252,41 @@ void classification_test_pmr_match_set_create(void)
odp_pmr_set_t pmr_set;
int retval;
odp_pmr_match_t pmr_terms[PMR_SET_NUM];
+   odp_cos_t default_cos;
+   odp_cos_t cos;
+   odp_queue_t default_queue;
+   odp_queue_t queue;
+   odp_pool_t default_pool;
+   odp_pool_t pool;
+   odp_pool_t pkt_pool;
+   odp_cls_cos_param_t cls_param;
+   odp_pktio_t pktio;
uint16_t val = 1024;
uint16_t mask = 0x;
int i;
-   for (i = 0; i < PMR_SET_NUM; i++) {
-   pmr_terms[i].term = ODP_PMR_TCP_DPORT;
-   p

[lng-odp] [API-NEXT PATCHv2] api: packet: add detailed packet error flags

2016-01-05 Thread Balasubramanian Manoharan
Additional APIs to get packet error flags for L2, L3 and L4 errors.

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
v2: Incorporates review comments from Petri

 include/odp/api/packet_flags.h| 33 +++
 platform/linux-generic/odp_packet_flags.c | 30 
 2 files changed, 63 insertions(+)

diff --git a/include/odp/api/packet_flags.h b/include/odp/api/packet_flags.h
index 7c3b247..8de0c82 100644
--- a/include/odp/api/packet_flags.h
+++ b/include/odp/api/packet_flags.h
@@ -38,6 +38,17 @@ extern "C" {
 int odp_packet_has_error(odp_packet_t pkt);
 
 /**
+ * Check for packet L2 errors
+ *
+ * check for all L2 errors
+ *
+ * @param pkt Packet handle
+ * @retval non-zero packet has L2 errors
+ * @retval 0 packet has no L2 error
+ */
+int odp_packet_has_l2_error(odp_packet_t pkt);
+
+/**
  * Check for L2 header, e.g. ethernet
  *
  * @param pkt Packet handle
@@ -47,6 +58,17 @@ int odp_packet_has_error(odp_packet_t pkt);
 int odp_packet_has_l2(odp_packet_t pkt);
 
 /**
+ * Check for packet L3 errors
+ *
+ * check for all L3 errors
+ *
+ * @param pkt Packet handle
+ * @retval non-zero packet has L3 errors
+ * @retval 0 packet has no L3 error
+ */
+int odp_packet_has_l3_error(odp_packet_t pkt);
+
+/**
  * Check for L3 header, e.g. IPv4, IPv6
  *
  * @param pkt Packet handle
@@ -56,6 +78,17 @@ int odp_packet_has_l2(odp_packet_t pkt);
 int odp_packet_has_l3(odp_packet_t pkt);
 
 /**
+ * Check for packet L4 errors
+ *
+ * check for all L4 errors
+ *
+ * @param pkt Packet handle
+ * @retval non-zero packet has L4 errors
+ * @retval 0 packet has no L4 error
+ */
+int odp_packet_has_l4_error(odp_packet_t pkt);
+
+/**
  * Check for L4 header, e.g. UDP, TCP, SCTP (also ICMP)
  *
  * @param pkt Packet handle
diff --git a/platform/linux-generic/odp_packet_flags.c 
b/platform/linux-generic/odp_packet_flags.c
index 3537aa9..ae9a9ed 100644
--- a/platform/linux-generic/odp_packet_flags.c
+++ b/platform/linux-generic/odp_packet_flags.c
@@ -38,16 +38,46 @@ int odp_packet_has_l2(odp_packet_t pkt)
return pkt_hdr->input_flags.l2;
 }
 
+int odp_packet_has_l2_error(odp_packet_t pkt)
+{
+   odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
+   /* L2 parsing is always done by default and hence
+   no additional check is required */
+   return pkt_hdr->error_flags.frame_len
+   | pkt_hdr->error_flags.snap_len
+   | pkt_hdr->error_flags.l2_chksum;
+}
+
 int odp_packet_has_l3(odp_packet_t pkt)
 {
retflag(pkt, input_flags.l3);
 }
 
+int odp_packet_has_l3_error(odp_packet_t pkt)
+{
+   odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
+
+   if (packet_parse_not_complete(pkt_hdr))
+   packet_parse_full(pkt_hdr);
+
+   return pkt_hdr->error_flags.ip_err;
+}
+
 int odp_packet_has_l4(odp_packet_t pkt)
 {
retflag(pkt, input_flags.l4);
 }
 
+int odp_packet_has_l4_error(odp_packet_t pkt)
+{
+   odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
+
+   if (packet_parse_not_complete(pkt_hdr))
+   packet_parse_full(pkt_hdr);
+
+   return pkt_hdr->error_flags.tcp_err | pkt_hdr->error_flags.udp_err;
+}
+
 int odp_packet_has_eth(odp_packet_t pkt)
 {
odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
-- 
1.9.1

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


[lng-odp] [API-NEXT PATCH] validation: classification: adds additional ASSERTS for stability

2015-12-24 Thread Balasubramanian Manoharan
Adds additional ASSERTS for stability in validation suites during failure

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
 .../classification/odp_classification_test_pmr.c   | 44 +++---
 .../classification/odp_classification_tests.c  | 23 +++
 2 files changed, 46 insertions(+), 21 deletions(-)

diff --git a/test/validation/classification/odp_classification_test_pmr.c 
b/test/validation/classification/odp_classification_test_pmr.c
index 5a13e13..6644b53 100644
--- a/test/validation/classification/odp_classification_test_pmr.c
+++ b/test/validation/classification/odp_classification_test_pmr.c
@@ -162,7 +162,7 @@ void classification_test_pmr_term_tcp_dport(void)
seqno = 0;
 
pktio = create_pktio(ODP_QUEUE_TYPE_SCHED);
-   CU_ASSERT(pktio != ODP_PKTIO_INVALID);
+   CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID);
retval = create_default_inq(pktio, ODP_QUEUE_TYPE_SCHED);
CU_ASSERT(retval == 0);
 
@@ -196,6 +196,7 @@ void classification_test_pmr_term_tcp_dport(void)
configure_default_cos(pktio, _cos,
  _queue, _pool);
pkt = create_packet(pkt_pool, false, , false);
+   CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
seqno = cls_pkt_get_seq(pkt);
CU_ASSERT(seqno != TEST_SEQ_INVALID);
 
@@ -205,7 +206,7 @@ void classification_test_pmr_term_tcp_dport(void)
enqueue_pktio_interface(pkt, pktio);
 
pkt = receive_packet(, ODP_TIME_SEC_IN_NS);
-   CU_ASSERT(pkt != ODP_PACKET_INVALID);
+   CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
pool_recv = odp_packet_pool(pkt);
CU_ASSERT(pool == pool_recv);
CU_ASSERT(retqueue == queue);
@@ -215,6 +216,7 @@ void classification_test_pmr_term_tcp_dport(void)
 
/* Other packets are delivered to default queue */
pkt = create_packet(pkt_pool, false, , false);
+   CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
seqno = cls_pkt_get_seq(pkt);
CU_ASSERT(seqno != TEST_SEQ_INVALID);
 
@@ -224,7 +226,7 @@ void classification_test_pmr_term_tcp_dport(void)
enqueue_pktio_interface(pkt, pktio);
 
pkt = receive_packet(, ODP_TIME_SEC_IN_NS);
-   CU_ASSERT(pkt != ODP_PACKET_INVALID);
+   CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
CU_ASSERT(seqno == cls_pkt_get_seq(pkt));
CU_ASSERT(retqueue == default_queue);
recvpool = odp_packet_pool(pkt);
@@ -269,6 +271,7 @@ void classification_test_pmr_term_tcp_sport(void)
seqno = 0;
 
pktio = create_pktio(ODP_QUEUE_TYPE_SCHED);
+   CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID);
retval = create_default_inq(pktio, ODP_QUEUE_TYPE_SCHED);
CU_ASSERT(retval == 0);
 
@@ -301,6 +304,7 @@ void classification_test_pmr_term_tcp_sport(void)
configure_default_cos(pktio, _cos,
  _queue, _pool);
pkt = create_packet(pkt_pool, false, , false);
+   CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
seqno = cls_pkt_get_seq(pkt);
CU_ASSERT(seqno != TEST_SEQ_INVALID);
 
@@ -310,7 +314,7 @@ void classification_test_pmr_term_tcp_sport(void)
enqueue_pktio_interface(pkt, pktio);
 
pkt = receive_packet(, ODP_TIME_SEC_IN_NS);
-   CU_ASSERT(pkt != ODP_PACKET_INVALID);
+   CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
CU_ASSERT(seqno == cls_pkt_get_seq(pkt));
CU_ASSERT(retqueue == queue);
recvpool = odp_packet_pool(pkt);
@@ -318,6 +322,7 @@ void classification_test_pmr_term_tcp_sport(void)
odp_packet_free(pkt);
 
pkt = create_packet(pkt_pool, false, , false);
+   CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
seqno = cls_pkt_get_seq(pkt);
CU_ASSERT(seqno != TEST_SEQ_INVALID);
 
@@ -327,7 +332,7 @@ void classification_test_pmr_term_tcp_sport(void)
enqueue_pktio_interface(pkt, pktio);
 
pkt = receive_packet(, ODP_TIME_SEC_IN_NS);
-   CU_ASSERT(pkt != ODP_PACKET_INVALID);
+   CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
CU_ASSERT(seqno == cls_pkt_get_seq(pkt));
CU_ASSERT(retqueue == default_queue);
recvpool = odp_packet_pool(pkt);
@@ -372,6 +377,7 @@ void classification_test_pmr_term_udp_dport(void)
seqno = 0;
 
pktio = create_pktio(ODP_QUEUE_TYPE_SCHED);
+   CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID);
retval = create_default_inq(pktio, ODP_QUEUE_TYPE_SCHED);
CU_ASSERT(retval == 0);
 
@@ -404,6 +410,7 @@ void classification_test_pmr_term_udp_dport(void)
configure_default_cos(pktio, _cos,
  _queue, _pool);
pkt = create_packet(pkt_pool, false, , true);
+   CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
seqno = cls_pkt_get_seq(pkt);
CU_ASSERT(seqno != TEST_SEQ_INVALID);
 
@@ -413,7 +420,7 @@ void classification_test_pmr_term_udp_dport(void)
enqueue_pktio_interface(pkt, pktio);
 
pkt = receive_

[lng-odp] [API-NEXT/PATCHv2] validation: classification: adds Test case for ODP_PMR_DIP_ADDR

2015-12-23 Thread Balasubramanian Manoharan
fixes: https://bugs.linaro.org/show_bug.cgi?id=1830

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
v2: rebase to HEAD
 .../classification/odp_classification_common.c |  4 +-
 .../classification/odp_classification_test_pmr.c   | 99 ++
 2 files changed, 101 insertions(+), 2 deletions(-)

diff --git a/test/validation/classification/odp_classification_common.c 
b/test/validation/classification/odp_classification_common.c
index afcea45..68c4b5a 100644
--- a/test/validation/classification/odp_classification_common.c
+++ b/test/validation/classification/odp_classification_common.c
@@ -251,10 +251,10 @@ odp_packet_t create_packet(odp_pool_t pool, bool vlan,
/* ipv4 */
ip = (odph_ipv4hdr_t *)odp_packet_l3_ptr(pkt, NULL);
 
-   parse_ipv4_string(CLS_DEFAULT_SADDR, , );
+   parse_ipv4_string(CLS_DEFAULT_DADDR, , );
ip->dst_addr = odp_cpu_to_be_32(addr);
 
-   parse_ipv4_string(CLS_DEFAULT_DADDR, , );
+   parse_ipv4_string(CLS_DEFAULT_SADDR, , );
ip->src_addr = odp_cpu_to_be_32(addr);
ip->ver_ihl = ODPH_IPV4 << 4 | ODPH_IPV4HDR_IHL_MIN;
if (flag_udp)
diff --git a/test/validation/classification/odp_classification_test_pmr.c 
b/test/validation/classification/odp_classification_test_pmr.c
index 5a13e13..3bd8e40 100644
--- a/test/validation/classification/odp_classification_test_pmr.c
+++ b/test/validation/classification/odp_classification_test_pmr.c
@@ -833,6 +833,104 @@ static void classification_test_pmr_queue_set(void)
odp_pktio_close(pktio);
 }
 
+static void classification_test_pmr_term_daddr(void)
+{
+   odp_packet_t pkt;
+   uint32_t seqno;
+   int retval;
+   odp_pktio_t pktio;
+   odp_queue_t queue;
+   odp_queue_t retqueue;
+   odp_queue_t default_queue;
+   odp_pool_t pool;
+   odp_pool_t default_pool;
+   odp_pmr_t pmr;
+   odp_cos_t cos;
+   odp_cos_t default_cos;
+   uint32_t addr;
+   uint32_t mask;
+   char cosname[ODP_QUEUE_NAME_LEN];
+   odp_pmr_match_t match;
+   odp_cls_cos_param_t cls_param;
+   odph_ipv4hdr_t *ip;
+   const char *dst_addr = "10.0.0.99/32";
+
+   pktio = create_pktio(ODP_QUEUE_TYPE_SCHED);
+   retval = create_default_inq(pktio, ODP_QUEUE_TYPE_SCHED);
+   CU_ASSERT(retval == 0);
+
+   parse_ipv4_string(dst_addr, , );
+   match.term = ODP_PMR_DIP_ADDR;
+   match.val = 
+   match.mask = 
+   match.val_sz = sizeof(addr);
+
+   pmr = odp_pmr_create();
+   CU_ASSERT_FATAL(pmr != ODP_PMR_INVAL);
+
+   queue = queue_create("daddr", true);
+   CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID);
+
+   pool = pool_create("daddr");
+   CU_ASSERT_FATAL(pool != ODP_POOL_INVALID);
+
+   sprintf(cosname, "daddr");
+   odp_cls_cos_param_init(_param);
+   cls_param.pool = pool;
+   cls_param.queue = queue;
+   cls_param.drop_policy = ODP_COS_DROP_POOL;
+
+   cos = odp_cls_cos_create(cosname, _param);
+   CU_ASSERT_FATAL(cos != ODP_COS_INVALID);
+
+   retval = odp_pktio_pmr_cos(pmr, pktio, cos);
+   CU_ASSERT(retval == 0);
+
+   configure_default_cos(pktio, _cos,
+ _queue, _pool);
+
+   /* packet with dst ip address matching PMR rule to be
+   received in the CoS queue*/
+   pkt = create_packet(pkt_pool, false, , false);
+   ip = (odph_ipv4hdr_t *)odp_packet_l3_ptr(pkt, NULL);
+   ip->dst_addr = odp_cpu_to_be_32(addr);
+   ip->chksum = odph_ipv4_csum_update(pkt);
+
+   seqno = cls_pkt_get_seq(pkt);
+   CU_ASSERT(seqno != TEST_SEQ_INVALID);
+
+   enqueue_pktio_interface(pkt, pktio);
+
+   pkt = receive_packet(, ODP_TIME_SEC_IN_NS);
+   CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
+   CU_ASSERT(seqno == cls_pkt_get_seq(pkt));
+   CU_ASSERT(retqueue == queue);
+   odp_packet_free(pkt);
+
+   /* Other packets delivered to default queue */
+   pkt = create_packet(pkt_pool, false, , false);
+   seqno = cls_pkt_get_seq(pkt);
+   CU_ASSERT(seqno != TEST_SEQ_INVALID);
+
+   enqueue_pktio_interface(pkt, pktio);
+
+   pkt = receive_packet(, ODP_TIME_SEC_IN_NS);
+   CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
+   CU_ASSERT(seqno == cls_pkt_get_seq(pkt));
+   CU_ASSERT(retqueue == default_queue);
+
+   odp_cos_destroy(cos);
+   odp_cos_destroy(default_cos);
+   odp_pmr_destroy(pmr);
+   odp_packet_free(pkt);
+   destroy_inq(pktio);
+   odp_pool_destroy(default_pool);
+   odp_pool_destroy(pool);
+   odp_queue_destroy(queue);
+   odp_queue_destroy(default_queue);
+   odp_pktio_close(pktio);
+}
+
 odp_testinfo_t classification_suite_pmr[] = {
ODP_TEST_INFO(classification_test_pmr_term_tcp_dport),
ODP_TEST_INFO(classification_test_pmr_term_tcp_sport),
@@ -841,5 +939,6 @@ 

Re: [lng-odp] [API-NEXT PATCH] linux-generic: classification: define pkt_addr as const

2015-12-18 Thread Balasubramanian Manoharan

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

On 18/12/15 6:58 PM, Matias Elo wrote:

Fixes netmap "cast discards '__attribute__((const))'" build
error. Define pkt_addr as const as classifier operations
should be read-only to packet data.

Signed-off-by: Matias Elo <matias@nokia.com>
---
  .../include/odp_classification_inlines.h   | 73 --
  .../include/odp_classification_internal.h  | 14 ++---
  .../linux-generic/include/odp_packet_io_internal.h |  2 +-
  platform/linux-generic/odp_classification.c| 30 -
  platform/linux-generic/pktio/netmap.c  |  2 +-
  platform/linux-generic/pktio/pktio_common.c|  4 +-
  6 files changed, 66 insertions(+), 59 deletions(-)

diff --git a/platform/linux-generic/include/odp_classification_inlines.h 
b/platform/linux-generic/include/odp_classification_inlines.h
index 7f13530..e9739aa 100644
--- a/platform/linux-generic/include/odp_classification_inlines.h
+++ b/platform/linux-generic/include/odp_classification_inlines.h
@@ -39,15 +39,16 @@ static inline int verify_pmr_packet_len(odp_packet_hdr_t 
*pkt_hdr,
  
  	return 0;

  }
-static inline int verify_pmr_ip_proto(uint8_t *pkt_addr,
+
+static inline int verify_pmr_ip_proto(const uint8_t *pkt_addr,
  odp_packet_hdr_t *pkt_hdr,
  pmr_term_value_t *term_value)
  {
-   odph_ipv4hdr_t *ip;
+   const odph_ipv4hdr_t *ip;
uint8_t proto;
if (!pkt_hdr->input_flags.ipv4)
return 0;
-   ip = (odph_ipv4hdr_t *)(pkt_addr + pkt_hdr->l3_offset);
+   ip = (const odph_ipv4hdr_t *)(pkt_addr + pkt_hdr->l3_offset);
proto = ip->proto;
if (term_value->val == (proto & term_value->mask))
return 1;
@@ -55,15 +56,15 @@ static inline int verify_pmr_ip_proto(uint8_t *pkt_addr,
return 0;
  }
  
-static inline int verify_pmr_ipv4_saddr(uint8_t *pkt_addr,

+static inline int verify_pmr_ipv4_saddr(const uint8_t *pkt_addr,
odp_packet_hdr_t *pkt_hdr,
pmr_term_value_t *term_value)
  {
-   odph_ipv4hdr_t *ip;
+   const odph_ipv4hdr_t *ip;
uint32_t ipaddr;
if (!pkt_hdr->input_flags.ipv4)
return 0;
-   ip = (odph_ipv4hdr_t *)(pkt_addr + pkt_hdr->l3_offset);
+   ip = (const odph_ipv4hdr_t *)(pkt_addr + pkt_hdr->l3_offset);
ipaddr = odp_be_to_cpu_32(ip->src_addr);
if (term_value->val == (ipaddr & term_value->mask))
return 1;
@@ -71,15 +72,15 @@ static inline int verify_pmr_ipv4_saddr(uint8_t *pkt_addr,
return 0;
  }
  
-static inline int verify_pmr_ipv4_daddr(uint8_t *pkt_addr,

+static inline int verify_pmr_ipv4_daddr(const uint8_t *pkt_addr,
odp_packet_hdr_t *pkt_hdr,
pmr_term_value_t *term_value)
  {
-   odph_ipv4hdr_t *ip;
+   const odph_ipv4hdr_t *ip;
uint32_t ipaddr;
if (!pkt_hdr->input_flags.ipv4)
return 0;
-   ip = (odph_ipv4hdr_t *)(pkt_addr + pkt_hdr->l3_offset);
+   ip = (const odph_ipv4hdr_t *)(pkt_addr + pkt_hdr->l3_offset);
ipaddr = odp_be_to_cpu_32(ip->dst_addr);
if (term_value->val == (ipaddr & term_value->mask))
return 1;
@@ -87,15 +88,15 @@ static inline int verify_pmr_ipv4_daddr(uint8_t *pkt_addr,
return 0;
  }
  
-static inline int verify_pmr_tcp_sport(uint8_t *pkt_addr,

+static inline int verify_pmr_tcp_sport(const uint8_t *pkt_addr,
   odp_packet_hdr_t *pkt_hdr,
   pmr_term_value_t *term_value)
  {
uint16_t sport;
-   odph_tcphdr_t *tcp;
+   const odph_tcphdr_t *tcp;
if (!pkt_hdr->input_flags.tcp)
return 0;
-   tcp = (odph_tcphdr_t *)(pkt_addr + pkt_hdr->l4_offset);
+   tcp = (const odph_tcphdr_t *)(pkt_addr + pkt_hdr->l4_offset);
sport = odp_be_to_cpu_16(tcp->src_port);
if (term_value->val == (sport & term_value->mask))
return 1;
@@ -103,15 +104,15 @@ static inline int verify_pmr_tcp_sport(uint8_t *pkt_addr,
return 0;
  }
  
-static inline int verify_pmr_tcp_dport(uint8_t *pkt_addr,

+static inline int verify_pmr_tcp_dport(const uint8_t *pkt_addr,
   odp_packet_hdr_t *pkt_hdr,
   pmr_term_value_t *term_value)
  {
uint16_t dport;
-   odph_tcphdr_t *tcp;
+   const odph_tcphdr_t *tcp;
if (!pkt_hdr->input_flags.tcp)
return 0;
-   tcp = (odph_tcphdr_t *)(pkt_addr + pkt_hdr->l4_offset);
+   tcp = (const odph_tcphdr_t *)(pkt_addr + pkt_hdr->l4_offset);
dport

[lng-odp] [API-NEXT/PATCHv2 1/6] api: classification: add class of serivce create api

2015-12-16 Thread Balasubramanian Manoharan
class of service create function now takes pool, queue, drop policy and
name as input parameters.
Adds class of service parameter structure odp_cls_cos_param_t and
initialization function odp_cls_cos_param_init()

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
v2: additional documentation and review comments from Petri

 include/odp/api/classification.h | 37 +++--
 1 file changed, 31 insertions(+), 6 deletions(-)

diff --git a/include/odp/api/classification.h b/include/odp/api/classification.h
index 725e1ab..4db5bf0 100644
--- a/include/odp/api/classification.h
+++ b/include/odp/api/classification.h
@@ -37,7 +37,7 @@ extern "C" {
 
 /**
  * @def ODP_COS_INVALID
- * This value is returned from odp_cos_create() on failure,
+ * This value is returned from odp_cls_cos_create() on failure,
  * May also be used as a sink class of service that
  * results in packets being discarded.
  */
@@ -60,9 +60,9 @@ extern "C" {
  */
 
 /**
- * Class-of-service packet drop policies
+ * class of service packet drop policies
  */
-typedef enum odp_cos_drop {
+typedef enum odp_cls_drop {
ODP_COS_DROP_POOL,/**< Follow buffer pool drop policy */
ODP_COS_DROP_NEVER,/**< Never drop, ignoring buffer pool policy */
 } odp_drop_e;
@@ -89,14 +89,39 @@ typedef enum odp_cos_hdr_flow_fields {
 } odp_cos_hdr_flow_fields_e;
 
 /**
+ * Class of service parameters
+ * Used to communicate class of service creation options
+ */
+typedef struct odp_cls_cos_param {
+   odp_queue_t queue;  /**< Queue associated with CoS */
+   odp_pool_t pool;/**< Pool associated with CoS */
+   odp_drop_e drop_policy; /**< Drop policy associated with CoS */
+} odp_cls_cos_param_t;
+
+/**
+ * Initialize class of service parameters
+ *
+ * Initialize an odp_cls_cos_param_t to its default value for all fields
+ *
+ * @param param   Address of the odp_cls_cos_param_t to be initialized
+ */
+void odp_cls_cos_param_init(odp_cls_cos_param_t *param);
+
+/**
  * Create a class-of-service
  *
- * @param[in]  nameString intended for debugging purposes.
+ * @param  nameString intended for debugging purposes.
  *
- * @return Class of service instance identifier
+ * @param  param   class of service parameters
+ *
+ * @retval class of service handle
  * @retval ODP_COS_INVALID on failure.
+ *
+ * @note ODP_QUEUE_INVALID and ODP_POOL_INVALID are valid values for queue
+ * and pool associated with a class of service and when any one of these values
+ * are configured as INVALID then the packets assigned to the CoS gets dropped.
  */
-odp_cos_t odp_cos_create(const char *name);
+odp_cos_t odp_cls_cos_create(const char *name, odp_cls_cos_param_t *param);
 
 /**
  * Discard a class-of-service along with all its associated resources
-- 
1.9.1

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


  1   2   3   >