From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id E1FBF8DAA for ; Wed, 30 Sep 2015 14:12:26 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP; 30 Sep 2015 05:12:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,612,1437462000"; d="scan'208";a="816267649" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga002.jf.intel.com with ESMTP; 30 Sep 2015 05:12:24 -0700 Received: from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com [10.237.217.45]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id t8UCCMgJ015011; Wed, 30 Sep 2015 13:12:22 +0100 Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id t8UCCMWp024437; Wed, 30 Sep 2015 13:12:22 +0100 Received: (from bricha3@localhost) by sivswdev01.ir.intel.com with id t8UCCMfW024433; Wed, 30 Sep 2015 13:12:22 +0100 From: Bruce Richardson To: dev@dpdk.org Date: Wed, 30 Sep 2015 13:12:21 +0100 Message-Id: <1443615142-24381-4-git-send-email-bruce.richardson@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1443615142-24381-1-git-send-email-bruce.richardson@intel.com> References: <1443615142-24381-1-git-send-email-bruce.richardson@intel.com> Subject: [dpdk-dev] [PATCH 3/4] ring: add rte_eth_from_ring function X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Sep 2015 12:12:28 -0000 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 --- 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 #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 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