Added Huffman fixed and dynamic encoding feature flags,
so an application can query if a device supports
these two types, when performing DEFLATE compression.

Signed-off-by: Pablo de Lara <pablo.de.lara.gua...@intel.com>
Acked-by: Fiona Trahe <fiona.tr...@intel.com>
---

Changes in v3:

- No change

Changes in v2:

- Fixed typo

 drivers/compress/isal/isal_compress_pmd_ops.c |  4 +++-
 lib/librte_compressdev/rte_comp.c             |  4 ++++
 lib/librte_compressdev/rte_comp.h             |  4 ++++
 test/test/test_compressdev.c                  | 16 ++++++++++++++++
 4 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/drivers/compress/isal/isal_compress_pmd_ops.c 
b/drivers/compress/isal/isal_compress_pmd_ops.c
index 970a0413b..585f22802 100644
--- a/drivers/compress/isal/isal_compress_pmd_ops.c
+++ b/drivers/compress/isal/isal_compress_pmd_ops.c
@@ -12,7 +12,9 @@
 static const struct rte_compressdev_capabilities isal_pmd_capabilities[] = {
        {
                .algo = RTE_COMP_ALGO_DEFLATE,
-               .comp_feature_flags =   RTE_COMP_FF_SHAREABLE_PRIV_XFORM,
+               .comp_feature_flags =   RTE_COMP_FF_SHAREABLE_PRIV_XFORM |
+                                       RTE_COMP_FF_HUFFMAN_FIXED |
+                                       RTE_COMP_FF_HUFFMAN_DYNAMIC,
                .window_size = {
                        .min = 15,
                        .max = 15,
diff --git a/lib/librte_compressdev/rte_comp.c 
b/lib/librte_compressdev/rte_comp.c
index f5bd3a6c0..5ed1d0daa 100644
--- a/lib/librte_compressdev/rte_comp.c
+++ b/lib/librte_compressdev/rte_comp.c
@@ -36,6 +36,10 @@ rte_comp_get_feature_name(uint64_t flag)
                return "SHA2_SHA256_HASH";
        case RTE_COMP_FF_SHAREABLE_PRIV_XFORM:
                return "SHAREABLE_PRIV_XFORM";
+       case RTE_COMP_FF_HUFFMAN_FIXED:
+               return "HUFFMAN_FIXED";
+       case RTE_COMP_FF_HUFFMAN_DYNAMIC:
+               return "HUFFMAN_DYNAMIC";
        default:
                return NULL;
        }
diff --git a/lib/librte_compressdev/rte_comp.h 
b/lib/librte_compressdev/rte_comp.h
index 6660cee82..c9245cce1 100644
--- a/lib/librte_compressdev/rte_comp.h
+++ b/lib/librte_compressdev/rte_comp.h
@@ -62,6 +62,10 @@ extern "C" {
  * to create as many priv_xforms as it expects to have stateless
  * operations in-flight.
  */
+#define RTE_COMP_FF_HUFFMAN_FIXED              (1ULL << 13)
+/**< Fixed huffman encoding is supported */
+#define RTE_COMP_FF_HUFFMAN_DYNAMIC            (1ULL << 14)
+/**< Dynamic huffman encoding is supported */
 
 /** Status of comp operation */
 enum rte_comp_op_status {
diff --git a/test/test/test_compressdev.c b/test/test/test_compressdev.c
index 640942bac..f960963a4 100644
--- a/test/test/test_compressdev.c
+++ b/test/test/test_compressdev.c
@@ -846,6 +846,14 @@ test_compressdev_deflate_stateless_fixed(void)
        const char *test_buffer;
        uint16_t i;
        int ret;
+       const struct rte_compressdev_capabilities *capab;
+
+       capab = rte_compressdev_capability_get(0, RTE_COMP_ALGO_DEFLATE);
+       TEST_ASSERT(capab != NULL, "Failed to retrieve device capabilities");
+
+       if ((capab->comp_feature_flags & RTE_COMP_FF_HUFFMAN_FIXED) == 0)
+               return -ENOTSUP;
+
        struct rte_comp_xform *compress_xform =
                        rte_malloc(NULL, sizeof(struct rte_comp_xform), 0);
 
@@ -905,6 +913,14 @@ test_compressdev_deflate_stateless_dynamic(void)
        struct rte_comp_xform *compress_xform =
                        rte_malloc(NULL, sizeof(struct rte_comp_xform), 0);
 
+       const struct rte_compressdev_capabilities *capab;
+
+       capab = rte_compressdev_capability_get(0, RTE_COMP_ALGO_DEFLATE);
+       TEST_ASSERT(capab != NULL, "Failed to retrieve device capabilities");
+
+       if ((capab->comp_feature_flags & RTE_COMP_FF_HUFFMAN_DYNAMIC) == 0)
+               return -ENOTSUP;
+
        if (compress_xform == NULL) {
                RTE_LOG(ERR, USER1,
                        "Compress xform could not be created\n");
-- 
2.14.4

Reply via email to