compress/qat: add fallback to fixed compression
authorTomasz Jozwiak <tomaszx.jozwiak@intel.com>
Fri, 15 Feb 2019 09:44:32 +0000 (10:44 +0100)
committerAkhil Goyal <akhil.goyal@nxp.com>
Fri, 22 Mar 2019 13:27:46 +0000 (14:27 +0100)
This patch adds fallback to fixed compression
feature during dynamic compression, when the input data size
is greater than IM buffer size / 1.1. This feature doesn't
stop compression proccess when IM buffer can be too small
to handle produced data.

Signed-off-by: Tomasz Jozwiak <tomaszx.jozwiak@intel.com>
Acked-by: Fiona Trahe <fiona.trahe@intel.com>
doc/guides/cryptodevs/qat.rst
drivers/compress/qat/qat_comp.c
drivers/compress/qat/qat_comp.h

index b7eace1..beb6760 100644 (file)
@@ -188,11 +188,11 @@ allocated while for GEN1 devices, 12 buffers are allocated, plus 1472 bytes over
 
        If the compressed output of a Deflate operation using Dynamic Huffman
         Encoding is too big to fit in an intermediate buffer, then the
-        operation will return RTE_COMP_OP_STATUS_ERROR and an error will be
-        displayed. Options for the application in this case
-        are to split the input data into smaller chunks and resubmit
-        in multiple operations or to configure QAT with
-        larger intermediate buffers.
+       operation will fall back to fixed compression rather than failing the operation.
+       To avoid this less performant case, applications should configure
+       the intermediate buffer size to be larger than the expected input data size
+       (compressed output size is usually unknown, so the only option is to make
+       larger than the input size).
 
 
 Device and driver naming
index 32ca753..b9367d3 100644 (file)
@@ -43,6 +43,30 @@ qat_comp_build_request(void *in_op, uint8_t *out_msg,
        rte_mov128(out_msg, tmpl);
        comp_req->comn_mid.opaque_data = (uint64_t)(uintptr_t)op;
 
+       if (likely(qat_xform->qat_comp_request_type ==
+                   QAT_COMP_REQUEST_DYNAMIC_COMP_STATELESS)) {
+               if (unlikely(op->src.length > QAT_FALLBACK_THLD)) {
+
+                       /* fallback to fixed compression */
+                       comp_req->comn_hdr.service_cmd_id =
+                                       ICP_QAT_FW_COMP_CMD_STATIC;
+
+                       ICP_QAT_FW_COMN_NEXT_ID_SET(&comp_req->comp_cd_ctrl,
+                                       ICP_QAT_FW_SLICE_DRAM_WR);
+
+                       ICP_QAT_FW_COMN_NEXT_ID_SET(&comp_req->u2.xlt_cd_ctrl,
+                                       ICP_QAT_FW_SLICE_NULL);
+                       ICP_QAT_FW_COMN_CURR_ID_SET(&comp_req->u2.xlt_cd_ctrl,
+                                       ICP_QAT_FW_SLICE_NULL);
+
+                       QAT_DP_LOG(DEBUG, "QAT PMD: fallback to fixed "
+                                  "compression! IM buffer size can be too low "
+                                  "for produced data.\n Please use input "
+                                  "buffer length lower than %d bytes",
+                                  QAT_FALLBACK_THLD);
+               }
+       }
+
        /* common for sgl and flat buffers */
        comp_req->comp_pars.comp_len = op->src.length;
        comp_req->comp_pars.out_buffer_sz = rte_pktmbuf_pkt_len(op->m_dst) -
index 19f48df..12b37b1 100644 (file)
@@ -21,6 +21,9 @@
 
 #define ERR_CODE_QAT_COMP_WRONG_FW -99
 
+/* fallback to fixed compression threshold */
+#define QAT_FALLBACK_THLD ((uint32_t)(RTE_PMD_QAT_COMP_IM_BUFFER_SIZE / 1.1))
+
 enum qat_comp_request_type {
        QAT_COMP_REQUEST_FIXED_COMP_STATELESS,
        QAT_COMP_REQUEST_DYNAMIC_COMP_STATELESS,