diff mbox series

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

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

Commit Message

Github ODP bot Nov. 8, 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: d22c949cc466bf28de559855a1cb525740578137
 ** Merge commit sha: 4c2f383b93c80fa98e8e676897db02dbc8b56112
 **/
 include/Makefile.am                                |   1 +
 include/odp/api/spec/threshold.h                   | 102 +++++++++++++++++++++
 platform/linux-generic/Makefile.am                 |   1 +
 platform/linux-generic/include/odp/api/threshold.h |  34 +++++++
 4 files changed, 138 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 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..54502e9e0
--- /dev/null
+++ b/include/odp/api/spec/threshold.h
@@ -0,0 +1,102 @@ 
+/* 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 {
+		struct {
+			/** Max percentage value */
+			odp_percent_t max;
+
+			/** Min percentage value */
+			odp_percent_t min;
+		} percent; /** Percentage */
+
+		struct {
+			/** Max packet count */
+			uint64_t max;
+
+			/** Min packet count */
+			uint64_t min;
+		} pkt_count; /** Packet count */
+
+		struct {
+			/** Max size of all packets */
+			uint64_t max;
+
+			/** Min size of all packets */
+			uint64_t min;
+		} pkt_size; /** Packet 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