diff mbox series

[v3,1/10] linux-gen: queue: inline queue from index conversion

Message ID 1519819218-27901-2-git-send-email-odpbot@yandex.ru
State New
Headers show
Series [v3,1/10] linux-gen: queue: inline queue from index conversion | expand

Commit Message

Github ODP bot Feb. 28, 2018, noon UTC
From: Petri Savolainen <petri.savolainen@linaro.org>


Inline queue handle from queue index conversion function.

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

---
/** Email created from pull request 492 (psavol:master-sched-optim)
 ** https://github.com/Linaro/odp/pull/492
 ** Patch: https://github.com/Linaro/odp/pull/492.patch
 ** Base sha: f5e12df388352b27f09787028a0040afb28564f4
 ** Merge commit sha: 56e6340663c8679516a24dc81df13a53488b86b8
 **/
 .../linux-generic/include/odp_queue_internal.h     |  7 +++++-
 platform/linux-generic/odp_queue_basic.c           | 29 ++++++----------------
 platform/linux-generic/odp_schedule_basic.c        |  5 +---
 platform/linux-generic/odp_schedule_iquery.c       |  2 +-
 platform/linux-generic/odp_schedule_sp.c           |  3 ++-
 5 files changed, 17 insertions(+), 29 deletions(-)
diff mbox series

Patch

diff --git a/platform/linux-generic/include/odp_queue_internal.h b/platform/linux-generic/include/odp_queue_internal.h
index b14f3ea83..8215a8180 100644
--- a/platform/linux-generic/include/odp_queue_internal.h
+++ b/platform/linux-generic/include/odp_queue_internal.h
@@ -63,11 +63,16 @@  union queue_entry_u {
 	uint8_t pad[ROUNDUP_CACHE_LINE(sizeof(struct queue_entry_s))];
 };
 
-static inline uint32_t queue_to_id(odp_queue_t handle)
+static inline uint32_t queue_to_index(odp_queue_t handle)
 {
 	return _odp_typeval(handle) - 1;
 }
 
+static inline odp_queue_t queue_from_index(uint32_t queue_id)
+{
+	return _odp_cast_scalar(odp_queue_t, queue_id + 1);
+}
+
 static inline queue_entry_t *qentry_from_int(queue_t q_int)
 {
 	return (queue_entry_t *)(void *)(q_int);
diff --git a/platform/linux-generic/odp_queue_basic.c b/platform/linux-generic/odp_queue_basic.c
index 0c0a11ec1..2801b220f 100644
--- a/platform/linux-generic/odp_queue_basic.c
+++ b/platform/linux-generic/odp_queue_basic.c
@@ -51,26 +51,16 @@  typedef struct queue_global_t {
 
 static queue_global_t *queue_glb;
 
-static
-queue_entry_t *get_qentry(uint32_t queue_id);
-
-static inline queue_entry_t *handle_to_qentry(odp_queue_t handle)
+static inline queue_entry_t *get_qentry(uint32_t queue_id)
 {
-	uint32_t queue_id;
-
-	queue_id = queue_to_id(handle);
-	return get_qentry(queue_id);
+	return &queue_glb->queue[queue_id];
 }
 
-static inline odp_queue_t queue_from_id(uint32_t queue_id)
+static inline queue_entry_t *handle_to_qentry(odp_queue_t handle)
 {
-	return _odp_cast_scalar(odp_queue_t, queue_id + 1);
-}
+	uint32_t queue_id = queue_to_index(handle);
 
-static
-queue_entry_t *get_qentry(uint32_t queue_id)
-{
-	return &queue_glb->queue[queue_id];
+	return get_qentry(queue_id);
 }
 
 static int queue_init_global(void)
@@ -98,7 +88,7 @@  static int queue_init_global(void)
 		queue_entry_t *queue = get_qentry(i);
 		LOCK_INIT(&queue->s.lock);
 		queue->s.index  = i;
-		queue->s.handle = queue_from_id(i);
+		queue->s.handle = queue_from_index(i);
 	}
 
 	lf_func = &queue_glb->queue_lf_func;
@@ -661,7 +651,7 @@  static int queue_info(odp_queue_t handle, odp_queue_info_t *info)
 		return -1;
 	}
 
-	queue_id = queue_to_id(handle);
+	queue_id = queue_to_index(handle);
 
 	if (odp_unlikely(queue_id >= ODP_CONFIG_QUEUES)) {
 		ODP_ERR("Invalid queue handle:%" PRIu64 "\n",
@@ -689,11 +679,6 @@  static int queue_info(odp_queue_t handle, odp_queue_info_t *info)
 	return 0;
 }
 
-odp_queue_t sched_cb_queue_handle(uint32_t queue_index)
-{
-	return queue_from_id(queue_index);
-}
-
 int sched_cb_queue_deq_multi(uint32_t queue_index, odp_event_t ev[], int num)
 {
 	queue_entry_t *qe = get_qentry(queue_index);
diff --git a/platform/linux-generic/odp_schedule_basic.c b/platform/linux-generic/odp_schedule_basic.c
index 7195eedea..e5e1fe60e 100644
--- a/platform/linux-generic/odp_schedule_basic.c
+++ b/platform/linux-generic/odp_schedule_basic.c
@@ -25,10 +25,7 @@ 
 #include <odp/api/packet_io.h>
 #include <odp_ring_internal.h>
 #include <odp_timer_internal.h>
-
-/* Should remove this dependency */
 #include <odp_queue_internal.h>
-#include <odp_timer_internal.h>
 
 /* Number of priority levels  */
 #define NUM_PRIO 8
@@ -876,7 +873,7 @@  static inline int do_schedule_grp(odp_queue_t *out_queue, odp_event_t out_ev[],
 				continue;
 			}
 
-			handle            = sched_cb_queue_handle(qi);
+			handle            = queue_from_index(qi);
 			sched_local.num   = num;
 			sched_local.index = 0;
 			sched_local.queue = handle;
diff --git a/platform/linux-generic/odp_schedule_iquery.c b/platform/linux-generic/odp_schedule_iquery.c
index 3ce85394e..ea62c3645 100644
--- a/platform/linux-generic/odp_schedule_iquery.c
+++ b/platform/linux-generic/odp_schedule_iquery.c
@@ -1541,7 +1541,7 @@  static inline int consume_queue(int prio, unsigned int queue_index)
 
 	cache->top = &cache->stash[0];
 	cache->count = count;
-	cache->queue = sched_cb_queue_handle(queue_index);
+	cache->queue = queue_from_index(queue_index);
 	return count;
 }
 
diff --git a/platform/linux-generic/odp_schedule_sp.c b/platform/linux-generic/odp_schedule_sp.c
index e46ae4480..007d673f0 100644
--- a/platform/linux-generic/odp_schedule_sp.c
+++ b/platform/linux-generic/odp_schedule_sp.c
@@ -18,6 +18,7 @@ 
 #include <odp_config_internal.h>
 #include <odp_ring_internal.h>
 #include <odp_timer_internal.h>
+#include <odp_queue_internal.h>
 
 #define NUM_THREAD        ODP_THREAD_COUNT_MAX
 #define NUM_QUEUE         ODP_CONFIG_QUEUES
@@ -564,7 +565,7 @@  static int schedule_multi(odp_queue_t *from, uint64_t wait,
 			sched_local.cmd = cmd;
 
 			if (from)
-				*from = sched_cb_queue_handle(qi);
+				*from = queue_from_index(qi);
 
 			return num;
 		}