diff mbox series

[API-NEXT,v2,5/6] linux-gen: queue: combine queue interface set functions

Message ID 20170704095343.4266-6-petri.savolainen@linaro.org
State New
Headers show
Series Queue interface clean up | expand

Commit Message

Petri Savolainen July 4, 2017, 9:53 a.m. UTC
Decrease queue interface size by combining four queue operation
set functions into a single function.

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

---
 platform/linux-generic/include/odp_queue_if.h | 16 +++++------
 platform/linux-generic/odp_packet_io.c        | 38 +++++++++++++--------------
 platform/linux-generic/odp_queue.c            | 34 +++++++++++-------------
 platform/linux-generic/odp_queue_scalable.c   | 32 ++++++++++------------
 platform/linux-generic/odp_traffic_mngr.c     |  6 ++---
 5 files changed, 58 insertions(+), 68 deletions(-)

-- 
2.13.0
diff mbox series

Patch

diff --git a/platform/linux-generic/include/odp_queue_if.h b/platform/linux-generic/include/odp_queue_if.h
index b5cbd515..7ba5c3c5 100644
--- a/platform/linux-generic/include/odp_queue_if.h
+++ b/platform/linux-generic/include/odp_queue_if.h
@@ -66,12 +66,11 @@  typedef void (*queue_set_pktout_fn_t)(queue_t q_int, odp_pktio_t pktio,
 typedef odp_pktin_queue_t (*queue_get_pktin_fn_t)(queue_t q_int);
 typedef void (*queue_set_pktin_fn_t)(queue_t q_int, odp_pktio_t pktio,
 				     int index);
-typedef void (*queue_set_enq_fn_t)(queue_t q_int, queue_enq_fn_t func);
-typedef void (*queue_set_enq_multi_fn_t)(queue_t q_int,
-					 queue_enq_multi_fn_t func);
-typedef void (*queue_set_deq_fn_t)(queue_t q_int, queue_deq_fn_t func);
-typedef void (*queue_set_deq_multi_fn_t)(queue_t q_int,
-					 queue_deq_multi_fn_t func);
+typedef void (*queue_set_enq_deq_fn_t)(queue_t q_int,
+				       queue_enq_fn_t enq,
+				       queue_enq_multi_fn_t enq_multi,
+				       queue_deq_fn_t deq,
+				       queue_deq_multi_fn_t deq_multi);
 typedef void (*queue_set_type_fn_t)(queue_t q_int, odp_queue_type_t type);
 
 /* Queue functions towards other internal components */
@@ -90,10 +89,7 @@  typedef struct {
 	queue_set_pktout_fn_t set_pktout;
 	queue_get_pktin_fn_t get_pktin;
 	queue_set_pktin_fn_t set_pktin;
-	queue_set_enq_fn_t set_enq_fn;
-	queue_set_enq_multi_fn_t set_enq_multi_fn;
-	queue_set_deq_fn_t set_deq_fn;
-	queue_set_deq_multi_fn_t set_deq_multi_fn;
+	queue_set_enq_deq_fn_t set_enq_deq_fn;
 	queue_set_type_fn_t set_type;
 } queue_fn_t;
 
diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c
index 0d825f91..6a181f53 100644
--- a/platform/linux-generic/odp_packet_io.c
+++ b/platform/linux-generic/odp_packet_io.c
@@ -1154,30 +1154,30 @@  int odp_pktio_stats_reset(odp_pktio_t pktio)
 	return ret;
 }
 
-static int pktin_enqueue(queue_t q_int ODP_UNUSED,
-			 odp_buffer_hdr_t *buf_hdr ODP_UNUSED)
+static int abort_pktin_enqueue(queue_t q_int ODP_UNUSED,
+			       odp_buffer_hdr_t *buf_hdr ODP_UNUSED)
 {
 	ODP_ABORT("attempted enqueue to a pktin queue");
 	return -1;
 }
 
-static int pktin_enq_multi(queue_t q_int ODP_UNUSED,
-			   odp_buffer_hdr_t *buf_hdr[] ODP_UNUSED,
-			   int num ODP_UNUSED)
+static int abort_pktin_enq_multi(queue_t q_int ODP_UNUSED,
+				 odp_buffer_hdr_t *buf_hdr[] ODP_UNUSED,
+				 int num ODP_UNUSED)
 {
 	ODP_ABORT("attempted enqueue to a pktin queue");
 	return 0;
 }
 
