diff mbox

[API-NEXT,PATCHv2,5/6] linux-generic: queue: streamline reorder_deq() routine

Message ID 1447015330-24420-6-git-send-email-bill.fischofer@linaro.org
State Superseded
Headers show

Commit Message

Bill Fischofer Nov. 8, 2015, 8:42 p.m. UTC
Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>
---
 .../linux-generic/include/odp_queue_internal.h     | 16 ++++++-------
 platform/linux-generic/odp_queue.c                 | 27 ++++++++++------------
 2 files changed, 19 insertions(+), 24 deletions(-)
diff mbox

Patch

diff --git a/platform/linux-generic/include/odp_queue_internal.h b/platform/linux-generic/include/odp_queue_internal.h
index 1bd365b..6120740 100644
--- a/platform/linux-generic/include/odp_queue_internal.h
+++ b/platform/linux-generic/include/odp_queue_internal.h
@@ -249,14 +249,13 @@  static inline void order_release(queue_entry_t *origin_qe, int count)
 
 static inline int reorder_deq(queue_entry_t *queue,
 			      queue_entry_t *origin_qe,
-			      odp_buffer_hdr_t **reorder_buf_return,
-			      odp_buffer_hdr_t **reorder_prev_return,
+			      odp_buffer_hdr_t **reorder_tail_return,
 			      odp_buffer_hdr_t **placeholder_buf_return,
 			      int *release_count_return,
 			      int *placeholder_count_return)
 {
 	odp_buffer_hdr_t *reorder_buf     = origin_qe->s.reorder_head;
-	odp_buffer_hdr_t *reorder_prev    = NULL;
+	odp_buffer_hdr_t *reorder_tail    = NULL;
 	odp_buffer_hdr_t *placeholder_buf = NULL;
 	odp_buffer_hdr_t *next_buf;
 	int               deq_count = 0;
@@ -300,9 +299,9 @@  static inline int reorder_deq(queue_entry_t *queue,
 				while (reorder_link->next)
 					reorder_link = reorder_link->next;
 				reorder_link->next = next_buf;
-				reorder_prev = reorder_link;
+				reorder_tail = reorder_link;
 			} else {
-				reorder_prev = reorder_buf;
+				reorder_tail = reorder_buf;
 			}
 
 			deq_count++;
@@ -310,8 +309,8 @@  static inline int reorder_deq(queue_entry_t *queue,
 				release_count++;
 			reorder_buf = next_buf;
 		} else if (!reorder_buf->target_qe) {
-			if (reorder_prev)
-				reorder_prev->next = next_buf;
+			if (reorder_tail)
+				reorder_tail->next = next_buf;
 			else
 				origin_qe->s.reorder_head = next_buf;
 
@@ -325,8 +324,7 @@  static inline int reorder_deq(queue_entry_t *queue,
 		}
 	}
 
-	*reorder_buf_return = reorder_buf;
-	*reorder_prev_return = reorder_prev;
+	*reorder_tail_return = reorder_tail;
 	*placeholder_buf_return = placeholder_buf;
 	*release_count_return = release_count;
 	*placeholder_count_return = placeholder_count;
diff --git a/platform/linux-generic/odp_queue.c b/platform/linux-generic/odp_queue.c
index d9be4b3..9cab9b2 100644
--- a/platform/linux-generic/odp_queue.c
+++ b/platform/linux-generic/odp_queue.c
@@ -428,7 +428,7 @@  int ordered_queue_enq(queue_entry_t *queue,
 {
 	odp_buffer_hdr_t *reorder_buf;
 	odp_buffer_hdr_t *next_buf;
-	odp_buffer_hdr_t *reorder_prev;
+	odp_buffer_hdr_t *reorder_tail;
 	odp_buffer_hdr_t *placeholder_buf = NULL;
 	int               release_count, placeholder_count;
 	int               sched = 0;
@@ -496,17 +496,17 @@  int ordered_queue_enq(queue_entry_t *queue,
 	/* Pick up this element, and all others resolved by this enq,
 	 * and add them to the target queue.
 	 */
-	reorder_deq(queue, origin_qe, &reorder_buf, &reorder_prev,
-		    &placeholder_buf, &release_count, &placeholder_count);
+	reorder_deq(queue, origin_qe, &reorder_tail, &placeholder_buf,
+		    &release_count, &placeholder_count);
 
 	/* Move the list from the reorder queue to the target queue */
 	if (queue->s.head)
 		queue->s.tail->next = origin_qe->s.reorder_head;
 	else
 		queue->s.head       = origin_qe->s.reorder_head;
-	queue->s.tail               = reorder_prev;
-	origin_qe->s.reorder_head   = reorder_prev->next;
-	reorder_prev->next          = NULL;
+	queue->s.tail               = reorder_tail;
+	origin_qe->s.reorder_head   = reorder_tail->next;
+	reorder_tail->next          = NULL;
 
 	/* Reflect resolved orders in the output sequence */
 	order_release(origin_qe, release_count + placeholder_count);
@@ -847,20 +847,17 @@  int queue_pktout_enq(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr,
 	 */
 	odp_buffer_hdr_t *reorder_buf;
 	odp_buffer_hdr_t *next_buf;
-	odp_buffer_hdr_t *reorder_prev;
+	odp_buffer_hdr_t *reorder_tail;
 	odp_buffer_hdr_t *xmit_buf;
 	odp_buffer_hdr_t *placeholder_buf;
-	int               deq_count, release_count, placeholder_count;
-
-	deq_count = reorder_deq(queue, origin_qe,
-				&reorder_buf, &reorder_prev, &placeholder_buf,
-				&release_count, &placeholder_count);
+	int               release_count, placeholder_count;
 
 	/* Send released buffers as well */
-	if (deq_count > 0) {
+	if (reorder_deq(queue, origin_qe, &reorder_tail, &placeholder_buf,
+			&release_count, &placeholder_count)) {
 		xmit_buf = origin_qe->s.reorder_head;
-		origin_qe->s.reorder_head = reorder_prev->next;
-		reorder_prev->next = NULL;
+		origin_qe->s.reorder_head = reorder_tail->next;
+		reorder_tail->next = NULL;
 		UNLOCK(&origin_qe->s.lock);
 
 		do {