aboutsummaryrefslogtreecommitdiff
path: root/platform/linux-generic/include/api
diff options
context:
space:
mode:
authorRobbie King <robking@cisco.com>2015-01-14 23:48:18 +0100
committerMaxim Uvarov <maxim.uvarov@linaro.org>2015-01-16 17:32:18 +0300
commit7e4e3fd2708fb9a554b2f46c15a3f78ed996bac6 (patch)
tree2b34cd9561db82ed956c4c9b464c501c52c4bf99 /platform/linux-generic/include/api
parentc08daf1132ecb6c0b227a56b8036d3d6b86b7469 (diff)
api: cpumask: rename API and use CPU_SET(3) for impl
Rename odp_coremask to odp_cpumask and implement with use of the cpu_set_t data structure (CPU_SET(3)). Signed-off-by: Robbie King <robking@cisco.com> Signed-off-by: Anders Roxell <anders.roxell@linaro.org> Reviewed-by: Petri Savolainen <petri.savolainen@linaro.org> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Diffstat (limited to 'platform/linux-generic/include/api')
-rw-r--r--platform/linux-generic/include/api/odp.h2
-rw-r--r--platform/linux-generic/include/api/odp_coremask.h188
-rw-r--r--platform/linux-generic/include/api/odp_cpumask.h137
3 files changed, 138 insertions, 189 deletions
diff --git a/platform/linux-generic/include/api/odp.h b/platform/linux-generic/include/api/odp.h
index b7b1ca996..1cc7ce012 100644
--- a/platform/linux-generic/include/api/odp.h
+++ b/platform/linux-generic/include/api/odp.h
@@ -27,7 +27,7 @@ extern "C" {
#include <odp_hints.h>
#include <odp_debug.h>
#include <odp_byteorder.h>
-#include <odp_coremask.h>
+#include <odp_cpumask.h>
#include <odp_barrier.h>
#include <odp_spinlock.h>
#include <odp_atomic.h>
diff --git a/platform/linux-generic/include/api/odp_coremask.h b/platform/linux-generic/include/api/odp_coremask.h
deleted file mode 100644
index c9331fdbd..000000000
--- a/platform/linux-generic/include/api/odp_coremask.h
+++ /dev/null
@@ -1,188 +0,0 @@
-/* Copyright (c) 2013, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-
-/**
- * @file
- *
- * ODP core masks and enumeration
- */
-
-#ifndef ODP_COREMASK_H_
-#define ODP_COREMASK_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-
-#include <odp_std_types.h>
-
-/** @addtogroup odp_scheduler
- * Core mask operations.
- * @{
- */
-
-/** @internal */
-#define ODP_COREMASK_SIZE_U64 1
-
-/**
- * Core mask
- *
- * Don't access directly, use access functions.
- */
-typedef struct odp_coremask_t {
- uint64_t _u64[ODP_COREMASK_SIZE_U64]; /**< @private Mask*/
-
-} odp_coremask_t;
-
-
-
-/**
- * Add core mask bits from a string
- *
- * @param str Hexadecimal digits in a string. Core #0 is located
- * at the least significant bit (0x1).
- * @param mask Core mask to modify
- *
- * @note Supports currently only core indexes upto 63
- */
-void odp_coremask_from_str(const char *str, odp_coremask_t *mask);
-
-/**
- * Write core mask as a string of hexadecimal digits
- *
- * The result will be prefixed with 0x and will be in hexadecimal
- *
- * @param str String for output
- * @param len Size of string length (incl. ending zero)
- * @param mask Core mask
- *
- * @note Supports currently only core indexes upto 63
- */
-void odp_coremask_to_str(char *str, int len, const odp_coremask_t *mask);
-
-
-/**
- * Add core mask bits from a u64 array
- *
- * In the array core #0 is located at the least significant bit
- * of the first word (u64[0] = 0x1).
- *
- * Examples
- * - core 0: u64[0] = 0x1
- * - core 1: u64[0] = 0x2
- * - ...
- * - core 63: u64[0] = 0x8000 0000 0000 0000
- * - core 64: u64[0] = 0x0, u64[1] = 0x1
- * - core 65: u64[0] = 0x0, u64[1] = 0x2
- *
- * @param u64 An array of u64 bit words
- * @param num Number of u64 words in the array
- * @param mask Core mask to modify
- *
- * @note Supports currently only core indexes upto 63
- */
-void odp_coremask_from_u64(const uint64_t *u64, int num, odp_coremask_t *mask);
-
-/**
- * Clear entire mask
- * @param mask Core mask to flush with zero value
- */
-static inline void odp_coremask_zero(odp_coremask_t *mask)
-{
- mask->_u64[0] = 0;
-}
-
-/**
- * Add core to mask
- * @param core Core number
- * @param mask add core number in core mask
- */
-void odp_coremask_set(int core, odp_coremask_t *mask);
-
-/**
- * Remove core from mask
- * @param core Core number
- * @param mask clear core number from core mask
- */
-void odp_coremask_clr(int core, odp_coremask_t *mask);
-
-/**
- * Test if core is a member of mask
- * @param core Core number
- * @param mask Core mask to check if core num set or not
- * @return non-zero if set otherwise 0
- */
-int odp_coremask_isset(int core, const odp_coremask_t *mask);
-
-/**
- * Count number of cores in mask
- * @param mask Core mask
- * @return coremask count
- */
-int odp_coremask_count(const odp_coremask_t *mask);
-
-
-
-/**
- * Logical AND over two source masks.
- *
- * @param dest Destination mask, can be one of the source masks
- * @param src1 Source mask 1
- * @param src2 Source mask 2
- */
-static inline void odp_coremask_and(odp_coremask_t *dest, odp_coremask_t *src1,
- odp_coremask_t *src2)
-{
- dest->_u64[0] = src1->_u64[0] & src2->_u64[0];
-}
-
-/**
- * Logical OR over two source masks.
- *
- * @param dest Destination mask, can be one of the source masks
- * @param src1 Source mask 1
- * @param src2 Source mask 2
- */
-static inline void odp_coremask_or(odp_coremask_t *dest, odp_coremask_t *src1,
- odp_coremask_t *src2)
-{
- dest->_u64[0] = src1->_u64[0] | src2->_u64[0];
-}
-
-/**
- * Logical XOR over two source masks.
- *
- * @param dest Destination mask, can be one of the source masks
- * @param src1 Source mask 1
- * @param src2 Source mask 2
- */
-static inline void odp_coremask_xor(odp_coremask_t *dest, odp_coremask_t *src1,
- odp_coremask_t *src2)
-{
- dest->_u64[0] = src1->_u64[0] ^ src2->_u64[0];
-}
-
-/**
- * Test if two masks contain the same cores
- */
-static inline int odp_coremask_equal(odp_coremask_t *mask1,
- odp_coremask_t *mask2)
-{
- return (mask1->_u64[0] == mask2->_u64[0]);
-}
-
-/**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/platform/linux-generic/include/api/odp_cpumask.h b/platform/linux-generic/include/api/odp_cpumask.h
new file mode 100644
index 000000000..e421d4ddd
--- /dev/null
+++ b/platform/linux-generic/include/api/odp_cpumask.h
@@ -0,0 +1,137 @@
+/* Copyright (c) 2013, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+
+/**
+ * @file
+ *
+ * ODP CPU masks and enumeration
+ */
+
+#ifndef ODP_CPUMASK_H_
+#define ODP_CPUMASK_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <string.h>
+#include <sched.h>
+
+#include <odp_std_types.h>
+
+/** @addtogroup odp_scheduler
+ * CPU mask operations.
+ * @{
+ */
+
+/**
+ * CPU mask
+ *
+ * Don't access directly, use access functions.
+ */
+typedef struct odp_cpumask_t {
+ cpu_set_t set; /**< @private Mask*/
+} odp_cpumask_t;
+
+/**
+ * Add CPU mask bits from a string
+ *
+ * @param str Hexadecimal digits in a string. CPU #0 is located
+ * at the least significant bit (0x1).
+ * @param mask CPU mask to modify
+ */
+void odp_cpumask_from_str(const char *str, odp_cpumask_t *mask);
+
+/**
+ * Write CPU mask as a string of hexadecimal digits
+ *
+ * @param str String for output
+ * @param len Size of string length (incl. ending zero)
+ * @param mask CPU mask
+ */
+void odp_cpumask_to_str(char *str, int len, const odp_cpumask_t *mask);
+
+/**
+ * Clear entire mask
+ * @param mask CPU mask to flush with zero value
+ */
+void odp_cpumask_zero(odp_cpumask_t *mask);
+
+/**
+ * Add cpu to mask
+ * @param cpu CPU number
+ * @param mask add cpu number in CPU mask
+ */
+void odp_cpumask_set(int cpu, odp_cpumask_t *mask);
+
+/**
+ * Remove cpu from mask
+ * @param cpu CPU number
+ * @param mask clear cpu number from CPU mask
+ */
+void odp_cpumask_clr(int cpu, odp_cpumask_t *mask);
+
+/**
+ * Test if cpu is a member of mask
+ * @param cpu CPU number
+ * @param mask CPU mask to check if cpu num set or not
+ * @return non-zero if set otherwise 0
+ */
+int odp_cpumask_isset(int cpu, const odp_cpumask_t *mask);
+
+/**
+ * Count number of cpus in mask
+ * @param mask CPU mask
+ * @return cpumask count
+ */
+int odp_cpumask_count(const odp_cpumask_t *mask);
+
+/**
+ * Logical AND over two source masks.
+ *
+ * @param dest Destination mask, can be one of the source masks
+ * @param src1 Source mask 1
+ * @param src2 Source mask 2
+ */
+void odp_cpumask_and(odp_cpumask_t *dest, odp_cpumask_t *src1,
+ odp_cpumask_t *src2);
+
+/**
+ * Logical OR over two source masks.
+ *
+ * @param dest Destination mask, can be one of the source masks
+ * @param src1 Source mask 1
+ * @param src2 Source mask 2
+ */
+void odp_cpumask_or(odp_cpumask_t *dest, odp_cpumask_t *src1,
+ odp_cpumask_t *src2);
+
+/**
+ * Logical XOR over two source masks.
+ *
+ * @param dest Destination mask, can be one of the source masks
+ * @param src1 Source mask 1
+ * @param src2 Source mask 2
+ */
+void odp_cpumask_xor(odp_cpumask_t *dest, odp_cpumask_t *src1,
+ odp_cpumask_t *src2);
+
+/**
+ * Test if two masks contain the same cpus
+ */
+int odp_cpumask_equal(const odp_cpumask_t *mask1,
+ const odp_cpumask_t *mask2);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif