diff mbox

[API-NEXT,2/3] linux-generic: queue: add odp_queue_info() function

Message ID 1447055757-8654-3-git-send-email-carl.wallen@nokia.com
State Accepted
Commit 3a1f9e9128af51cdaf64ace21287ab8608dd2cbc
Headers show

Commit Message

Wallen, Carl (Nokia - FI/Espoo) Nov. 9, 2015, 7:55 a.m. UTC
Retrieve queue name and params.

Signed-off-by: Carl Wallen <carl.wallen@nokia.com>
---
 platform/linux-generic/odp_queue.c | 40 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

--
2.1.4
diff mbox

Patch

diff --git a/platform/linux-generic/odp_queue.c b/platform/linux-generic/odp_queue.c
index 1c15e17..90e8972 100644
--- a/platform/linux-generic/odp_queue.c
+++ b/platform/linux-generic/odp_queue.c
@@ -1045,3 +1045,43 @@  void odp_schedule_order_unlock(unsigned lock_index)
	/* Release the ordered lock */
	odp_atomic_fetch_inc_u64(&origin_qe->s.sync_out[lock_index]);
 }
+
+int odp_queue_info(odp_queue_t handle, odp_queue_info_t *info)
+{
+	uint32_t queue_id;
+	queue_entry_t *queue;
+	int status;
+
+	if (odp_unlikely(info == NULL)) {
+		ODP_ERR("Unable to store info, NULL ptr given\n");
+		return -1;
+	}
+
+	queue_id = queue_to_id(handle);
+
+	if (odp_unlikely(queue_id >= ODP_CONFIG_QUEUES)) {
+		ODP_ERR("Invalid queue handle:%" PRIu64 "\n",
+			odp_queue_to_u64(handle));
+		return -1;
+	}
+
+	queue = get_qentry(queue_id);
+
+	LOCK(&queue->s.lock);
+	status = queue->s.status;
+
+	if (odp_unlikely(status == QUEUE_STATUS_FREE ||
+			 status == QUEUE_STATUS_DESTROYED)) {
+		UNLOCK(&queue->s.lock);
+		ODP_ERR("Invalid queue status:%d\n", status);
+		return -1;
+	}
+
+	info->name = queue->s.name;
+	info->type = queue->s.type;
+	info->param = queue->s.param;
+
+	UNLOCK(&queue->s.lock);
+
+	return 0;
+}