diff mbox series

[API-NEXT,v8,2/4] api: threshold: add odp_threshold_t parameter

Message ID 1511186413-3157-3-git-send-email-odpbot@yandex.ru
State New
Headers show
Series [API-NEXT,v8,1/4] api: std_types: add odp_percent_t data type | expand

Commit Message

Github ODP bot Nov. 20, 2017, 2 p.m. UTC
From: Balasubramanian Manoharan <bala.manoharan@linaro.org>


odp_threshold_t is used to configure different threshold types

Signed-off-by: Balasubramanian Manoharan <bala.manoharan@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: d4b364849c4abb4c71e0c5260e1a793ebb8dc97d
 ** Merge commit sha: 806896e052ccb172565d49630ce6033f4e6ec9cd
 **/
 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 mbox series

Patch

diff --git a/include/Makefile.am b/include/Makefile.am
index 4e2d748b0..02f9c44af 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -43,6 +43,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..38c2430a0
--- /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_types_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 packet:1;
+
+		/** Total size of all transient packets in bytes */
+		uint8_t bytes:1;
+	};
+
+	/** All bits of the bit field structure */
+	uint8_t all_bits;
+} odp_threshold_types_t;
+
+/**
+ * ODP Threshold types
+ *
+ * Different types of threshold measurements
+ */
+typedef enum odp_threshold_type_t {
+	/** Percentage of the total size of pool or queue */
+	ODP_THRESHOLD_PERCENT,
+
+	/** Total number of all transient packets */
+	ODP_THRESHOLD_PACKET,
+
+	/** Total size of all transient packets in bytes */
+	ODP_THRESHOLD_BYTE
+} odp_threshold_type_t;
+
+/**
+ * ODP Threshold
+ *
+ * Threshold configuration
+ */
+typedef struct odp_threshold_t {
+	/** Type of threshold */
+	odp_threshold_type_t 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;
+		} packet;
+
+		/** Sum of all data bytes of all packets */
+		struct {
+			/** Max byte count */
+			uint64_t max;
+
+			/** Min byte count */
+			uint64_t min;
+		} byte;
+	};
+} 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 990eb433a..8f783463c 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