[v1,2/6] linux-gen: queue: inline enq and deq functions

Message ID 1534510807-11066-3-git-send-email-odpbot@yandex.ru
State New
Headers show
Series
  • Separate queue operations for plain and scheduled queues
Related show

Commit Message

Github ODP bot Aug. 17, 2018, 1 p.m.
From: Petri Savolainen <petri.savolainen@linaro.org>


Inline queue enqueue and dequeue functions.

Signed-off-by: Petri Savolainen <petri.savolainen@linaro.org>

---
/** Email created from pull request 675 (psavol:master-queue-inline)
 ** https://github.com/Linaro/odp/pull/675
 ** Patch: https://github.com/Linaro/odp/pull/675.patch
 ** Base sha: dc28824415ea510e3ef62e47f7640bf4a8420fde
 ** Merge commit sha: a68fc608f4c460289d09e09e68f3646d1846737a
 **/
 .../include/odp/api/plat/queue_inline_types.h | 26 +++++++++
 .../include/odp/api/plat/queue_inlines.h      | 29 +++++++++-
 platform/linux-generic/include/odp_queue_if.h | 25 ---------
 platform/linux-generic/odp_queue_basic.c      |  2 +-
 platform/linux-generic/odp_queue_if.c         | 56 ++++++-------------
 platform/linux-generic/odp_queue_scalable.c   |  2 +-
 6 files changed, 74 insertions(+), 66 deletions(-)

Patch

diff --git a/platform/linux-generic/include/odp/api/plat/queue_inline_types.h b/platform/linux-generic/include/odp/api/plat/queue_inline_types.h
index 3a8df7a4b..f81a84782 100644
--- a/platform/linux-generic/include/odp/api/plat/queue_inline_types.h
+++ b/platform/linux-generic/include/odp/api/plat/queue_inline_types.h
@@ -12,6 +12,7 @@  extern "C" {
 #endif
 
 #include <stdint.h>
+#include <odp/api/spec/queue_types.h>
 
 /** @cond _ODP_HIDE_FROM_DOXYGEN_ */
 
@@ -26,6 +27,31 @@  typedef struct _odp_queue_inline_offset_t {
 
 } _odp_queue_inline_offset_t;
 
+/* Queue API functions */
+typedef struct {
+	odp_queue_t (*queue_create)(const char *name,
+				    const odp_queue_param_t *param);
+	int (*queue_destroy)(odp_queue_t queue);
+	odp_queue_t (*queue_lookup)(const char *name);
+	int (*queue_capability)(odp_queue_capability_t *capa);
+	int (*queue_context_set)(odp_queue_t queue, void *context,
+				 uint32_t len);
+	int (*queue_enq)(odp_queue_t queue, odp_event_t ev);
+	int (*queue_enq_multi)(odp_queue_t queue, const odp_event_t events[],
+			       int num);
+	odp_event_t (*queue_deq)(odp_queue_t queue);
+	int (*queue_deq_multi)(odp_queue_t queue, odp_event_t events[],
+			       int num);
+	odp_queue_type_t (*queue_type)(odp_queue_t queue);
+	odp_schedule_sync_t (*queue_sched_type)(odp_queue_t queue);
+	odp_schedule_prio_t (*queue_sched_prio)(odp_queue_t queue);
+	odp_schedule_group_t (*queue_sched_group)(odp_queue_t queue);
+	uint32_t (*queue_lock_count)(odp_queue_t queue);
+	uint64_t (*queue_to_u64)(odp_queue_t queue);
+	void (*queue_param_init)(odp_queue_param_t *param);
+	int (*queue_info)(odp_queue_t queue, odp_queue_info_t *info);
+} _odp_queue_api_fn_t;
+
 /** @endcond */
 
 #ifdef __cplusplus
diff --git a/platform/linux-generic/include/odp/api/plat/queue_inlines.h b/platform/linux-generic/include/odp/api/plat/queue_inlines.h
index f802c96e7..c557b4ba3 100644
--- a/platform/linux-generic/include/odp/api/plat/queue_inlines.h
+++ b/platform/linux-generic/include/odp/api/plat/queue_inlines.h
@@ -12,11 +12,16 @@ 
 /** @cond _ODP_HIDE_FROM_DOXYGEN_ */
 
 extern _odp_queue_inline_offset_t _odp_queue_inline_offset;
+extern const _odp_queue_api_fn_t *_odp_queue_api;
 
 #ifndef _ODP_NO_INLINE
 	/* Inline functions by default */
 	#define _ODP_INLINE static inline
-	#define odp_queue_context __odp_queue_context
+	#define odp_queue_context   __odp_queue_context
+	#define odp_queue_enq       __odp_queue_enq
+	#define odp_queue_enq_multi __odp_queue_enq_multi
+	#define odp_queue_deq       __odp_queue_deq
+	#define odp_queue_deq_multi __odp_queue_deq_multi
 #else
 	#define _ODP_INLINE
 #endif
@@ -31,6 +36,28 @@  _ODP_INLINE void *odp_queue_context(odp_queue_t handle)
 	return context;
 }
 
