[API-NEXT,v2,2/3] linux-generic: queue: add fns towards pktio and TM

Message ID 1496275208-6349-3-git-send-email-odpbot@yandex.ru
State New
Headers show
Series
  • Modular queue interface
Related show

Commit Message

Github ODP bot June 1, 2017, midnight
From: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>


Pkt I/O and TM access queue internal structure members. Introduced
functions in the function pointer table to access these members.

Signed-off-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>

---
/** Email created from pull request 43 (nagarahalli:api-next-mod-queue1)
 ** https://github.com/Linaro/odp/pull/43
 ** Patch: https://github.com/Linaro/odp/pull/43.patch
 ** Base sha: b67bfce457a7546bbae4dad16b5185629eda77e5
 ** Merge commit sha: cbf36c8b1ca89d3854e7d26a0ea4e367a51427bb
 **/
 .../linux-generic/include/odp_queue_internal.h     |  1 -
 platform/linux-generic/include/odp_schedule_if.h   | 30 +++++++++--
 platform/linux-generic/odp_packet_io.c             | 41 +++++++++------
 platform/linux-generic/odp_queue.c                 | 60 +++++++++++++++++++++-
 platform/linux-generic/odp_traffic_mngr.c          |  7 +--
 5 files changed, 113 insertions(+), 26 deletions(-)

Patch hide | download patch | download mbox

