compressdev: add device capabilities
authorFiona Trahe <fiona.trahe@intel.com>
Fri, 27 Apr 2018 13:24:05 +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 structure which each PMD will fill out,
providing the capabilities of each driver
(containing mainly which compression services
it supports).

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 855385e..2d7127c 100644 (file)
@@ -31,6 +31,29 @@ static struct rte_compressdev_global compressdev_globals = {
 
 struct rte_compressdev_global *rte_compressdev_globals = &compressdev_globals;
 
+const struct rte_compressdev_capabilities * __rte_experimental
+rte_compressdev_capability_get(uint8_t dev_id,
+                       enum rte_comp_algorithm algo)
+{
+       const struct rte_compressdev_capabilities *capability;
+       struct rte_compressdev_info dev_info;
+       int i = 0;
+
+       if (dev_id >= compressdev_globals.nb_devs) {
+               COMPRESSDEV_LOG(ERR, "Invalid dev_id=%d", dev_id);
+               return NULL;
+       }
+       rte_compressdev_info_get(dev_id, &dev_info);
+
+       while ((capability = &dev_info.capabilities[i++])->algo !=
+                       RTE_COMP_ALGO_UNSPECIFIED){
+               if (capability->algo == algo)
+                       return capability;
+       }
+
+       return NULL;
+}
+
 const char * __rte_experimental
 rte_compressdev_get_feature_name(uint64_t flag)
 {
index 5ad9269..d52103e 100644 (file)
@@ -21,6 +21,39 @@ extern "C" {
 
 #include "rte_comp.h"
 
+/**
+ * Parameter log base 2 range description.
+ * Final value will be 2^value.
+ */
+struct rte_param_log2_range {
+       uint8_t min;    /**< Minimum log2 value */
+       uint8_t max;    /**< Maximum log2 value */
+       uint8_t increment;
+       /**< If a range of sizes are supported,
+        * this parameter is used to indicate
+        * increments in base 2 log byte value
+        * that are supported between the minimum and maximum
+        */
+};
+
+/** Structure used to capture a capability of a comp device */
+struct rte_compressdev_capabilities {
+       enum rte_comp_algorithm algo;
+       /* Compression algorithm */
+       uint64_t comp_feature_flags;
+       /**< Bitmask of flags for compression service features */
+       struct rte_param_log2_range window_size;
+       /**< Window size range in base two log byte values */
+};
+
+/** Macro used at end of comp PMD list */
+#define RTE_COMP_END_OF_CAPABILITIES_LIST() \
+       { RTE_COMP_ALGO_UNSPECIFIED }
+
+const struct rte_compressdev_capabilities * __rte_experimental
+rte_compressdev_capability_get(uint8_t dev_id,
+                       enum rte_comp_algorithm algo);
+
 /**
  * compression device supported feature flags
  *
@@ -57,6 +90,8 @@ rte_compressdev_get_feature_name(uint64_t flag);
 struct rte_compressdev_info {
        const char *driver_name;                /**< Driver name. */
        uint64_t feature_flags;                 /**< Feature flags */
+       const struct rte_compressdev_capabilities *capabilities;
+       /**< Array of devices supported capabilities */
        uint16_t max_nb_queue_pairs;
        /**< Maximum number of queues pairs supported by device.
         * (If 0, there is no limit in maximum number of queue pairs)
index 8e40046..6c55334 100644 (file)
@@ -3,6 +3,7 @@ EXPERIMENTAL {
 
        rte_compressdev_callback_register;
        rte_compressdev_callback_unregister;
+       rte_compressdev_capability_get;
        rte_compressdev_close;
        rte_compressdev_configure;
        rte_compressdev_count;