diff mbox

[API-NEXT,PATCHv11,12/13] linux-generic: schedule: implement order insertion routines

Message ID 1439085315-6957-13-git-send-email-bill.fischofer@linaro.org
State New
Headers show

Commit Message

Bill Fischofer Aug. 9, 2015, 1:55 a.m. UTC
Implement the odp_schedule_order_copy(), odp_schedule_sustain(),
and odp_schedule_sustain_set(), which together permit events to
be inserted into an ordered flow.

Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>
---
 platform/linux-generic/odp_queue.c    | 27 +++++++++++++++++++++++++++
 platform/linux-generic/odp_schedule.c | 24 ++++++++++++++++++++++++
 2 files changed, 51 insertions(+)
diff mbox

Patch

diff --git a/platform/linux-generic/odp_queue.c b/platform/linux-generic/odp_queue.c
index 669b630..c8ae733 100644
--- a/platform/linux-generic/odp_queue.c
+++ b/platform/linux-generic/odp_queue.c
@@ -993,3 +993,30 @@  int odp_schedule_release_ordered(odp_event_t ev)
 	UNLOCK(&origin_qe->s.lock);
 	return 0;
 }
+
+int odp_schedule_order_copy(odp_event_t src_event, odp_event_t dst_event)
+{
+	odp_buffer_hdr_t *src =
+		odp_buf_to_hdr(odp_buffer_from_event(src_event));
+	odp_buffer_hdr_t *dst =
+		odp_buf_to_hdr(odp_buffer_from_event(dst_event));
+	queue_entry_t *origin_qe = src->origin_qe;
+
+	if (!origin_qe || dst->origin_qe)
+		return -1;
+
+	LOCK(&origin_qe->s.lock);
+
+	if (src->origin_qe != origin_qe) {
+		UNLOCK(&origin_qe->s.lock);
+		return -1;
+	}
+
+	dst->origin_qe = origin_qe;
+	dst->order     = src->order;
+	dst->sync      = src->sync;
+	src->flags.sustain = 1;
+
+	UNLOCK(&origin_qe->s.lock);
+	return 0;
+}
diff --git a/platform/linux-generic/odp_schedule.c b/platform/linux-generic/odp_schedule.c
index 4d594a0..548ed25 100644
--- a/platform/linux-generic/odp_schedule.c
+++ b/platform/linux-generic/odp_schedule.c
@@ -746,3 +746,27 @@  int odp_schedule_group_count(odp_schedule_group_t group)
 void odp_schedule_prefetch(int num ODP_UNUSED)
 {
 }
+
+int odp_schedule_order_sustain(odp_event_t ev)
+{
+	odp_buffer_hdr_t *buf_hdr =
+		odp_buf_to_hdr(odp_buffer_from_event(ev));
+
+	if (buf_hdr->origin_qe)
+		return buf_hdr->flags.sustain;
+
+	return -1;
+}
+
+int odp_schedule_order_sustain_set(odp_event_t ev, odp_bool_t sustain)
+{
+	odp_buffer_hdr_t *buf_hdr =
+		odp_buf_to_hdr(odp_buffer_from_event(ev));
+
+	if (buf_hdr->origin_qe && (sustain & 1) == sustain) {
+		buf_hdr->flags.sustain = sustain;
+		return 0;
+	}
+
+	return -1;
+}