From: Bruce Richardson Date: Wed, 30 Sep 2015 12:12:21 +0000 (+0100) Subject: ring: create device from a ring X-Git-Tag: spdx-start~8178 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=f3a0daf3473f1aec9ae60a8744404a0fcb1593be;p=dpdk.git ring: create device from a ring 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 Acked-by: Pablo de Lara --- diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c index bfd6f4e943..d851f9e28d 100644 --- a/drivers/net/ring/rte_eth_ring.c +++ b/drivers/net/ring/rte_eth_ring.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -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 5a69bffd3d..4ff83eca61 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 0875e25cfa..1f785d9409 100644 --- a/drivers/net/ring/rte_eth_ring_version.map +++ b/drivers/net/ring/rte_eth_ring_version.map @@ -5,3 +5,10 @@ DPDK_2.0 { local: *; }; + +DPDK_2.2 { + global: + + rte_eth_from_ring; + +} DPDK_2.0;