From mboxrd@z Thu Jan 1 00:00:00 1970 From: Pablo de Lara Subject: [PATCH v6 13/14] compressdev: get device id from name Date: Fri, 27 Apr 2018 14:24:06 +0100 Message-ID: <20180427132407.13385-14-pablo.de.lara.guarch@intel.com> References: <1517595924-25963-1-git-send-email-fiona.trahe@intel.com> <20180427132407.13385-1-pablo.de.lara.guarch@intel.com> Cc: fiona.trahe@intel.com, shally.verma@cavium.com, ahmed.mansour@nxp.com, Ashish.Gupta@cavium.com, Pablo de Lara , Shally Verma , Ashish Gupta To: dev@dpdk.org Return-path: Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id BB5177CAA for ; Fri, 27 Apr 2018 15:24:20 +0200 (CEST) In-Reply-To: <20180427132407.13385-1-pablo.de.lara.guarch@intel.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Fiona Trahe Added API to retrieve the device id provided the device name. Signed-off-by: Fiona Trahe Signed-off-by: Pablo de Lara Signed-off-by: Shally Verma Signed-off-by: Ashish Gupta --- lib/librte_compressdev/rte_compressdev.c | 18 ++++++++++++++++++ lib/librte_compressdev/rte_compressdev.h | 13 +++++++++++++ lib/librte_compressdev/rte_compressdev_version.map | 1 + 3 files changed, 32 insertions(+) diff --git a/lib/librte_compressdev/rte_compressdev.c b/lib/librte_compressdev/rte_compressdev.c index 2d7127ce2..6a38917dd 100644 --- a/lib/librte_compressdev/rte_compressdev.c +++ b/lib/librte_compressdev/rte_compressdev.c @@ -117,6 +117,24 @@ rte_compressdev_is_valid_dev(uint8_t dev_id) } +int __rte_experimental +rte_compressdev_get_dev_id(const char *name) +{ + unsigned int i; + + if (name == NULL) + return -1; + + for (i = 0; i < rte_compressdev_globals->nb_devs; i++) + if ((strcmp(rte_compressdev_globals->devs[i].data->name, name) + == 0) && + (rte_compressdev_globals->devs[i].attached == + RTE_COMPRESSDEV_ATTACHED)) + return i; + + return -1; +} + uint8_t __rte_experimental rte_compressdev_count(void) { diff --git a/lib/librte_compressdev/rte_compressdev.h b/lib/librte_compressdev/rte_compressdev.h index d52103e15..c86035f14 100644 --- a/lib/librte_compressdev/rte_compressdev.h +++ b/lib/librte_compressdev/rte_compressdev.h @@ -111,6 +111,19 @@ struct rte_compressdev_stats { /**< Total error count on operations dequeued */ }; + +/** + * Get the device identifier for the named compress device. + * + * @param name + * Device name to select the device structure + * @return + * - Returns compress device identifier on success. + * - Return -1 on failure to find named compress device. + */ +int __rte_experimental +rte_compressdev_get_dev_id(const char *name); + /** * Get the compress device name given a device identifier. * diff --git a/lib/librte_compressdev/rte_compressdev_version.map b/lib/librte_compressdev/rte_compressdev_version.map index 6c553341a..e5cbc569e 100644 --- a/lib/librte_compressdev/rte_compressdev_version.map +++ b/lib/librte_compressdev/rte_compressdev_version.map @@ -10,6 +10,7 @@ EXPERIMENTAL { rte_compressdev_dequeue_burst; rte_compressdev_devices_get; rte_compressdev_enqueue_burst; + rte_compressdev_get_dev_id; rte_compressdev_get_feature_name; rte_compressdev_info_get; rte_compressdev_name_get; -- 2.14.3