get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/59613/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 59613,
    "url": "https://patches.dpdk.org/api/patches/59613/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20190920200628.6444-3-adamx.dybkowski@intel.com/",
    "project": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<20190920200628.6444-3-adamx.dybkowski@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20190920200628.6444-3-adamx.dybkowski@intel.com",
    "date": "2019-09-20T20:06:27",
    "name": "[v3,2/3] compress/qat: add stateful decompression",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "52cb37b6b88122b6e470cbbb975857cc7f48b903",
    "submitter": {
        "id": 1322,
        "url": "https://patches.dpdk.org/api/people/1322/?format=api",
        "name": "Dybkowski, AdamX",
        "email": "adamx.dybkowski@intel.com"
    },
    "delegate": {
        "id": 6690,
        "url": "https://patches.dpdk.org/api/users/6690/?format=api",
        "username": "akhil",
        "first_name": "akhil",
        "last_name": "goyal",
        "email": "gakhil@marvell.com"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/20190920200628.6444-3-adamx.dybkowski@intel.com/mbox/",
    "series": [
        {
            "id": 6488,
            "url": "https://patches.dpdk.org/api/series/6488/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=6488",
            "date": "2019-09-20T20:06:25",
            "name": "compress/qat: add stateful decompression",
            "version": 3,
            "mbox": "https://patches.dpdk.org/series/6488/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/59613/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/59613/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@dpdk.org",
        "Delivered-To": "patchwork@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 23A391BEF7;\n\tMon, 23 Sep 2019 15:25:43 +0200 (CEST)",
            "from mga11.intel.com (mga11.intel.com [192.55.52.93])\n\tby dpdk.org (Postfix) with ESMTP id A40601BEEF\n\tfor <dev@dpdk.org>; Mon, 23 Sep 2019 15:25:30 +0200 (CEST)",
            "from fmsmga001.fm.intel.com ([10.253.24.23])\n\tby fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t23 Sep 2019 06:25:30 -0700",
            "from adamdybx-mobl.ger.corp.intel.com (HELO\n\taddy-VirtualBox.isw.intel.com) ([10.103.104.111])\n\tby fmsmga001.fm.intel.com with ESMTP; 23 Sep 2019 06:25:28 -0700"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.64,540,1559545200\"; d=\"scan'208\";a=\"203127086\"",
        "From": "Adam Dybkowski <adamx.dybkowski@intel.com>",
        "To": "dev@dpdk.org, fiona.trahe@intel.com, arturx.trybula@intel.com,\n\takhil.goyal@nxp.com",
        "Cc": "Adam Dybkowski <adamx.dybkowski@intel.com>",
        "Date": "Fri, 20 Sep 2019 22:06:27 +0200",
        "Message-Id": "<20190920200628.6444-3-adamx.dybkowski@intel.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "In-Reply-To": "<20190920200628.6444-1-adamx.dybkowski@intel.com>",
        "References": "<20190920124452.29449-2-adamx.dybkowski@intel.com>\n\t<20190920200628.6444-1-adamx.dybkowski@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v3 2/3] compress/qat: add stateful decompression",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "This patch adds the stateful decompression feature\nto the DPDK QAT PMD.\n\nSigned-off-by: Adam Dybkowski <adamx.dybkowski@intel.com>\n---\n doc/guides/compressdevs/features/default.ini |  37 +--\n doc/guides/compressdevs/features/qat.ini     |  21 +-\n doc/guides/compressdevs/qat_comp.rst         |   5 +\n doc/guides/rel_notes/release_19_11.rst       |   4 +\n drivers/compress/qat/qat_comp.c              | 256 +++++++++++++++++--\n drivers/compress/qat/qat_comp.h              |  32 +++\n drivers/compress/qat/qat_comp_pmd.c          | 166 +++++++++++-\n drivers/compress/qat/qat_comp_pmd.h          |   2 +\n 8 files changed, 462 insertions(+), 61 deletions(-)",
    "diff": "diff --git a/doc/guides/compressdevs/features/default.ini b/doc/guides/compressdevs/features/default.ini\nindex 829e4df61..e1419ee8d 100644\n--- a/doc/guides/compressdevs/features/default.ini\n+++ b/doc/guides/compressdevs/features/default.ini\n@@ -6,21 +6,22 @@\n ; the features table in the documentation.\n ;\n [Features]\n-HW Accelerated      =\n-CPU SSE             =\n-CPU AVX             =\n-CPU AVX2            =\n-CPU AVX512          =\n-CPU NEON            =\n-Stateful            =\n-Pass-through        =\n-OOP SGL In SGL Out  =\n-OOP SGL In LB  Out  =\n-OOP LB  In SGL Out  =\n-Deflate             =\n-LZS                 =\n-Adler32             =\n-Crc32               =\n-Adler32&Crc32       =\n-Fixed               =\n-Dynamic             =\n+HW Accelerated         =\n+CPU SSE                =\n+CPU AVX                =\n+CPU AVX2               =\n+CPU AVX512             =\n+CPU NEON               =\n+Stateful Compression   =\n+Stateful Decompression =\n+Pass-through           =\n+OOP SGL In SGL Out     =\n+OOP SGL In LB  Out     =\n+OOP LB  In SGL Out     =\n+Deflate                =\n+LZS                    =\n+Adler32                =\n+Crc32                  =\n+Adler32&Crc32          =\n+Fixed                  =\n+Dynamic                =\ndiff --git a/doc/guides/compressdevs/features/qat.ini b/doc/guides/compressdevs/features/qat.ini\nindex 6b1e7f935..bced8f9cf 100644\n--- a/doc/guides/compressdevs/features/qat.ini\n+++ b/doc/guides/compressdevs/features/qat.ini\n@@ -4,13 +4,14 @@\n ; Supported features of 'QAT' compression driver.\n ;\n [Features]\n-HW Accelerated      = Y\n-OOP SGL In SGL Out  = Y\n-OOP SGL In LB  Out  = Y\n-OOP LB  In SGL Out  = Y\n-Deflate             = Y\n-Adler32             = Y\n-Crc32               = Y\n-Adler32&Crc32       = Y\n-Fixed               = Y\n-Dynamic             = Y\n+HW Accelerated         = Y\n+Stateful Decompression = Y\n+OOP SGL In SGL Out     = Y\n+OOP SGL In LB  Out     = Y\n+OOP LB  In SGL Out     = Y\n+Deflate                = Y\n+Adler32                = Y\n+Crc32                  = Y\n+Adler32&Crc32          = Y\n+Fixed                  = Y\n+Dynamic                = Y\ndiff --git a/doc/guides/compressdevs/qat_comp.rst b/doc/guides/compressdevs/qat_comp.rst\nindex 6f583a460..6421f767c 100644\n--- a/doc/guides/compressdevs/qat_comp.rst\n+++ b/doc/guides/compressdevs/qat_comp.rst\n@@ -29,6 +29,10 @@ Checksum generation:\n \n     * CRC32, Adler and combined checksum\n \n+Stateful operation:\n+\n+    * Decompression only\n+\n Limitations\n -----------\n \n@@ -38,6 +42,7 @@ Limitations\n * When using Deflate dynamic huffman encoding for compression, the input size (op.src.length)\n   must be < CONFIG_RTE_PMD_QAT_COMP_IM_BUFFER_SIZE from the config file,\n   see :ref:`building_qat_config` for more details.\n+* Stateful compression is not supported.\n \n \n Installation\ndiff --git a/doc/guides/rel_notes/release_19_11.rst b/doc/guides/rel_notes/release_19_11.rst\nindex 27cfbd9e3..573683da4 100644\n--- a/doc/guides/rel_notes/release_19_11.rst\n+++ b/doc/guides/rel_notes/release_19_11.rst\n@@ -56,6 +56,10 @@ New Features\n      Also, make sure to start the actual text at the margin.\n      =========================================================\n \n+* **Updated the Intel QuickAssist Technology (QAT) compression PMD.**\n+\n+  Added stateful decompression support in the Intel QuickAssist Technology PMD.\n+  Please note that stateful compression is not supported.\n \n Removed Items\n -------------\ndiff --git a/drivers/compress/qat/qat_comp.c b/drivers/compress/qat/qat_comp.c\nindex 835aaa838..8717b7432 100644\n--- a/drivers/compress/qat/qat_comp.c\n+++ b/drivers/compress/qat/qat_comp.c\n@@ -27,22 +27,51 @@ qat_comp_build_request(void *in_op, uint8_t *out_msg,\n \tstruct rte_comp_op *op = in_op;\n \tstruct qat_comp_op_cookie *cookie =\n \t\t\t(struct qat_comp_op_cookie *)op_cookie;\n-\tstruct qat_comp_xform *qat_xform = op->private_xform;\n-\tconst uint8_t *tmpl = (uint8_t *)&qat_xform->qat_comp_req_tmpl;\n+\tstruct qat_comp_stream *stream;\n+\tstruct qat_comp_xform *qat_xform;\n+\tconst uint8_t *tmpl;\n \tstruct icp_qat_fw_comp_req *comp_req =\n \t    (struct icp_qat_fw_comp_req *)out_msg;\n \n-\tif (unlikely(op->op_type != RTE_COMP_OP_STATELESS)) {\n-\t\tQAT_DP_LOG(ERR, \"QAT PMD only supports stateless compression \"\n-\t\t\t\t\"operation requests, op (%p) is not a \"\n-\t\t\t\t\"stateless operation.\", op);\n-\t\top->status = RTE_COMP_OP_STATUS_INVALID_ARGS;\n-\t\treturn -EINVAL;\n+\tif (op->op_type == RTE_COMP_OP_STATEFUL) {\n+\t\tstream = op->stream;\n+\t\tqat_xform = &stream->qat_xform;\n+\t\tif (unlikely(qat_xform->qat_comp_request_type !=\n+\t\t\t     QAT_COMP_REQUEST_DECOMPRESS)) {\n+\t\t\tQAT_DP_LOG(ERR, \"QAT PMD does not support stateful compression\");\n+\t\t\top->status = RTE_COMP_OP_STATUS_INVALID_ARGS;\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\t\tif (unlikely(stream->op_in_progress)) {\n+\t\t\tQAT_DP_LOG(ERR, \"QAT PMD does not support running multiple stateful operations on the same stream at once\");\n+\t\t\top->status = RTE_COMP_OP_STATUS_INVALID_STATE;\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\t\tstream->op_in_progress = 1;\n+\t} else {\n+\t\tstream = NULL;\n+\t\tqat_xform = op->private_xform;\n \t}\n+\ttmpl = (uint8_t *)&qat_xform->qat_comp_req_tmpl;\n \n \trte_mov128(out_msg, tmpl);\n \tcomp_req->comn_mid.opaque_data = (uint64_t)(uintptr_t)op;\n \n+\tif (op->op_type == RTE_COMP_OP_STATEFUL) {\n+\t\tcomp_req->comp_pars.req_par_flags =\n+\t\t\tICP_QAT_FW_COMP_REQ_PARAM_FLAGS_BUILD(\n+\t\t\t\t(stream->start_of_packet) ?\n+\t\t\t\t\tICP_QAT_FW_COMP_SOP\n+\t\t\t\t      : ICP_QAT_FW_COMP_NOT_SOP,\n+\t\t\t\t(op->flush_flag == RTE_COMP_FLUSH_FULL ||\n+\t\t\t\t op->flush_flag == RTE_COMP_FLUSH_FINAL) ?\n+\t\t\t\t\tICP_QAT_FW_COMP_EOP\n+\t\t\t\t      : ICP_QAT_FW_COMP_NOT_EOP,\n+\t\t\t\tICP_QAT_FW_COMP_NOT_BFINAL,\n+\t\t\t\tICP_QAT_FW_COMP_NO_CNV,\n+\t\t\t\tICP_QAT_FW_COMP_NO_CNV_RECOVERY);\n+\t}\n+\n \tif (likely(qat_xform->qat_comp_request_type ==\n \t\t    QAT_COMP_REQUEST_DYNAMIC_COMP_STATELESS)) {\n \t\tif (unlikely(op->src.length > QAT_FALLBACK_THLD)) {\n@@ -94,6 +123,9 @@ qat_comp_build_request(void *in_op, uint8_t *out_msg,\n \t\t\t\t\t   \" for %d elements of SGL\",\n \t\t\t\t\t   op->m_src->nb_segs);\n \t\t\t\top->status = RTE_COMP_OP_STATUS_ERROR;\n+\t\t\t\t/* clear op-in-progress flag */\n+\t\t\t\tif (stream)\n+\t\t\t\t\tstream->op_in_progress = 0;\n \t\t\t\treturn -ENOMEM;\n \t\t\t}\n \t\t\t/* new SGL is valid now */\n@@ -111,6 +143,9 @@ qat_comp_build_request(void *in_op, uint8_t *out_msg,\n \t\tif (ret) {\n \t\t\tQAT_DP_LOG(ERR, \"QAT PMD Cannot fill source sgl array\");\n \t\t\top->status = RTE_COMP_OP_STATUS_INVALID_ARGS;\n+\t\t\t/* clear op-in-progress flag */\n+\t\t\tif (stream)\n+\t\t\t\tstream->op_in_progress = 0;\n \t\t\treturn ret;\n \t\t}\n \n@@ -129,6 +164,9 @@ qat_comp_build_request(void *in_op, uint8_t *out_msg,\n \t\t\t\t\t   \" for %d elements of SGL\",\n \t\t\t\t\t   op->m_dst->nb_segs);\n \t\t\t\top->status = RTE_COMP_OP_STATUS_ERROR;\n+\t\t\t\t/* clear op-in-progress flag */\n+\t\t\t\tif (stream)\n+\t\t\t\t\tstream->op_in_progress = 0;\n \t\t\t\treturn -ENOMEM;\n \t\t\t}\n \t\t\t/* new SGL is valid now */\n@@ -146,6 +184,9 @@ qat_comp_build_request(void *in_op, uint8_t *out_msg,\n \t\tif (ret) {\n \t\t\tQAT_DP_LOG(ERR, \"QAT PMD Cannot fill dest. sgl array\");\n \t\t\top->status = RTE_COMP_OP_STATUS_INVALID_ARGS;\n+\t\t\t/* clear op-in-progress flag */\n+\t\t\tif (stream)\n+\t\t\t\tstream->op_in_progress = 0;\n \t\t\treturn ret;\n \t\t}\n \n@@ -202,12 +243,22 @@ qat_comp_process_response(void **op, uint8_t *resp, void *op_cookie,\n \t\t\t(struct qat_comp_op_cookie *)op_cookie;\n \tstruct rte_comp_op *rx_op = (struct rte_comp_op *)(uintptr_t)\n \t\t\t(resp_msg->opaque_data);\n-\tstruct qat_comp_xform *qat_xform = (struct qat_comp_xform *)\n-\t\t\t\t(rx_op->private_xform);\n+\tstruct qat_comp_stream *stream;\n+\tstruct qat_comp_xform *qat_xform;\n \tint err = resp_msg->comn_resp.comn_status &\n \t\t\t((1 << QAT_COMN_RESP_CMP_STATUS_BITPOS) |\n \t\t\t (1 << QAT_COMN_RESP_XLAT_STATUS_BITPOS));\n \n+\tif (rx_op->op_type == RTE_COMP_OP_STATEFUL) {\n+\t\tstream = rx_op->stream;\n+\t\tqat_xform = &stream->qat_xform;\n+\t\t/* clear op-in-progress flag */\n+\t\tstream->op_in_progress = 0;\n+\t} else {\n+\t\tstream = NULL;\n+\t\tqat_xform = rx_op->private_xform;\n+\t}\n+\n #if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG\n \tQAT_DP_LOG(DEBUG, \"Direction: %s\",\n \t    qat_xform->qat_comp_request_type == QAT_COMP_REQUEST_DECOMPRESS ?\n@@ -254,7 +305,21 @@ qat_comp_process_response(void **op, uint8_t *resp, void *op_cookie,\n \t\tint8_t xlat_err_code =\n \t\t\t(int8_t)resp_msg->comn_resp.comn_error.xlat_err_code;\n \n-\t\tif ((cmp_err_code == ERR_CODE_OVERFLOW_ERROR && !xlat_err_code)\n+\t\t/* handle recoverable out-of-buffer condition in stateful */\n+\t\t/* decompression scenario */\n+\t\tif (cmp_err_code == ERR_CODE_OVERFLOW_ERROR && !xlat_err_code\n+\t\t\t\t&& qat_xform->qat_comp_request_type\n+\t\t\t\t\t== QAT_COMP_REQUEST_DECOMPRESS\n+\t\t\t\t&& rx_op->op_type == RTE_COMP_OP_STATEFUL) {\n+\t\t\tstruct icp_qat_fw_resp_comp_pars *comp_resp =\n+\t\t\t\t\t&resp_msg->comp_resp_pars;\n+\t\t\trx_op->status =\n+\t\t\t\tRTE_COMP_OP_STATUS_OUT_OF_SPACE_RECOVERABLE;\n+\t\t\trx_op->consumed = comp_resp->input_byte_counter;\n+\t\t\trx_op->produced = comp_resp->output_byte_counter;\n+\t\t\tstream->start_of_packet = 0;\n+\t\t} else if ((cmp_err_code == ERR_CODE_OVERFLOW_ERROR\n+\t\t\t  && !xlat_err_code)\n \t\t\t\t||\n \t\t    (!cmp_err_code && xlat_err_code == ERR_CODE_OVERFLOW_ERROR)\n \t\t\t\t||\n@@ -275,6 +340,8 @@ qat_comp_process_response(void **op, uint8_t *resp, void *op_cookie,\n \t\trx_op->status = RTE_COMP_OP_STATUS_SUCCESS;\n \t\trx_op->consumed = comp_resp->input_byte_counter;\n \t\trx_op->produced = comp_resp->output_byte_counter;\n+\t\tif (stream)\n+\t\t\tstream->start_of_packet = 0;\n \n \t\tif (qat_xform->checksum_type != RTE_COMP_CHECKSUM_NONE) {\n \t\t\tif (qat_xform->checksum_type == RTE_COMP_CHECKSUM_CRC32)\n@@ -297,6 +364,12 @@ qat_comp_xform_size(void)\n \treturn RTE_ALIGN_CEIL(sizeof(struct qat_comp_xform), 8);\n }\n \n+unsigned int\n+qat_comp_stream_size(void)\n+{\n+\treturn RTE_ALIGN_CEIL(sizeof(struct qat_comp_stream), 8);\n+}\n+\n static void qat_comp_create_req_hdr(struct icp_qat_fw_comn_req_hdr *header,\n \t\t\t\t    enum qat_comp_request_type request)\n {\n@@ -317,7 +390,9 @@ static void qat_comp_create_req_hdr(struct icp_qat_fw_comn_req_hdr *header,\n \n static int qat_comp_create_templates(struct qat_comp_xform *qat_xform,\n \t\t\tconst struct rte_memzone *interm_buff_mz,\n-\t\t\tconst struct rte_comp_xform *xform)\n+\t\t\tconst struct rte_comp_xform *xform,\n+\t\t\tconst struct qat_comp_stream *stream,\n+\t\t\tenum rte_comp_op_type op_type)\n {\n \tstruct icp_qat_fw_comp_req *comp_req;\n \tint comp_level, algo;\n@@ -329,6 +404,18 @@ static int qat_comp_create_templates(struct qat_comp_xform *qat_xform,\n \t\treturn -EINVAL;\n \t}\n \n+\tif (op_type == RTE_COMP_OP_STATEFUL) {\n+\t\tif (unlikely(stream == NULL)) {\n+\t\t\tQAT_LOG(ERR, \"Stream must be non null for stateful op\");\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\t\tif (unlikely(qat_xform->qat_comp_request_type !=\n+\t\t\t     QAT_COMP_REQUEST_DECOMPRESS)) {\n+\t\t\tQAT_LOG(ERR, \"QAT PMD does not support stateful compression\");\n+\t\t\treturn -ENOTSUP;\n+\t\t}\n+\t}\n+\n \tif (qat_xform->qat_comp_request_type == QAT_COMP_REQUEST_DECOMPRESS) {\n \t\tdirection = ICP_QAT_HW_COMPRESSION_DIR_DECOMPRESS;\n \t\tcomp_level = ICP_QAT_HW_COMPRESSION_DEPTH_1;\n@@ -376,12 +463,43 @@ static int qat_comp_create_templates(struct qat_comp_xform *qat_xform,\n \tqat_comp_create_req_hdr(&comp_req->comn_hdr,\n \t\t\t\t\tqat_xform->qat_comp_request_type);\n \n-\tcomp_req->comn_hdr.serv_specif_flags = ICP_QAT_FW_COMP_FLAGS_BUILD(\n-\t    ICP_QAT_FW_COMP_STATELESS_SESSION,\n-\t    ICP_QAT_FW_COMP_NOT_AUTO_SELECT_BEST,\n-\t    ICP_QAT_FW_COMP_NOT_ENH_AUTO_SELECT_BEST,\n-\t    ICP_QAT_FW_COMP_NOT_DISABLE_TYPE0_ENH_AUTO_SELECT_BEST,\n-\t    ICP_QAT_FW_COMP_ENABLE_SECURE_RAM_USED_AS_INTMD_BUF);\n+\tif (op_type == RTE_COMP_OP_STATEFUL) {\n+\t\tcomp_req->comn_hdr.serv_specif_flags =\n+\t\t\t\tICP_QAT_FW_COMP_FLAGS_BUILD(\n+\t\t\tICP_QAT_FW_COMP_STATEFUL_SESSION,\n+\t\t\tICP_QAT_FW_COMP_NOT_AUTO_SELECT_BEST,\n+\t\t\tICP_QAT_FW_COMP_NOT_ENH_AUTO_SELECT_BEST,\n+\t\t\tICP_QAT_FW_COMP_NOT_DISABLE_TYPE0_ENH_AUTO_SELECT_BEST,\n+\t\t\tICP_QAT_FW_COMP_ENABLE_SECURE_RAM_USED_AS_INTMD_BUF);\n+\n+\t\t/* Decompression state registers */\n+\t\tcomp_req->comp_cd_ctrl.comp_state_addr =\n+\t\t\t\tstream->state_registers_decomp_phys;\n+\n+\t\t/* Enable A, B, C, D, and E (CAMs). */\n+\t\tcomp_req->comp_cd_ctrl.ram_bank_flags =\n+\t\t\tICP_QAT_FW_COMP_RAM_FLAGS_BUILD(\n+\t\t\t\tICP_QAT_FW_COMP_BANK_DISABLED, /* Bank I */\n+\t\t\t\tICP_QAT_FW_COMP_BANK_DISABLED, /* Bank H */\n+\t\t\t\tICP_QAT_FW_COMP_BANK_DISABLED, /* Bank G */\n+\t\t\t\tICP_QAT_FW_COMP_BANK_DISABLED, /* Bank F */\n+\t\t\t\tICP_QAT_FW_COMP_BANK_ENABLED,  /* Bank E */\n+\t\t\t\tICP_QAT_FW_COMP_BANK_ENABLED,  /* Bank D */\n+\t\t\t\tICP_QAT_FW_COMP_BANK_ENABLED,  /* Bank C */\n+\t\t\t\tICP_QAT_FW_COMP_BANK_ENABLED,  /* Bank B */\n+\t\t\t\tICP_QAT_FW_COMP_BANK_ENABLED); /* Bank A */\n+\n+\t\tcomp_req->comp_cd_ctrl.ram_banks_addr =\n+\t\t\t\tstream->inflate_context_phys;\n+\t} else {\n+\t\tcomp_req->comn_hdr.serv_specif_flags =\n+\t\t\t\tICP_QAT_FW_COMP_FLAGS_BUILD(\n+\t\t\tICP_QAT_FW_COMP_STATELESS_SESSION,\n+\t\t\tICP_QAT_FW_COMP_NOT_AUTO_SELECT_BEST,\n+\t\t\tICP_QAT_FW_COMP_NOT_ENH_AUTO_SELECT_BEST,\n+\t\t\tICP_QAT_FW_COMP_NOT_DISABLE_TYPE0_ENH_AUTO_SELECT_BEST,\n+\t\t\tICP_QAT_FW_COMP_ENABLE_SECURE_RAM_USED_AS_INTMD_BUF);\n+\t}\n \n \tcomp_req->cd_pars.sl.comp_slice_cfg_word[0] =\n \t    ICP_QAT_HW_COMPRESSION_CONFIG_BUILD(\n@@ -497,7 +615,8 @@ qat_comp_private_xform_create(struct rte_compressdev *dev,\n \t\tqat_xform->checksum_type = xform->decompress.chksum;\n \t}\n \n-\tif (qat_comp_create_templates(qat_xform, qat->interm_buff_mz, xform)) {\n+\tif (qat_comp_create_templates(qat_xform, qat->interm_buff_mz, xform,\n+\t\t\t\t      NULL, RTE_COMP_OP_STATELESS)) {\n \t\tQAT_LOG(ERR, \"QAT: Problem with setting compression\");\n \t\treturn -EINVAL;\n \t}\n@@ -532,3 +651,102 @@ qat_comp_private_xform_free(struct rte_compressdev *dev __rte_unused,\n \t}\n \treturn -EINVAL;\n }\n+\n+/**\n+ * Reset stream state for the next use.\n+ *\n+ * @param stream\n+ *   handle of pmd's private stream data\n+ */\n+static void\n+qat_comp_stream_reset(struct qat_comp_stream *stream)\n+{\n+\tif (stream) {\n+\t\tmemset(&stream->qat_xform, 0, sizeof(struct qat_comp_xform));\n+\t\tstream->start_of_packet = 1;\n+\t\tstream->op_in_progress = 0;\n+\t}\n+}\n+\n+/**\n+ * Create driver private stream data.\n+ *\n+ * @param dev\n+ *   Compressdev device\n+ * @param xform\n+ *   xform data\n+ * @param stream\n+ *   ptr where handle of pmd's private stream data should be stored\n+ * @return\n+ *  - Returns 0 if private stream structure has been created successfully.\n+ *  - Returns -EINVAL if input parameters are invalid.\n+ *  - Returns -ENOTSUP if comp device does not support STATEFUL operations.\n+ *  - Returns -ENOTSUP if comp device does not support the comp transform.\n+ *  - Returns -ENOMEM if the private stream could not be allocated.\n+ */\n+int\n+qat_comp_stream_create(struct rte_compressdev *dev,\n+\t\t       const struct rte_comp_xform *xform,\n+\t\t       void **stream)\n+{\n+\tstruct qat_comp_dev_private *qat = dev->data->dev_private;\n+\tstruct qat_comp_stream *ptr;\n+\n+\tif (unlikely(stream == NULL)) {\n+\t\tQAT_LOG(ERR, \"QAT: stream parameter is NULL\");\n+\t\treturn -EINVAL;\n+\t}\n+\tif (unlikely(xform->type == RTE_COMP_COMPRESS)) {\n+\t\tQAT_LOG(ERR, \"QAT: stateful compression not supported\");\n+\t\treturn -ENOTSUP;\n+\t}\n+\tif (unlikely(qat->streampool == NULL)) {\n+\t\tQAT_LOG(ERR, \"QAT device has no stream mempool\");\n+\t\treturn -ENOMEM;\n+\t}\n+\tif (rte_mempool_get(qat->streampool, stream)) {\n+\t\tQAT_LOG(ERR, \"Couldn't get object from qat stream mempool\");\n+\t\treturn -ENOMEM;\n+\t}\n+\n+\tptr = (struct qat_comp_stream *) *stream;\n+\tqat_comp_stream_reset(ptr);\n+\tptr->qat_xform.qat_comp_request_type = QAT_COMP_REQUEST_DECOMPRESS;\n+\tptr->qat_xform.checksum_type = xform->decompress.chksum;\n+\n+\tif (qat_comp_create_templates(&ptr->qat_xform, qat->interm_buff_mz,\n+\t\t\t\t      xform, ptr, RTE_COMP_OP_STATEFUL)) {\n+\t\tQAT_LOG(ERR, \"QAT: problem with creating descriptor template for stream\");\n+\t\trte_mempool_put(qat->streampool, *stream);\n+\t\t*stream = NULL;\n+\t\treturn -EINVAL;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+/**\n+ * Free driver private stream data.\n+ *\n+ * @param dev\n+ *   Compressdev device\n+ * @param stream\n+ *   handle of pmd's private stream data\n+ * @return\n+ *  - 0 if successful\n+ *  - <0 in error cases\n+ *  - Returns -EINVAL if input parameters are invalid.\n+ *  - Returns -ENOTSUP if comp device does not support STATEFUL operations.\n+ *  - Returns -EBUSY if can't free stream as there are inflight operations\n+ */\n+int\n+qat_comp_stream_free(struct rte_compressdev *dev, void *stream)\n+{\n+\tif (stream) {\n+\t\tstruct qat_comp_dev_private *qat = dev->data->dev_private;\n+\t\tqat_comp_stream_reset((struct qat_comp_stream *) stream);\n+\t\trte_mempool_put(qat->streampool, stream);\n+\t\treturn 0;\n+\t}\n+\treturn -EINVAL;\n+}\ndiff --git a/drivers/compress/qat/qat_comp.h b/drivers/compress/qat/qat_comp.h\nindex 61d12ecf4..2231451a1 100644\n--- a/drivers/compress/qat/qat_comp.h\n+++ b/drivers/compress/qat/qat_comp.h\n@@ -26,6 +26,16 @@\n \n #define QAT_MIN_OUT_BUF_SIZE 46\n \n+/* maximum size of the state registers */\n+#define QAT_STATE_REGISTERS_MAX_SIZE 64\n+\n+/* decompressor context size */\n+#define QAT_INFLATE_CONTEXT_SIZE_GEN1 36864\n+#define QAT_INFLATE_CONTEXT_SIZE_GEN2 34032\n+#define QAT_INFLATE_CONTEXT_SIZE_GEN3 34032\n+#define QAT_INFLATE_CONTEXT_SIZE RTE_MAX(RTE_MAX(QAT_INFLATE_CONTEXT_SIZE_GEN1,\\\n+\t\tQAT_INFLATE_CONTEXT_SIZE_GEN2), QAT_INFLATE_CONTEXT_SIZE_GEN3)\n+\n enum qat_comp_request_type {\n \tQAT_COMP_REQUEST_FIXED_COMP_STATELESS,\n \tQAT_COMP_REQUEST_DYNAMIC_COMP_STATELESS,\n@@ -61,6 +71,17 @@ struct qat_comp_xform {\n \tenum rte_comp_checksum_type checksum_type;\n };\n \n+struct qat_comp_stream {\n+\tstruct qat_comp_xform qat_xform;\n+\tvoid *state_registers_decomp;\n+\tphys_addr_t state_registers_decomp_phys;\n+\tvoid *inflate_context;\n+\tphys_addr_t inflate_context_phys;\n+\tconst struct rte_memzone *memzone;\n+\tuint8_t start_of_packet;\n+\tvolatile uint8_t op_in_progress;\n+};\n+\n int\n qat_comp_build_request(void *in_op, uint8_t *out_msg, void *op_cookie,\n \t\t       enum qat_device_gen qat_dev_gen __rte_unused);\n@@ -80,5 +101,16 @@ qat_comp_private_xform_free(struct rte_compressdev *dev, void *private_xform);\n unsigned int\n qat_comp_xform_size(void);\n \n+unsigned int\n+qat_comp_stream_size(void);\n+\n+int\n+qat_comp_stream_create(struct rte_compressdev *dev,\n+\t\t       const struct rte_comp_xform *xform,\n+\t\t       void **stream);\n+\n+int\n+qat_comp_stream_free(struct rte_compressdev *dev, void *stream);\n+\n #endif\n #endif\ndiff --git a/drivers/compress/qat/qat_comp_pmd.c b/drivers/compress/qat/qat_comp_pmd.c\nindex 072647217..05b7dfe77 100644\n--- a/drivers/compress/qat/qat_comp_pmd.c\n+++ b/drivers/compress/qat/qat_comp_pmd.c\n@@ -9,6 +9,12 @@\n \n #define QAT_PMD_COMP_SGL_DEF_SEGMENTS 16\n \n+struct stream_create_info {\n+\tstruct qat_comp_dev_private *comp_dev;\n+\tint socket_id;\n+\tint error;\n+};\n+\n static const struct rte_compressdev_capabilities qat_comp_gen_capabilities[] = {\n \t{/* COMPRESSION - deflate */\n \t .algo = RTE_COMP_ALGO_DEFLATE,\n@@ -21,7 +27,8 @@ static const struct rte_compressdev_capabilities qat_comp_gen_capabilities[] = {\n \t\t\t\tRTE_COMP_FF_HUFFMAN_DYNAMIC |\n \t\t\t\tRTE_COMP_FF_OOP_SGL_IN_SGL_OUT |\n \t\t\t\tRTE_COMP_FF_OOP_SGL_IN_LB_OUT |\n-\t\t\t\tRTE_COMP_FF_OOP_LB_IN_SGL_OUT,\n+\t\t\t\tRTE_COMP_FF_OOP_LB_IN_SGL_OUT |\n+\t\t\t\tRTE_COMP_FF_STATEFUL_DECOMPRESSION,\n \t .window_size = {.min = 15, .max = 15, .increment = 0} },\n \t{RTE_COMP_ALGO_LIST_END, 0, {0, 0, 0} } };\n \n@@ -315,6 +322,120 @@ qat_comp_create_xform_pool(struct qat_comp_dev_private *comp_dev,\n \treturn mp;\n }\n \n+static void\n+qat_comp_stream_init(struct rte_mempool *mp __rte_unused, void *opaque,\n+\t\t     void *obj, unsigned int obj_idx)\n+{\n+\tstruct stream_create_info *info = opaque;\n+\tstruct qat_comp_stream *stream = obj;\n+\tchar mz_name[RTE_MEMZONE_NAMESIZE];\n+\tconst struct rte_memzone *memzone;\n+\tstruct qat_inter_sgl *ram_banks_desc;\n+\n+\t/* find a memzone for RAM banks */\n+\tsnprintf(mz_name, RTE_MEMZONE_NAMESIZE, \"%s_%u_rambanks\",\n+\t\t info->comp_dev->qat_dev->name, obj_idx);\n+\tmemzone = rte_memzone_lookup(mz_name);\n+\tif (memzone == NULL) {\n+\t\t/* allocate a memzone for compression state and RAM banks */\n+\t\tmemzone = rte_memzone_reserve_aligned(mz_name,\n+\t\t\tQAT_STATE_REGISTERS_MAX_SIZE\n+\t\t\t\t+ sizeof(struct qat_inter_sgl)\n+\t\t\t\t+ QAT_INFLATE_CONTEXT_SIZE,\n+\t\t\tinfo->socket_id,\n+\t\t\tRTE_MEMZONE_IOVA_CONTIG, QAT_64_BYTE_ALIGN);\n+\t\tif (memzone == NULL) {\n+\t\t\tQAT_LOG(ERR,\n+\t\t\t    \"Can't allocate RAM banks for device %s, object %u\",\n+\t\t\t\tinfo->comp_dev->qat_dev->name, obj_idx);\n+\t\t\tinfo->error = -ENOMEM;\n+\t\t\treturn;\n+\t\t}\n+\t}\n+\n+\t/* prepare the buffer list descriptor for RAM banks */\n+\tram_banks_desc = (struct qat_inter_sgl *)\n+\t\t(((uint8_t *) memzone->addr) + QAT_STATE_REGISTERS_MAX_SIZE);\n+\tram_banks_desc->num_bufs = 1;\n+\tram_banks_desc->buffers[0].len = QAT_INFLATE_CONTEXT_SIZE;\n+\tram_banks_desc->buffers[0].addr = memzone->iova\n+\t\t\t+ QAT_STATE_REGISTERS_MAX_SIZE\n+\t\t\t+ sizeof(struct qat_inter_sgl);\n+\n+\tmemset(stream, 0, qat_comp_stream_size());\n+\tstream->memzone = memzone;\n+\tstream->state_registers_decomp = memzone->addr;\n+\tstream->state_registers_decomp_phys = memzone->iova;\n+\tstream->inflate_context = ((uint8_t *) memzone->addr)\n+\t\t\t+ QAT_STATE_REGISTERS_MAX_SIZE;\n+\tstream->inflate_context_phys = memzone->iova\n+\t\t\t+ QAT_STATE_REGISTERS_MAX_SIZE;\n+}\n+\n+static void\n+qat_comp_stream_destroy(struct rte_mempool *mp __rte_unused,\n+\t\t\tvoid *opaque __rte_unused, void *obj,\n+\t\t\tunsigned obj_idx __rte_unused)\n+{\n+\tstruct qat_comp_stream *stream = obj;\n+\n+\trte_memzone_free(stream->memzone);\n+}\n+\n+static struct rte_mempool *\n+qat_comp_create_stream_pool(struct qat_comp_dev_private *comp_dev,\n+\t\t\t    int socket_id,\n+\t\t\t    uint32_t num_elements)\n+{\n+\tchar stream_pool_name[RTE_MEMPOOL_NAMESIZE];\n+\tstruct rte_mempool *mp;\n+\n+\tsnprintf(stream_pool_name, RTE_MEMPOOL_NAMESIZE,\n+\t\t \"%s_streams\", comp_dev->qat_dev->name);\n+\n+\tQAT_LOG(DEBUG, \"streampool: %s\", stream_pool_name);\n+\tmp = rte_mempool_lookup(stream_pool_name);\n+\n+\tif (mp != NULL) {\n+\t\tQAT_LOG(DEBUG, \"streampool already created\");\n+\t\tif (mp->size != num_elements) {\n+\t\t\tQAT_LOG(DEBUG, \"streampool wrong size - delete it\");\n+\t\t\trte_mempool_obj_iter(mp, qat_comp_stream_destroy, NULL);\n+\t\t\trte_mempool_free(mp);\n+\t\t\tmp = NULL;\n+\t\t\tcomp_dev->streampool = NULL;\n+\t\t}\n+\t}\n+\n+\tif (mp == NULL) {\n+\t\tstruct stream_create_info info = {\n+\t\t\t.comp_dev = comp_dev,\n+\t\t\t.socket_id = socket_id,\n+\t\t\t.error = 0\n+\t\t};\n+\t\tmp = rte_mempool_create(stream_pool_name,\n+\t\t\t\tnum_elements,\n+\t\t\t\tqat_comp_stream_size(), 0, 0,\n+\t\t\t\tNULL, NULL, qat_comp_stream_init, &info,\n+\t\t\t\tsocket_id, 0);\n+\t\tif (mp == NULL) {\n+\t\t\tQAT_LOG(ERR,\n+\t\t\t     \"Err creating mempool %s w %d elements of size %d\",\n+\t\t\t     stream_pool_name, num_elements,\n+\t\t\t     qat_comp_stream_size());\n+\t\t} else if (info.error) {\n+\t\t\trte_mempool_obj_iter(mp, qat_comp_stream_destroy, NULL);\n+\t\t\tQAT_LOG(ERR,\n+\t\t\t     \"Destoying mempool %s as at least one element failed initialisation\",\n+\t\t\t     stream_pool_name);\n+\t\t\trte_mempool_free(mp);\n+\t\t\tmp = NULL;\n+\t\t}\n+\t}\n+\n+\treturn mp;\n+}\n+\n static void\n _qat_comp_dev_config_clear(struct qat_comp_dev_private *comp_dev)\n {\n@@ -330,6 +451,14 @@ _qat_comp_dev_config_clear(struct qat_comp_dev_private *comp_dev)\n \t\trte_mempool_free(comp_dev->xformpool);\n \t\tcomp_dev->xformpool = NULL;\n \t}\n+\n+\t/* Free stream pool */\n+\tif (comp_dev->streampool) {\n+\t\trte_mempool_obj_iter(comp_dev->streampool,\n+\t\t\t\t     qat_comp_stream_destroy, NULL);\n+\t\trte_mempool_free(comp_dev->streampool);\n+\t\tcomp_dev->streampool = NULL;\n+\t}\n }\n \n static int\n@@ -339,12 +468,6 @@ qat_comp_dev_config(struct rte_compressdev *dev,\n \tstruct qat_comp_dev_private *comp_dev = dev->data->dev_private;\n \tint ret = 0;\n \n-\tif (config->max_nb_streams != 0) {\n-\t\tQAT_LOG(ERR,\n-\t\"QAT device does not support STATEFUL so max_nb_streams must be 0\");\n-\t\treturn -EINVAL;\n-\t}\n-\n \tif (RTE_PMD_QAT_COMP_IM_BUFFER_SIZE == 0) {\n \t\tQAT_LOG(WARNING,\n \t\t\t\"RTE_PMD_QAT_COMP_IM_BUFFER_SIZE = 0 in config file, so\"\n@@ -360,13 +483,26 @@ qat_comp_dev_config(struct rte_compressdev *dev,\n \t\t}\n \t}\n \n-\tcomp_dev->xformpool = qat_comp_create_xform_pool(comp_dev, config,\n-\t\t\t\t\tconfig->max_nb_priv_xforms);\n-\tif (comp_dev->xformpool == NULL) {\n+\tif (config->max_nb_priv_xforms) {\n+\t\tcomp_dev->xformpool = qat_comp_create_xform_pool(comp_dev,\n+\t\t\t\t\t    config, config->max_nb_priv_xforms);\n+\t\tif (comp_dev->xformpool == NULL) {\n+\t\t\tret = -ENOMEM;\n+\t\t\tgoto error_out;\n+\t\t}\n+\t} else\n+\t\tcomp_dev->xformpool = NULL;\n+\n+\tif (config->max_nb_streams) {\n+\t\tcomp_dev->streampool = qat_comp_create_stream_pool(comp_dev,\n+\t\t\t\t     config->socket_id, config->max_nb_streams);\n+\t\tif (comp_dev->streampool == NULL) {\n+\t\t\tret = -ENOMEM;\n+\t\t\tgoto error_out;\n+\t\t}\n+\t} else\n+\t\tcomp_dev->streampool = NULL;\n \n-\t\tret = -ENOMEM;\n-\t\tgoto error_out;\n-\t}\n \treturn 0;\n \n error_out:\n@@ -508,7 +644,9 @@ static struct rte_compressdev_ops compress_qat_ops = {\n \n \t/* Compression related operations */\n \t.private_xform_create\t= qat_comp_private_xform_create,\n-\t.private_xform_free\t= qat_comp_private_xform_free\n+\t.private_xform_free\t= qat_comp_private_xform_free,\n+\t.stream_create\t\t= qat_comp_stream_create,\n+\t.stream_free\t\t= qat_comp_stream_free\n };\n \n /* An rte_driver is needed in the registration of the device with compressdev.\ndiff --git a/drivers/compress/qat/qat_comp_pmd.h b/drivers/compress/qat/qat_comp_pmd.h\nindex b8299d43a..6979de14d 100644\n--- a/drivers/compress/qat/qat_comp_pmd.h\n+++ b/drivers/compress/qat/qat_comp_pmd.h\n@@ -30,6 +30,8 @@ struct qat_comp_dev_private {\n \t/**< The device's memory for intermediate buffers */\n \tstruct rte_mempool *xformpool;\n \t/**< The device's pool for qat_comp_xforms */\n+\tstruct rte_mempool *streampool;\n+\t/**< The device's pool for qat_comp_streams */\n };\n \n int\n",
    "prefixes": [
        "v3",
        "2/3"
    ]
}