From: Balasubramanian Manoharan <bala.manoha...@linaro.org>

odp_threshold_t is used to configure different threshold types

Signed-off-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>
---
/** Email created from pull request 277 (bala-manoharan:RED)
 ** https://github.com/Linaro/odp/pull/277
 ** Patch: https://github.com/Linaro/odp/pull/277.patch
 ** Base sha: d22c949cc466bf28de559855a1cb525740578137
 ** Merge commit sha: 0f3d27771374d5b525af19461f31d0e308b05874
 **/
 include/Makefile.am                                |   1 +
 include/odp/api/spec/threshold.h                   | 105 +++++++++++++++++++++
 platform/linux-generic/Makefile.am                 |   1 +
 platform/linux-generic/include/odp/api/threshold.h |  34 +++++++
 4 files changed, 141 insertions(+)
 create mode 100644 include/odp/api/spec/threshold.h
 create mode 100644 platform/linux-generic/include/odp/api/threshold.h

diff --git a/include/Makefile.am b/include/Makefile.am
index d53181ceb..8ab150ad9 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -44,6 +44,7 @@ odpapispecinclude_HEADERS = \
                  odp/api/spec/sync.h \
                  odp/api/spec/system_info.h \
                  odp/api/spec/thread.h \
+                 odp/api/spec/threshold.h \
                  odp/api/spec/thrmask.h \
                  odp/api/spec/ticketlock.h \
                  odp/api/spec/time.h \
diff --git a/include/odp/api/spec/threshold.h b/include/odp/api/spec/threshold.h
new file mode 100644
index 000000000..48d01dd4e
--- /dev/null
+++ b/include/odp/api/spec/threshold.h
@@ -0,0 +1,105 @@
+/* Copyright (c) 2017, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:     BSD-3-Clause
+ */
+
+/**
+ * @file
+ *
+ * ODP threshold descriptor
+ */
+
+#ifndef ODP_API_THRESHOLD_H_
+#define ODP_API_THRESHOLD_H_
+#include <odp/visibility_begin.h>
+#include <odp/api/std_types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Supported threshold types
+ *
+ * Supported threshold types in a bit field structure.
+ */
+typedef union odp_threshold_type_t {
+       /** bitfields for different threshold types */
+       struct {
+               /** Percentage of the total size of pool or queue */
+               uint8_t percent:1;
+
+               /** Total number of all transient packets */
+               uint8_t pkt_cnt:1;
+
+               /** Total size of all transient packets in bytes */
+               uint8_t pkt_size:1;
+       };
+
+       /** All bits of the bit field structure */
+       uint8_t all_bits;
+} odp_threshold_type_t;
+
+/**
+ * ODP Threshold types
+ *
+ * Different types of threshold measurements
+ */
+typedef        enum {
+       /** Percentage of the total size of pool or queue */
+       odp_percent_e,
+
+       /** Total number of all transient packets */
+       odp_pkt_count_e,
+
+       /** Total size of all transient packets in bytes */
+       odp_pkt_size_e
+} odp_threshold_type_e;
+
+/**
+ * ODP Threshold
+ *
+ * Threshold configuration
+ */
+typedef struct odp_threshold_t {
+       /** Type of threshold */
+       odp_threshold_type_e type;
+
+       /** Different threshold types */
+       union {
+               /** Percentage */
+               struct {
+                       /** Max percentage value */
+                       odp_percent_t max;
+
+                       /** Min percentage value */
+                       odp_percent_t min;
+               } percent;
+
+               /** Packet count */
+               struct {
+                       /** Max packet count */
+                       uint64_t max;
+
+                       /** Min packet count */
+                       uint64_t min;
+               } pkt_count;
+
+               /** Packet size */
+               struct {
+                       /** Max size of all packets */
+                       uint64_t max;
+
+                       /** Min size of all packets */
+                       uint64_t min;
+               } pkt_size;
+       };
+} odp_threshold_t;
+
+#ifdef __cplusplus
+}
+#endif
+
+#include <odp/visibility_end.h>
+#endif
diff --git a/platform/linux-generic/Makefile.am 
b/platform/linux-generic/Makefile.am
index c54067609..2b5056e4d 100644
--- a/platform/linux-generic/Makefile.am
+++ b/platform/linux-generic/Makefile.am
@@ -65,6 +65,7 @@ odpapiinclude_HEADERS = \
                  include/odp/api/sync.h \
                  include/odp/api/system_info.h \
                  include/odp/api/thread.h \
+                 include/odp/api/threshold.h \
                  include/odp/api/thrmask.h \
                  include/odp/api/ticketlock.h \
                  include/odp/api/time.h \
diff --git a/platform/linux-generic/include/odp/api/threshold.h 
b/platform/linux-generic/include/odp/api/threshold.h
new file mode 100644
index 000000000..f4f362852
--- /dev/null
+++ b/platform/linux-generic/include/odp/api/threshold.h
@@ -0,0 +1,34 @@
+/* Copyright (c) 2017, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:     BSD-3-Clause
+ */
+
+/**
+ * @file
+ *
+ * ODP threshold API - platform specific header
+ */
+
+#ifndef ODP_PLAT_THRESHOLD_H_
+#define ODP_PLAT_THRESHOLD_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** @ingroup odp_threshold
+ *  @{
+ */
+
+/**
+ * @}
+ */
+
+#include <odp/api/spec/threshold.h>
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif

Reply via email to