-static odp_buffer_hdr_t *pktout_dequeue(queue_t q_int ODP_UNUSED)
+static odp_buffer_hdr_t *abort_pktout_dequeue(queue_t q_int ODP_UNUSED)
 {
 	ODP_ABORT("attempted dequeue from a pktout queue");
 	return NULL;
 }
 
-static int pktout_deq_multi(queue_t q_int ODP_UNUSED,
-			    odp_buffer_hdr_t *buf_hdr[] ODP_UNUSED,
-			    int num ODP_UNUSED)
+static int abort_pktout_deq_multi(queue_t q_int ODP_UNUSED,
+				  odp_buffer_hdr_t *buf_hdr[] ODP_UNUSED,
+				  int num ODP_UNUSED)
 {
 	ODP_ABORT("attempted dequeue from a pktout queue");
 	return 0;
@@ -1272,12 +1272,11 @@  int odp_pktin_queue_config(odp_pktio_t pktio,
 
 			if (mode == ODP_PKTIN_MODE_QUEUE) {
 				queue_fn->set_pktin(q_int, pktio, i);
-				queue_fn->set_enq_fn(q_int, pktin_enqueue);
-				queue_fn->set_deq_fn(q_int, pktin_dequeue);
-				queue_fn->set_enq_multi_fn(q_int,
-							   pktin_enq_multi);
-				queue_fn->set_deq_multi_fn(q_int,
-							   pktin_deq_multi);
+				queue_fn->set_enq_deq_fn(q_int,
+							 abort_pktin_enqueue,
+							 abort_pktin_enq_multi,
+							 pktin_dequeue,
+							 pktin_deq_multi);
 			}
 
 			entry->s.in_queue[i].queue = queue;
@@ -1401,10 +1400,11 @@  int odp_pktout_queue_config(odp_pktio_t pktio,
 			queue_fn->set_pktout(q_int, pktio, i);
 
 			/* Override default enqueue / dequeue functions */
-			queue_fn->set_enq_fn(q_int, pktout_enqueue);
-			queue_fn->set_deq_fn(q_int, pktout_dequeue);
-			queue_fn->set_enq_multi_fn(q_int, pktout_enq_multi);
-			queue_fn->set_deq_multi_fn(q_int, pktout_deq_multi);
+			queue_fn->set_enq_deq_fn(q_int,
+						 pktout_enqueue,
+						 pktout_enq_multi,
+						 abort_pktout_dequeue,
+						 abort_pktout_deq_multi);
 
 			entry->s.out_queue[i].queue = queue;
 		}
diff --git a/platform/linux-generic/odp_queue.c b/platform/linux-generic/odp_queue.c
index 60f88f09..ec225d00 100644
--- a/platform/linux-generic/odp_queue.c
+++ b/platform/linux-generic/odp_queue.c
@@ -748,24 +748,25 @@  static void queue_set_pktin(queue_t q_int, odp_pktio_t pktio, int index)
 	qentry->s.pktin.index = index;
 }
 
-static void queue_set_enq_func(queue_t q_int, queue_enq_fn_t func)
+static void queue_set_enq_deq_func(queue_t q_int,
+				   queue_enq_fn_t enq,
+				   queue_enq_multi_fn_t enq_multi,
+				   queue_deq_fn_t deq,
+				   queue_deq_multi_fn_t deq_multi)
 {
-	qentry_from_int(q_int)->s.enqueue = func;
-}
+	queue_entry_t *qentry = qentry_from_int(q_int);
 
-static void queue_set_enq_multi_func(queue_t q_int, queue_enq_multi_fn_t func)
-{
-	qentry_from_int(q_int)->s.enqueue_multi = func;
-}
+	if (enq)
+		qentry->s.enqueue = enq;
 
-static void queue_set_deq_func(queue_t q_int, queue_deq_fn_t func)
-{
-	qentry_from_int(q_int)->s.dequeue = func;
-}
+	if (enq_multi)
+		qentry->s.enqueue_multi = enq_multi;
 
-static void queue_set_deq_multi_func(queue_t q_int, queue_deq_multi_fn_t func)
-{
-	qentry_from_int(q_int)->s.dequeue_multi = func;
+	if (deq)
+		qentry->s.dequeue = deq;
+
+	if (deq_multi)
+		qentry->s.dequeue_multi = deq_multi;
 }
 
 static void queue_set_type(queue_t q_int, odp_queue_type_t type)
@@ -821,9 +822,6 @@  queue_fn_t queue_default_fn = {
 	.set_pktout = queue_set_pktout,
 	.get_pktin = queue_get_pktin,
 	.set_pktin = queue_set_pktin,
-	.set_enq_fn = queue_set_enq_func,
-	.set_enq_multi_fn = queue_set_enq_multi_func,
-	.set_deq_fn = queue_set_deq_func,
-	.set_deq_multi_fn = queue_set_deq_multi_func,
+	.set_enq_deq_fn = queue_set_enq_deq_func,
 	.set_type = queue_set_type
 };
diff --git a/platform/linux-generic/odp_queue_scalable.c b/platform/linux-generic/odp_queue_scalable.c
index 7441a2a9..14fa1833 100644
--- a/platform/linux-generic/odp_queue_scalable.c
+++ b/platform/linux-generic/odp_queue_scalable.c
@@ -937,24 +937,23 @@  static void queue_set_pktin(queue_t handle, odp_pktio_t pktio, int index)
 	qentry_from_int(handle)->s.pktin.index = index;
 }
 
