Signed-off-by: Bill Fischofer <[email protected]>
---
platform/linux-generic/Makefile.am | 1 +
platform/linux-generic/include/api/odp_buffer.h | 21 +++++++++++++++++++++
.../linux-generic/include/odp_buffer_internal.h | 4 +++-
platform/linux-generic/odp_buffer.c | 17 ++++++++++++++++-
platform/linux-generic/odp_event.c | 19 +++++++++++++++++++
5 files changed, 60 insertions(+), 2 deletions(-)
create mode 100644 platform/linux-generic/odp_event.c
diff --git a/platform/linux-generic/Makefile.am
b/platform/linux-generic/Makefile.am
index b90b31e..38a1f14 100644
--- a/platform/linux-generic/Makefile.am
+++ b/platform/linux-generic/Makefile.am
@@ -82,6 +82,7 @@ __LIB__libodp_la_SOURCES = \
odp_classification.c \
odp_cpumask.c \
odp_crypto.c \
+ odp_event.c \
odp_init.c \
odp_impl.c \
odp_linux.c \
diff --git a/platform/linux-generic/include/api/odp_buffer.h
b/platform/linux-generic/include/api/odp_buffer.h
index 0670464..f6c2087 100644
--- a/platform/linux-generic/include/api/odp_buffer.h
+++ b/platform/linux-generic/include/api/odp_buffer.h
@@ -27,6 +27,27 @@ extern "C" {
* @{
*/
+/**
+ * Get buffer handle from event
+ *
+ * Converts an ODP_EVENT_BUFFER type event to a buffer.
+ *
+ * @param ev Event handle
+ *
+ * @return Buffer handle
+ *
+ * @see odp_event_type()
+ */
+odp_buffer_t odp_buffer_from_event(odp_event_t ev);
+
+/**
+ * Convert buffer handle to event
+ *
+ * @param buf Buffer handle
+ *
+ * @return Event handle
+ */
+odp_event_t odp_buffer_to_event(odp_buffer_t buf);
/**
* Buffer start address
diff --git a/platform/linux-generic/include/odp_buffer_internal.h
b/platform/linux-generic/include/odp_buffer_internal.h
index 39b0b05..43d8619 100644
--- a/platform/linux-generic/include/odp_buffer_internal.h
+++ b/platform/linux-generic/include/odp_buffer_internal.h
@@ -20,7 +20,7 @@ extern "C" {
#include <odp_std_types.h>
#include <odp_atomic.h>
-#include <odp_buffer_pool.h>
+#include <odp_pool.h>
#include <odp_buffer.h>
#include <odp_debug.h>
#include <odp_align.h>
@@ -28,6 +28,7 @@ extern "C" {
#include <odp_config.h>
#include <odp_byteorder.h>
#include <odp_thread.h>
+#include <odp_event.h>
#define ODP_BITSIZE(x) \
@@ -152,6 +153,7 @@ typedef struct {
/* Forward declarations */
odp_buffer_t buffer_alloc(odp_buffer_pool_t pool, size_t size);
+int _odp_buffer_type(odp_buffer_t buf);
#ifdef __cplusplus
}
diff --git a/platform/linux-generic/odp_buffer.c
b/platform/linux-generic/odp_buffer.c
index 57ba408..99b5f59 100644
--- a/platform/linux-generic/odp_buffer.c
+++ b/platform/linux-generic/odp_buffer.c
@@ -13,6 +13,15 @@
#include <string.h>
#include <stdio.h>
+odp_buffer_t odp_buffer_from_event(odp_event_t ev)
+{
+ return (odp_buffer_t)ev;
+}
+
+odp_event_t odp_buffer_to_event(odp_buffer_t buf)
+{
+ return (odp_event_t)buf;
+}
void *odp_buffer_addr(odp_buffer_t buf)
{
@@ -30,7 +39,7 @@ uint32_t odp_buffer_size(odp_buffer_t buf)
}
-int odp_buffer_type(odp_buffer_t buf)
+int _odp_buffer_type(odp_buffer_t buf)
{
odp_buffer_hdr_t *hdr = odp_buf_to_hdr(buf);
@@ -38,6 +47,12 @@ int odp_buffer_type(odp_buffer_t buf)
}
+int odp_buffer_type(odp_buffer_t buf)
+{
+ return _odp_buffer_type(buf);
+}
+
+
int odp_buffer_is_valid(odp_buffer_t buf)
{
return validate_buf(buf) != NULL;
diff --git a/platform/linux-generic/odp_event.c
b/platform/linux-generic/odp_event.c
new file mode 100644
index 0000000..c4291f8
--- /dev/null
+++ b/platform/linux-generic/odp_event.c
@@ -0,0 +1,19 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <odp_event.h>
+#include <odp_buffer.h>
+#include <odp_pool.h>
+#include <odp_buffer_internal.h>
+
+int odp_event_type(odp_event_t event)
+{
+ odp_buffer_t buf;
+
+ buf = odp_buffer_from_event(event);
+
+ return _odp_buffer_type(buf);
+}
--
2.1.0
_______________________________________________
lng-odp mailing list
[email protected]
http://lists.linaro.org/mailman/listinfo/lng-odp