+_ODP_INLINE int odp_queue_enq(odp_queue_t queue, odp_event_t ev)
+{
+	return _odp_queue_api->queue_enq(queue, ev);
+}
+
+_ODP_INLINE int odp_queue_enq_multi(odp_queue_t queue,
+				    const odp_event_t events[], int num)
+{
+	return _odp_queue_api->queue_enq_multi(queue, events, num);
+}
+
+_ODP_INLINE odp_event_t odp_queue_deq(odp_queue_t queue)
+{
+	return _odp_queue_api->queue_deq(queue);
+}
+
+_ODP_INLINE int odp_queue_deq_multi(odp_queue_t queue,
+				    odp_event_t events[], int num)
+{
+	return _odp_queue_api->queue_deq_multi(queue, events, num);
+}
+
 /** @endcond */
 
 #endif
diff --git a/platform/linux-generic/include/odp_queue_if.h b/platform/linux-generic/include/odp_queue_if.h
index 2eaf8771e..f89690bd7 100644
--- a/platform/linux-generic/include/odp_queue_if.h
+++ b/platform/linux-generic/include/odp_queue_if.h
@@ -18,31 +18,6 @@  extern "C" {
 
 #define QUEUE_MULTI_MAX CONFIG_BURST_SIZE
 
-/* Queue API functions */
-typedef struct {
-	odp_queue_t (*queue_create)(const char *name,
-				    const odp_queue_param_t *param);
-	int (*queue_destroy)(odp_queue_t queue);
-	odp_queue_t (*queue_lookup)(const char *name);
-	int (*queue_capability)(odp_queue_capability_t *capa);
-	int (*queue_context_set)(odp_queue_t queue, void *context,
-				 uint32_t len);
-	int (*queue_enq)(odp_queue_t queue, odp_event_t ev);
-	int (*queue_enq_multi)(odp_queue_t queue, const odp_event_t events[],
-			       int num);
-	odp_event_t (*queue_deq)(odp_queue_t queue);
-	int (*queue_deq_multi)(odp_queue_t queue, odp_event_t events[],
-			       int num);
-	odp_queue_type_t (*queue_type)(odp_queue_t queue);
-	odp_schedule_sync_t (*queue_sched_type)(odp_queue_t queue);
-	odp_schedule_prio_t (*queue_sched_prio)(odp_queue_t queue);
-	odp_schedule_group_t (*queue_sched_group)(odp_queue_t queue);
-	uint32_t (*queue_lock_count)(odp_queue_t queue);
-	uint64_t (*queue_to_u64)(odp_queue_t hdl);
-	void (*queue_param_init)(odp_queue_param_t *param);
-	int (*queue_info)(odp_queue_t queue, odp_queue_info_t *info);
-} queue_api_t;
-
 typedef int (*queue_init_global_fn_t)(void);
 typedef int (*queue_term_global_fn_t)(void);
 typedef int (*queue_init_local_fn_t)(void);
diff --git a/platform/linux-generic/odp_queue_basic.c b/platform/linux-generic/odp_queue_basic.c
index 89eed3c0d..3f57a23db 100644
--- a/platform/linux-generic/odp_queue_basic.c
+++ b/platform/linux-generic/odp_queue_basic.c
@@ -902,7 +902,7 @@  static odp_queue_t queue_to_ext(void *q_int)
 }
 
 /* API functions */
