Instead of having magic 0-1-2 numbers, let's have the special enum for
feature support levels (unsupported/supported/preferred).

Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsoleni...@linaro.org>
---
 include/odp/api/spec/ipsec.h                     | 39 +++++-----------
 include/odp/api/spec/support.h                   | 57 ++++++++++++++++++++++++
 include/odp_api.h                                |  1 +
 platform/Makefile.inc                            |  1 +
 platform/linux-generic/Makefile.am               |  1 +
 platform/linux-generic/include/odp/api/support.h | 34 ++++++++++++++
 6 files changed, 106 insertions(+), 27 deletions(-)
 create mode 100644 include/odp/api/spec/support.h
 create mode 100644 platform/linux-generic/include/odp/api/support.h

diff --git a/include/odp/api/spec/ipsec.h b/include/odp/api/spec/ipsec.h
index a0ceb11a..ecbf38c6 100644
--- a/include/odp/api/spec/ipsec.h
+++ b/include/odp/api/spec/ipsec.h
@@ -19,6 +19,7 @@ extern "C" {
 #endif
 
 #include <odp/api/crypto.h>
+#include <odp/api/support.h>
 #include <odp/api/packet_io.h>
 #include <odp/api/classification.h>
 
@@ -230,38 +231,22 @@ typedef struct odp_ipsec_capability_t {
        /** Maximum number of IPSEC SAs */
        uint32_t max_num_sa;
 
-       /** Synchronous IPSEC operation mode (ODP_IPSEC_OP_MODE_SYNC) support
-        *
-        *  0: Synchronous mode is not supported
-        *  1: Synchronous mode is supported
-        *  2: Synchronous mode is supported and preferred
-        */
-       uint8_t op_mode_sync;
+       /** Synchronous IPSEC operation mode (ODP_IPSEC_OP_MODE_SYNC) support */
+       odp_support_t op_mode_sync;
 
-       /** Asynchronous IPSEC operation mode (ODP_IPSEC_OP_MODE_ASYNC) support
-        *
-        *  0: Asynchronous mode is not supported
-        *  1: Asynchronous mode is supported
-        *  2: Asynchronous mode is supported and preferred
+       /**
+        * Asynchronous IPSEC operation mode (ODP_IPSEC_OP_MODE_ASYNC) support
         */
-       uint8_t op_mode_async;
+       odp_support_t op_mode_async;
 
-       /** Inline IPSEC operation mode (ODP_IPSEC_OP_MODE_INLINE) support
-        *
-        *  0: Inline IPSEC operation is not supported
-        *  1: Inline IPSEC operation is supported
-        *  2: Inline IPSEC operation is supported and preferred
-        */
-       uint8_t op_mode_inline;
+       /** Inline IPSEC operation mode (ODP_IPSEC_OP_MODE_INLINE) support */
+       odp_support_t op_mode_inline;
 
-       /** Support of pipelined classification (ODP_IPSEC_PIPELINE_CLS) of
-        *  resulting inbound packets.
-        *
-        *  0: Classification of resulting packets is not supported
-        *  1: Classification of resulting packets is supported
-        *  2: Classification of resulting packets is supported and preferred
+       /**
+        * Support of pipelined classification (ODP_IPSEC_PIPELINE_CLS) of
+        *  resulting inbound packets
         */
-       uint8_t pipeline_cls;
+       odp_support_t pipeline_cls;
 
        /** Soft expiry limit in seconds support
         *
diff --git a/include/odp/api/spec/support.h b/include/odp/api/spec/support.h
new file mode 100644
index 00000000..cc43b6f0
--- /dev/null
+++ b/include/odp/api/spec/support.h
@@ -0,0 +1,57 @@
+/* Copyright (c) 2017, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:     BSD-3-Clause
+ */
+
+/**
+ * @file
+ *
+ * ODP support API
+ */
+
+#ifndef ODP_API_SUPPORT_H_
+#define ODP_API_SUPPORT_H_
+#include <odp/visibility_begin.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** @defgroup odp_support ODP support
+ *  Common API
+ *  @{
+ */
+
+/**
+ * ODP support support
+ *
+ * Support levels are specified in the relative order, where ODP_SUPPORT_NO is
+ * the lowest level. E.g. if the examined support level is greater than
+ * ODP_SUPPORT_NO, the feature is supported in some form.
+ */
+typedef enum odp_support_t {
+       /**
+        * Feature is not supported
+        */
+       ODP_SUPPORT_NO = 0,
+       /**
+        * Feature is supported
+        */
+       ODP_SUPPORT_YES,
+       /**
+        * Feature is supported and preferred
+        */
+       ODP_SUPPORT_PREFERRED
+} odp_support_t;
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#include <odp/visibility_end.h>
+#endif
diff --git a/include/odp_api.h b/include/odp_api.h
index 73e5309a..e3ffcb1e 100644
--- a/include/odp_api.h
+++ b/include/odp_api.h
@@ -57,6 +57,7 @@ extern "C" {
 #include <odp/api/spinlock_recursive.h>
 #include <odp/api/rwlock_recursive.h>
 #include <odp/api/std_clib.h>
+#include <odp/api/support.h>
 #include <odp/api/ipsec.h>
 
 #ifdef __cplusplus
diff --git a/platform/Makefile.inc b/platform/Makefile.inc
index 874cf887..b4cc2433 100644
--- a/platform/Makefile.inc
+++ b/platform/Makefile.inc
@@ -31,6 +31,7 @@ odpapispecinclude_HEADERS = \
                  $(top_srcdir)/include/odp/api/spec/debug.h \
                  $(top_srcdir)/include/odp/api/spec/errno.h \
                  $(top_srcdir)/include/odp/api/spec/event.h \
+                 $(top_srcdir)/include/odp/api/spec/support.h \
                  $(top_srcdir)/include/odp/api/spec/hash.h \
                  $(top_srcdir)/include/odp/api/spec/hints.h \
                  $(top_srcdir)/include/odp/api/spec/init.h \
diff --git a/platform/linux-generic/Makefile.am 
b/platform/linux-generic/Makefile.am
index 0d5299cb..3257d261 100644
--- a/platform/linux-generic/Makefile.am
+++ b/platform/linux-generic/Makefile.am
@@ -37,6 +37,7 @@ odpapiinclude_HEADERS = \
                  $(srcdir)/include/odp/api/debug.h \
                  $(srcdir)/include/odp/api/errno.h \
                  $(srcdir)/include/odp/api/event.h \
+                 $(srcdir)/include/odp/api/support.h \
                  $(srcdir)/include/odp/api/hash.h \
                  $(srcdir)/include/odp/api/hints.h \
                  $(srcdir)/include/odp/api/init.h \
diff --git a/platform/linux-generic/include/odp/api/support.h 
b/platform/linux-generic/include/odp/api/support.h
new file mode 100644
index 00000000..dd6abab2
--- /dev/null
+++ b/platform/linux-generic/include/odp/api/support.h
@@ -0,0 +1,34 @@
+/* Copyright (c) 2017, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:     BSD-3-Clause
+ */
+
+/**
+ * @file
+ *
+ * ODP support API - platform specific header
+ */
+
+#ifndef ODP_PLAT_SUPPORT_H_
+#define ODP_PLAT_SUPPORT_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** @ingroup odp_support
+ *  @{
+ */
+
+/**
+ * @}
+ */
+
+#include <odp/api/spec/support.h>
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
-- 
2.11.0

Reply via email to