diff --git a/platform/linux-generic/include/odp_queue_internal.h b/platform/linux-generic/include/odp_queue_internal.h
index 759d36e0..8f46ba2e 100644
--- a/platform/linux-generic/include/odp_queue_internal.h
+++ b/platform/linux-generic/include/odp_queue_internal.h
@@ -40,7 +40,6 @@  extern "C" {
 
 /* forward declaration */
 union queue_entry_u;
-
 typedef int (*enq_func_t)(union queue_entry_u *, odp_buffer_hdr_t *);
 typedef	odp_buffer_hdr_t *(*deq_func_t)(union queue_entry_u *);
 
diff --git a/platform/linux-generic/include/odp_schedule_if.h b/platform/linux-generic/include/odp_schedule_if.h
index e5d76103..f3989ef8 100644
--- a/platform/linux-generic/include/odp_schedule_if.h
+++ b/platform/linux-generic/include/odp_schedule_if.h
@@ -14,9 +14,7 @@  extern "C" {
 #include <odp/api/queue.h>
 #include <odp_queue_internal.h>
 #include <odp/api/schedule.h>
-
-/* Internal abstract queue type */
-typedef void* queue_t;
+#include <odp/api/packet_io.h>
 
 /* Queue API functions */
 typedef struct {
@@ -44,6 +42,17 @@  typedef struct {
 	int (*queue_info)(odp_queue_t queue, odp_queue_info_t *info);
 } queue_api_t;
 
+/* Internal abstract queue type */
+typedef void* queue_t;
+
+typedef int (*enq_func_t)(union queue_entry_u *, odp_buffer_hdr_t *);
+typedef	odp_buffer_hdr_t *(*deq_func_t)(union queue_entry_u *);
+
+typedef int (*enq_multi_func_t)(union queue_entry_u *,
+				odp_buffer_hdr_t **, int);
+typedef	int (*deq_multi_func_t)(union queue_entry_u *,
+				odp_buffer_hdr_t **, int);
+
 /* Queue functions towards other internal components */
 typedef struct {
 	int (*queue_init_global)(void);
@@ -54,9 +63,22 @@  typedef struct {
 	odp_buffer_hdr_t *(*queue_deq)(queue_entry_t *queue);
 	int (*queue_deq_multi)(queue_entry_t *queue,
 			       odp_buffer_hdr_t *buf_hdr[], int num);
+	odp_pktout_queue_t (*queue_get_pktout)(queue_entry_t *queue);
+	void (*queue_set_pktout)(queue_entry_t *queue, odp_pktio_t pktio,
+				 int index);
+	odp_pktin_queue_t (*queue_get_pktin)(queue_entry_t *queue);
+	void (*queue_set_pktin)(queue_entry_t *queue, odp_pktio_t pktio,
+				int index);
+	void (*queue_set_enq_func)(queue_entry_t *queue, enq_func_t func);
+	void (*queue_set_enq_multi_func)(queue_entry_t *queue,
+					 enq_multi_func_t func);
+	void (*queue_set_deq_func)(queue_entry_t *queue, deq_func_t func);
+	void (*queue_set_deq_multi_func)(queue_entry_t *queue,
+					 deq_multi_func_t func);
+	void (*queue_set_type)(queue_entry_t *queue, odp_queue_type_t type);
 } queue_fn_t;
 
-const queue_fn_t *queue_fn;
+extern const queue_fn_t *queue_fn;
 
 typedef void (*schedule_pktio_start_fn_t)(int pktio_index, int num_in_queue,
 					  int in_queue_idx[]);
diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c
index 4d1ab519..19ff5a28 100644
--- a/platform/linux-generic/odp_packet_io.c
+++ b/platform/linux-generic/odp_packet_io.c
@@ -592,7 +592,7 @@  int pktout_enqueue(queue_entry_t *qentry, odp_buffer_hdr_t *buf_hdr)
 				    &nbr))
 		return (nbr == len ? 0 : -1);
 
-	nbr = odp_pktout_send(qentry->s.pktout, &pkt, len);
+	nbr = odp_pktout_send(queue_fn->queue_get_pktout(qentry), &pkt, len);
 	return (nbr == len ? 0 : -1);
 }
 
@@ -616,7 +616,7 @@  int pktout_enq_multi(queue_entry_t *qentry, odp_buffer_hdr_t *buf_hdr[],
 	for (i = 0; i < num; ++i)
 		pkt_tbl[i] = _odp_packet_from_buffer(buf_hdr[i]->handle.handle);
 
-	nbr = odp_pktout_send(qentry->s.pktout, pkt_tbl, num);
+	nbr = odp_pktout_send(queue_fn->queue_get_pktout(qentry), pkt_tbl, num);
 	return nbr;
 }
 
@@ -645,7 +645,8 @@  odp_buffer_hdr_t *pktin_dequeue(queue_entry_t *qentry)
 	if (buf_hdr != NULL)
 		return buf_hdr;
 
-	pkts = pktin_recv_buf(qentry->s.pktin, hdr_tbl, QUEUE_MULTI_MAX);
+	pkts = pktin_recv_buf(queue_fn->queue_get_pktin(qentry),
+			      hdr_tbl, QUEUE_MULTI_MAX);
 
 	if (pkts <= 0)
 		return NULL;
@@ -679,7 +680,8 @@  int pktin_deq_multi(queue_entry_t *qentry, odp_buffer_hdr_t *buf_hdr[], int num)
 	if (nbr == num)
 		return nbr;
 
-	pkts = pktin_recv_buf(qentry->s.pktin, hdr_tbl, QUEUE_MULTI_MAX);
+	pkts = pktin_recv_buf(queue_fn->queue_get_pktin(qentry),
+			      hdr_tbl, QUEUE_MULTI_MAX);
 	if (pkts <= 0)
 		return nbr;
 
@@ -1276,13 +1278,15 @@  int odp_pktin_queue_config(odp_pktio_t pktio,
 				queue_entry_t *qentry;
 
 				qentry = queue_to_qentry(queue);
-				qentry->s.pktin.index  = i;
-				qentry->s.pktin.pktio  = pktio;
-
-				qentry->s.enqueue = pktin_enqueue;
-				qentry->s.dequeue = pktin_dequeue;
-				qentry->s.enqueue_multi = pktin_enq_multi;
-				qentry->s.dequeue_multi = pktin_deq_multi;
+				queue_fn->queue_set_pktin(qentry, pktio, i);
+				queue_fn->queue_set_enq_func(qentry,
+							     pktin_enqueue);
+				queue_fn->queue_set_deq_func(qentry,
+							     pktin_dequeue);
+				queue_fn->queue_set_enq_multi_func(qentry,
+							 pktin_enq_multi);
+				queue_fn->queue_set_deq_multi_func(qentry,
+							 pktin_deq_multi);
 			}
 
 			entry->s.in_queue[i].queue = queue;
@@ -1400,14 +1404,17 @@  int odp_pktout_queue_config(odp_pktio_t pktio,
 			}
 
 			qentry = queue_to_qentry(queue);
-			qentry->s.pktout.index  = i;
-			qentry->s.pktout.pktio  = pktio;
+			queue_fn->queue_set_pktout(qentry, pktio, i);
 
 			/* Override default enqueue / dequeue functions */
-			qentry->s.enqueue       = pktout_enqueue;
-			qentry->s.dequeue       = pktout_dequeue;
-			qentry->s.enqueue_multi = pktout_enq_multi;
-			qentry->s.dequeue_multi = pktout_deq_multi;
+			queue_fn->queue_set_enq_func(qentry,
+						     pktout_enqueue);
+			queue_fn->queue_set_deq_func(qentry,
+						     pktout_dequeue);
+			queue_fn->queue_set_enq_multi_func(qentry,
+							   pktout_enq_multi);
+			queue_fn->queue_set_deq_multi_func(qentry,
+							   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 928d767a..06d2e263 100644
--- a/platform/linux-generic/odp_queue.c
+++ b/platform/linux-generic/odp_queue.c
@@ -770,6 +770,55 @@  static uint64_t queue_to_u64(odp_queue_t hdl)
 	return _odp_pri(hdl);
 }
 
+static odp_pktout_queue_t queue_get_pktout(queue_entry_t *queue)
+{
+	return queue->s.pktout;
+}
+
+static void queue_set_pktout(queue_entry_t *queue, odp_pktio_t pktio, int index)
+{
+	queue->s.pktout.pktio = pktio;
+	queue->s.pktout.index = index;
+}
+
+static odp_pktin_queue_t queue_get_pktin(queue_entry_t *queue)
+{
+	return queue->s.pktin;
+}
+
+static void queue_set_pktin(queue_entry_t *queue, odp_pktio_t pktio, int index)
+{
+	queue->s.pktin.pktio = pktio;
+	queue->s.pktin.index = index;
+}
+
+static void queue_set_enq_func(queue_entry_t *queue, enq_func_t func)
+{
+	queue->s.enqueue = func;
+}
+
+static void queue_set_enq_multi_func(queue_entry_t *queue,
+				     enq_multi_func_t func)
+{
+	queue->s.enqueue_multi = func;
+}
+
+static void queue_set_deq_func(queue_entry_t *queue, deq_func_t func)
+{
+	queue->s.dequeue = func;
+}
+
+static void queue_set_deq_multi_func(queue_entry_t *queue,
+					    deq_multi_func_t func)
+{
+	queue->s.dequeue_multi = func;
+}
+
+static void queue_set_type(queue_entry_t *queue, odp_queue_type_t type)
+{
+	queue->s.type = type;
+}
+
 /* API functions */
 queue_api_t queue_default_api = {
 	.queue_create = queue_create,
@@ -799,5 +848,14 @@  queue_fn_t queue_default_fn = {
 	.queue_enq = _queue_enq,
 	.queue_enq_multi = _queue_enq_multi,
 	.queue_deq = _queue_deq,
-	.queue_deq_multi = _queue_deq_multi
+	.queue_deq_multi = _queue_deq_multi,
+	.queue_get_pktout = queue_get_pktout,
+	.queue_set_pktout = queue_set_pktout,
+	.queue_get_pktin = queue_get_pktin,
+	.queue_set_pktin = queue_set_pktin,
+	.queue_set_enq_func = queue_set_enq_func,
+	.queue_set_enq_multi_func = queue_set_enq_multi_func,
+	.queue_set_deq_func = queue_set_deq_func,
+	.queue_set_deq_multi_func = queue_set_deq_multi_func,
+	.queue_set_type = queue_set_type
 };
diff --git a/platform/linux-generic/odp_traffic_mngr.c b/platform/linux-generic/odp_traffic_mngr.c
index a93b3ba9..5008defe 100644
--- a/platform/linux-generic/odp_traffic_mngr.c
+++ b/platform/linux-generic/odp_traffic_mngr.c
@@ -3918,9 +3918,10 @@  odp_tm_queue_t odp_tm_queue_create(odp_tm_t odp_tm,
 	tm_queue_obj->pkt = ODP_PACKET_INVALID;
 	odp_ticketlock_init(&tm_wred_node->tm_wred_node_lock);
 
-	tm_queue_obj->tm_qentry.s.type = QUEUE_TYPE_TM;
-	tm_queue_obj->tm_qentry.s.enqueue = queue_tm_reenq;
-	tm_queue_obj->tm_qentry.s.enqueue_multi = queue_tm_reenq_multi;
+	queue_fn->queue_set_type(&tm_queue_obj->tm_qentry, QUEUE_TYPE_TM);
+	queue_fn->queue_set_enq_func(&tm_queue_obj->tm_qentry, queue_tm_reenq);
+	queue_fn->queue_set_enq_multi_func(&tm_queue_obj->tm_qentry,
+					   queue_tm_reenq_multi);
 
 	tm_system->queue_num_tbl[tm_queue_obj->queue_num - 1] = tm_queue_obj;
 	odp_ticketlock_lock(&tm_system->tm_system_lock);