[dpdk-dev] [PATCH 3/4] ring: add rte_eth_from_ring function

Bruce Richardson bruce.richardson at intel.com
Wed Sep 30 14:12:21 CEST 2015


Add a one-parameter function to take an existing rte_ring and wrap it as
an ethdev, returning the port id of the new ethdev instance.

Signed-off-by: Bruce Richardson <bruce.richardson at intel.com>
---
 drivers/net/ring/rte_eth_ring.c           |  8 ++++++++
 drivers/net/ring/rte_eth_ring.h           | 14 ++++++++++++++
 drivers/net/ring/rte_eth_ring_version.map |  5 +++++
 3 files changed, 27 insertions(+)

diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
index bfd6f4e..d851f9e 100644
--- a/drivers/net/ring/rte_eth_ring.c
+++ b/drivers/net/ring/rte_eth_ring.c
@@ -36,6 +36,7 @@
 #include <rte_ethdev.h>
 #include <rte_malloc.h>
 #include <rte_memcpy.h>
+#include <rte_memzone.h>
 #include <rte_string_fns.h>
 #include <rte_dev.h>
 #include <rte_kvargs.h>
@@ -392,6 +393,13 @@ error:
 	return -1;
 }
 
+int
+rte_eth_from_ring(struct rte_ring *r)
+{
+	return rte_eth_from_rings(r->name, &r, 1, &r, 1,
+			r->memzone ? r->memzone->socket_id : SOCKET_ID_ANY);
+}
+
 enum dev_action{
 	DEV_CREATE,
 	DEV_ATTACH
diff --git a/drivers/net/ring/rte_eth_ring.h b/drivers/net/ring/rte_eth_ring.h
index 5a69bff..4ff83ec 100644
--- a/drivers/net/ring/rte_eth_ring.h
+++ b/drivers/net/ring/rte_eth_ring.h
@@ -65,6 +65,20 @@ int rte_eth_from_rings(const char *name,
 		const unsigned nb_tx_queues,
 		const unsigned numa_node);
 
+/**
+ * Create a new ethdev port from a ring
+ *
+ * This function is a shortcut call for rte_eth_from_rings for the
+ * case where one wants to take a single rte_ring and use it as though
+ * it were an ethdev
+ *
+ * @param ring
+ *    the ring to be used as an ethdev
+ * @return
+ *    the port number of the newly created ethdev, or -1 on error
+ */
+int rte_eth_from_ring(struct rte_ring *r);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/drivers/net/ring/rte_eth_ring_version.map b/drivers/net/ring/rte_eth_ring_version.map
index 0875e25..8e113a4 100644
--- a/drivers/net/ring/rte_eth_ring_version.map
+++ b/drivers/net/ring/rte_eth_ring_version.map
@@ -5,3 +5,8 @@ DPDK_2.0 {
 
 	local: *;
 };
+
+DPDK_2.2 {
+	global:
+	rte_eth_from_ring;
+} DPDK_2.0;
-- 
2.4.3



More information about the dev mailing list