-queue_api_t queue_basic_api = {
+_odp_queue_api_fn_t queue_basic_api = {
 	.queue_create = queue_create,
 	.queue_destroy = queue_destroy,
 	.queue_lookup = queue_lookup,
diff --git a/platform/linux-generic/odp_queue_if.c b/platform/linux-generic/odp_queue_if.c
index f3984542a..65f65006e 100644
--- a/platform/linux-generic/odp_queue_if.c
+++ b/platform/linux-generic/odp_queue_if.c
@@ -19,101 +19,81 @@ 
 #include <odp/visibility_begin.h>
 
 _odp_queue_inline_offset_t ODP_ALIGNED_CACHE _odp_queue_inline_offset;
+const _odp_queue_api_fn_t *_odp_queue_api;
 
 #include <odp/visibility_end.h>
 
-extern const queue_api_t queue_scalable_api;
+extern const _odp_queue_api_fn_t queue_scalable_api;
 extern const queue_fn_t queue_scalable_fn;
 
-extern const queue_api_t queue_basic_api;
+extern const _odp_queue_api_fn_t queue_basic_api;
 extern const queue_fn_t queue_basic_fn;
 
-const queue_api_t *queue_api;
 const queue_fn_t *queue_fn;
 
 odp_queue_t odp_queue_create(const char *name, const odp_queue_param_t *param)
 {
-	return queue_api->queue_create(name, param);
+	return _odp_queue_api->queue_create(name, param);
 }
 
 int odp_queue_destroy(odp_queue_t queue)
 {
-	return queue_api->queue_destroy(queue);
+	return _odp_queue_api->queue_destroy(queue);
 }
 
 odp_queue_t odp_queue_lookup(const char *name)
 {
-	return queue_api->queue_lookup(name);
+	return _odp_queue_api->queue_lookup(name);
 }
 
 int odp_queue_capability(odp_queue_capability_t *capa)
 {
-	return queue_api->queue_capability(capa);
+	return _odp_queue_api->queue_capability(capa);
 }
 
 int odp_queue_context_set(odp_queue_t queue, void *context, uint32_t len)
 {
-	return queue_api->queue_context_set(queue, context, len);
-}
-
-int odp_queue_enq(odp_queue_t queue, odp_event_t ev)
-{
-	return queue_api->queue_enq(queue, ev);
-}
-
-int odp_queue_enq_multi(odp_queue_t queue, const odp_event_t events[], int num)
-{
-	return queue_api->queue_enq_multi(queue, events, num);
-}
-
-odp_event_t odp_queue_deq(odp_queue_t queue)
-{
-	return queue_api->queue_deq(queue);
-}
-
-int odp_queue_deq_multi(odp_queue_t queue, odp_event_t events[], int num)
-{
-	return queue_api->queue_deq_multi(queue, events, num);
+	return _odp_queue_api->queue_context_set(queue, context, len);
 }
 
 odp_queue_type_t odp_queue_type(odp_queue_t queue)
 {
-	return queue_api->queue_type(queue);
+	return _odp_queue_api->queue_type(queue);
 }
 
 odp_schedule_sync_t odp_queue_sched_type(odp_queue_t queue)
 {
-	return queue_api->queue_sched_type(queue);
+	return _odp_queue_api->queue_sched_type(queue);
 }
 
 odp_schedule_prio_t odp_queue_sched_prio(odp_queue_t queue)
 {
-	return queue_api->queue_sched_prio(queue);
+	return _odp_queue_api->queue_sched_prio(queue);
 }
 
 odp_schedule_group_t odp_queue_sched_group(odp_queue_t queue)
 {
-	return queue_api->queue_sched_group(queue);
+	return _odp_queue_api->queue_sched_group(queue);
 }
 
 uint32_t odp_queue_lock_count(odp_queue_t queue)
 {
-	return queue_api->queue_lock_count(queue);
+	return _odp_queue_api->queue_lock_count(queue);
 }
 
 uint64_t odp_queue_to_u64(odp_queue_t hdl)
 {
-	return queue_api->queue_to_u64(hdl);
+	return _odp_queue_api->queue_to_u64(hdl);
 }
 
 void odp_queue_param_init(odp_queue_param_t *param)
 {
-	return queue_api->queue_param_init(param);
+	return _odp_queue_api->queue_param_init(param);
 }
 
 int odp_queue_info(odp_queue_t queue, odp_queue_info_t *info)
 {
-	return queue_api->queue_info(queue, info);
+	return _odp_queue_api->queue_info(queue, info);
 }
 
 int _odp_queue_init_global(void)
@@ -127,10 +107,10 @@  int _odp_queue_init_global(void)
 	    !strcmp(sched, "sp") ||
 	    !strcmp(sched, "iquery")) {
 		queue_fn = &queue_basic_fn;
-		queue_api = &queue_basic_api;
+		_odp_queue_api = &queue_basic_api;
 	} else if (!strcmp(sched, "scalable")) {
 		queue_fn = &queue_scalable_fn;
-		queue_api = &queue_scalable_api;
+		_odp_queue_api = &queue_scalable_api;
 	} else {
 		ODP_ABORT("Unknown scheduler specified via ODP_SCHEDULER\n");
 		return -1;
diff --git a/platform/linux-generic/odp_queue_scalable.c b/platform/linux-generic/odp_queue_scalable.c
index 13e93bc19..3ca865b05 100644
--- a/platform/linux-generic/odp_queue_scalable.c
+++ b/platform/linux-generic/odp_queue_scalable.c
@@ -961,7 +961,7 @@  static odp_queue_t queue_to_ext(void *handle)
 }
 
 /* API functions */
-queue_api_t queue_scalable_api = {
+_odp_queue_api_fn_t queue_scalable_api = {
 	.queue_create = queue_create,
 	.queue_destroy = queue_destroy,
 	.queue_lookup = queue_lookup,