compressdev: get device id from name
authorFiona Trahe <fiona.trahe@intel.com>
Fri, 27 Apr 2018 13:24:06 +0000 (14:24 +0100)
committerPablo de Lara <pablo.de.lara.guarch@intel.com>
Thu, 10 May 2018 16:46:20 +0000 (17:46 +0100)
Added API to retrieve the device id provided the device name.

Signed-off-by: Fiona Trahe <fiona.trahe@intel.com>
Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Signed-off-by: Shally Verma <shally.verma@caviumnetworks.com>
Signed-off-by: Ashish Gupta <ashish.gupta@caviumnetworks.com>
lib/librte_compressdev/rte_compressdev.c
lib/librte_compressdev/rte_compressdev.h
lib/librte_compressdev/rte_compressdev_version.map

index 2d7127c..6a38917 100644 (file)
@@ -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)
 {
index d52103e..c86035f 100644 (file)
@@ -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.
  *
index 6c55334..e5cbc56 100644 (file)
@@ -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;