diff mbox

[API-NEXT,2/3] linux-generic: pktio: implement pktio support for user contexts

Message ID 1460064119-21282-2-git-send-email-bill.fischofer@linaro.org
State New
Headers show

Commit Message

Bill Fischofer April 7, 2016, 9:21 p.m. UTC
Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>
---
 .../linux-generic/include/odp_packet_io_internal.h |  1 +
 platform/linux-generic/odp_packet_io.c             | 22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+)
diff mbox

Patch

diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h
index 8e1d04f..1521724 100644
--- a/platform/linux-generic/include/odp_packet_io_internal.h
+++ b/platform/linux-generic/include/odp_packet_io_internal.h
@@ -141,6 +141,7 @@  struct pktio_entry {
 
 	odp_pool_t pool;
 	odp_pktio_param_t param;
+	void *context;                 /**< user context pointer */
 
 	/* Storage for queue handles
 	 * Multi-queue support is pktio driver specific */
diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c
index 1dff7a3..0d591c0 100644
--- a/platform/linux-generic/odp_packet_io.c
+++ b/platform/linux-generic/odp_packet_io.c
@@ -920,6 +920,28 @@  int odp_pktio_info(odp_pktio_t id, odp_pktio_info_t *info)
 	return 0;
 }
 
+void *odp_pktio_context(odp_pktio_t pktio)
+{
+	pktio_entry_t *entry = get_pktio_entry(pktio);
+
+	if (entry)
+		return entry->s.context;
+
+	return NULL;
+}
+
+int odp_pktio_context_set(odp_pktio_t pktio, void *context)
+{
+	pktio_entry_t *entry = get_pktio_entry(pktio);
+
+	if (entry) {
+		entry->s.context = context;
+		return 0;
+	}
+
+	return -1;
+}
+
 void odp_pktio_print(odp_pktio_t id)
 {
 	pktio_entry_t *entry;