-static void queue_set_enq_func(queue_t handle, queue_enq_fn_t func)
+static void queue_set_enq_deq_func(queue_t handle,
+				   queue_enq_fn_t enq,
+				   queue_enq_multi_fn_t enq_multi,
+				   queue_deq_fn_t deq,
+				   queue_deq_multi_fn_t deq_multi)
 {
-	qentry_from_int(handle)->s.enqueue = func;
-}
+	if (enq)
+		qentry_from_int(handle)->s.enqueue = enq;
 
-static void queue_set_enq_multi_func(queue_t handle, queue_enq_multi_fn_t func)
-{
-	qentry_from_int(handle)->s.enqueue_multi = func;
-}
+	if (enq_multi)
+		qentry_from_int(handle)->s.enqueue_multi = enq_multi;
 
-static void queue_set_deq_func(queue_t handle, queue_deq_fn_t func)
-{
-	qentry_from_int(handle)->s.dequeue = func;
-}
+	if (deq)
+		qentry_from_int(handle)->s.dequeue = deq;
 
-static void queue_set_deq_multi_func(queue_t handle, queue_deq_multi_fn_t func)
-{
-	qentry_from_int(handle)->s.dequeue_multi = func;
+	if (deq_multi)
+		qentry_from_int(handle)->s.dequeue_multi = deq_multi;
 }
 
 static void queue_set_type(queue_t handle, odp_queue_type_t type)
@@ -1013,9 +1012,6 @@  queue_fn_t queue_scalable_fn = {
 	.set_pktout = queue_set_pktout,
 	.get_pktin = queue_get_pktin,
 	.set_pktin = queue_set_pktin,
-	.set_enq_fn = queue_set_enq_func,
-	.set_enq_multi_fn = queue_set_enq_multi_func,
-	.set_deq_fn = queue_set_deq_func,
-	.set_deq_multi_fn = queue_set_deq_multi_func,
+	.set_enq_deq_fn = queue_set_enq_deq_func,
 	.set_type = queue_set_type
 };
diff --git a/platform/linux-generic/odp_traffic_mngr.c b/platform/linux-generic/odp_traffic_mngr.c
index 8b5f3187..1f254d75 100644
--- a/platform/linux-generic/odp_traffic_mngr.c
+++ b/platform/linux-generic/odp_traffic_mngr.c
@@ -3927,9 +3927,9 @@  odp_tm_queue_t odp_tm_queue_create(odp_tm_t odp_tm,
 	}
 	tm_queue_obj->tm_qentry = queue_fn->from_ext(queue);
 	queue_fn->set_type(tm_queue_obj->tm_qentry, QUEUE_TYPE_TM);
-	queue_fn->set_enq_fn(tm_queue_obj->tm_qentry, queue_tm_reenq);
-	queue_fn->set_enq_multi_fn(tm_queue_obj->tm_qentry,
-				   queue_tm_reenq_multi);
+	queue_fn->set_enq_deq_fn(tm_queue_obj->tm_qentry,
+				 queue_tm_reenq, queue_tm_reenq_multi,
+				 NULL, NULL);
 
 	tm_system->queue_num_tbl[tm_queue_obj->queue_num - 1] = tm_queue_obj;
 	odp_ticketlock_lock(&tm_system->tm_system_lock);