get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 105465,
    "url": "http://patchwork.dpdk.org/api/patches/105465/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20211228092421.22602-2-arkadiuszx.kusztal@intel.com/",
    "project": {
        "id": 1,
        "url": "http://patchwork.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": "<20211228092421.22602-2-arkadiuszx.kusztal@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20211228092421.22602-2-arkadiuszx.kusztal@intel.com",
    "date": "2021-12-28T09:24:20",
    "name": "[1/2] crypto/qat: refactor asymmetric crypto functions",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "efe1459ecc5a55f31a640bfdc9816d1b456d68e5",
    "submitter": {
        "id": 452,
        "url": "http://patchwork.dpdk.org/api/people/452/?format=api",
        "name": "Arkadiusz Kusztal",
        "email": "arkadiuszx.kusztal@intel.com"
    },
    "delegate": {
        "id": 6690,
        "url": "http://patchwork.dpdk.org/api/users/6690/?format=api",
        "username": "akhil",
        "first_name": "akhil",
        "last_name": "goyal",
        "email": "gakhil@marvell.com"
    },
    "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/20211228092421.22602-2-arkadiuszx.kusztal@intel.com/mbox/",
    "series": [
        {
            "id": 21034,
            "url": "http://patchwork.dpdk.org/api/series/21034/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=21034",
            "date": "2021-12-28T09:24:19",
            "name": "crypto/qat: add asymmetric crypto algorithms",
            "version": 1,
            "mbox": "http://patchwork.dpdk.org/series/21034/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/105465/comments/",
    "check": "warning",
    "checks": "http://patchwork.dpdk.org/api/patches/105465/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 7833DA034F;\n\tTue, 28 Dec 2021 10:25:17 +0100 (CET)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id DCE0F410FF;\n\tTue, 28 Dec 2021 10:25:10 +0100 (CET)",
            "from mga02.intel.com (mga02.intel.com [134.134.136.20])\n by mails.dpdk.org (Postfix) with ESMTP id 460494003C\n for <dev@dpdk.org>; Tue, 28 Dec 2021 10:25:06 +0100 (CET)",
            "from orsmga005.jf.intel.com ([10.7.209.41])\n by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 28 Dec 2021 01:24:31 -0800",
            "from silpixa00400308.ir.intel.com ([10.237.214.95])\n by orsmga005.jf.intel.com with ESMTP; 28 Dec 2021 01:24:29 -0800"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple;\n d=intel.com; i=@intel.com; q=dns/txt; s=Intel;\n t=1640683507; x=1672219507;\n h=from:to:cc:subject:date:message-id:in-reply-to: references;\n bh=4lV6ztamrHw/7UjmO3saabFwAnMNqE7Kfb2sioSG03I=;\n b=VJs0Y7LXhpOrtpWa5bO0TTirdbgVXlKmimLn2wnhvHnofmaJkUW+6BYs\n UcKWIQbOGLbDD6fqcPZswpXr600awSrw9eyLEwihcUksl434jHcQIDzE1\n xC8SlDiZUJsdYsKvYDrXK7VEuY44qqLYKPCDGTR1+Xr51KCIlDWfm7fhS\n xsiQrIuUUvbiuQbcDIGFhso3qn1sIPDary7fIGBQfUvO7NRZK58gmWErC\n jrSujpQRRHP8Z1NDwLDRp+EoeAk54DeAyLc5yd31OrCZulyQylYb/zj1J\n DTzsw3UL4vSOO3O6vd9ZDQm/MHPA/hSmpxpGi7OJQfF0x9DsQxxxZ44ly g==;",
        "X-IronPort-AV": [
            "E=McAfee;i=\"6200,9189,10210\"; a=\"228645409\"",
            "E=Sophos;i=\"5.88,242,1635231600\"; d=\"scan'208\";a=\"228645409\"",
            "E=Sophos;i=\"5.88,242,1635231600\"; d=\"scan'208\";a=\"686542946\""
        ],
        "X-ExtLoop1": "1",
        "From": "Arek Kusztal <arkadiuszx.kusztal@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "gakhil@marvell.com, roy.fan.zhang@intel.com,\n Arek Kusztal <arkadiuszx.kusztal@intel.com>",
        "Subject": "[PATCH 1/2] crypto/qat: refactor asymmetric crypto functions",
        "Date": "Tue, 28 Dec 2021 09:24:20 +0000",
        "Message-Id": "<20211228092421.22602-2-arkadiuszx.kusztal@intel.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "In-Reply-To": "<20211228092421.22602-1-arkadiuszx.kusztal@intel.com>",
        "References": "<20211228092421.22602-1-arkadiuszx.kusztal@intel.com>",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <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 <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org"
    },
    "content": "This commit refactors asummetric crypto functions\nin Intel QuickAssist Technology PMD.\nFunctions right now are shorter and far easier readable,\nplus it facilitates addition of new algorithms.\n\nSigned-off-by: Arek Kusztal <arkadiuszx.kusztal@intel.com>\n---\n .../qat/qat_adf/qat_pke_functionality_arrays.h     |  254 ++++-\n drivers/crypto/qat/dev/qat_asym_pmd_gen1.c         |    1 -\n drivers/crypto/qat/qat_asym.c                      | 1127 +++++++++-----------\n drivers/crypto/qat/qat_asym.h                      |    2 +-\n 4 files changed, 698 insertions(+), 686 deletions(-)",
    "diff": "diff --git a/drivers/common/qat/qat_adf/qat_pke_functionality_arrays.h b/drivers/common/qat/qat_adf/qat_pke_functionality_arrays.h\nindex 42ffbbadd0..6aec257988 100644\n--- a/drivers/common/qat/qat_adf/qat_pke_functionality_arrays.h\n+++ b/drivers/common/qat/qat_adf/qat_pke_functionality_arrays.h\n@@ -10,70 +10,206 @@\n /*\n  * Modular exponentiation functionality IDs\n  */\n-static const uint32_t MOD_EXP_SIZE[][2] = {\n-\t\t{ 512,\tMATHS_MODEXP_L512 },\n-\t\t{ 1024, MATHS_MODEXP_L1024 },\n-\t\t{ 1536,\tMATHS_MODEXP_L1536 },\n-\t\t{ 2048, MATHS_MODEXP_L2048 },\n-\t\t{ 2560, MATHS_MODEXP_L2560 },\n-\t\t{ 3072, MATHS_MODEXP_L3072 },\n-\t\t{ 3584, MATHS_MODEXP_L3584 },\n-\t\t{ 4096, MATHS_MODEXP_L4096 }\n-};\n \n-static const uint32_t MOD_INV_IDS_ODD[][2] = {\n-\t\t{ 128,\tMATHS_MODINV_ODD_L128 },\n-\t\t{ 192,\tMATHS_MODINV_ODD_L192 },\n-\t\t{ 256,  MATHS_MODINV_ODD_L256 },\n-\t\t{ 384,\tMATHS_MODINV_ODD_L384 },\n-\t\t{ 512,\tMATHS_MODINV_ODD_L512 },\n-\t\t{ 768,\tMATHS_MODINV_ODD_L768 },\n-\t\t{ 1024, MATHS_MODINV_ODD_L1024 },\n-\t\t{ 1536, MATHS_MODINV_ODD_L1536 },\n-\t\t{ 2048, MATHS_MODINV_ODD_L2048 },\n-\t\t{ 3072, MATHS_MODINV_ODD_L3072 },\n-\t\t{ 4096, MATHS_MODINV_ODD_L4096 },\n+struct qat_asym_function {\n+\tuint32_t func_id;\n+\tuint32_t bytesize;\n };\n \n-static const uint32_t MOD_INV_IDS_EVEN[][2] = {\n-\t\t{ 128,\tMATHS_MODINV_EVEN_L128 },\n-\t\t{ 192,\tMATHS_MODINV_EVEN_L192 },\n-\t\t{ 256,\tMATHS_MODINV_EVEN_L256 },\n-\t\t{ 384,\tMATHS_MODINV_EVEN_L384 },\n-\t\t{ 512,\tMATHS_MODINV_EVEN_L512 },\n-\t\t{ 768,\tMATHS_MODINV_EVEN_L768 },\n-\t\t{ 1024, MATHS_MODINV_EVEN_L1024 },\n-\t\t{ 1536, MATHS_MODINV_EVEN_L1536 },\n-\t\t{ 2048, MATHS_MODINV_EVEN_L2048 },\n-\t\t{ 3072, MATHS_MODINV_EVEN_L3072 },\n-\t\t{ 4096, MATHS_MODINV_EVEN_L4096 },\n-};\n+static struct qat_asym_function\n+get_modexp_function(struct rte_crypto_asym_xform *xform)\n+{\n+\tstruct qat_asym_function qat_function = { };\n \n-static const uint32_t RSA_ENC_IDS[][2] = {\n-\t\t{ 512,\tPKE_RSA_EP_512 },\n-\t\t{ 1024,\tPKE_RSA_EP_1024 },\n-\t\t{ 1536,\tPKE_RSA_EP_1536 },\n-\t\t{ 2048,\tPKE_RSA_EP_2048 },\n-\t\t{ 3072,\tPKE_RSA_EP_3072 },\n-\t\t{ 4096,\tPKE_RSA_EP_4096 },\n-};\n+\tif (xform->modex.modulus.length <= 64) {\n+\t\tqat_function.func_id = MATHS_MODEXP_L512;\n+\t\tqat_function.bytesize = 64;\n+\t} else if (xform->modex.modulus.length <= 128) {\n+\t\tqat_function.func_id = MATHS_MODEXP_L1024;\n+\t\tqat_function.bytesize = 128;\n+\t} else if (xform->modex.modulus.length <= 192) {\n+\t\tqat_function.func_id = MATHS_MODEXP_L1536;\n+\t\tqat_function.bytesize = 192;\n+\t} else if (xform->modex.modulus.length <= 256) {\n+\t\tqat_function.func_id = MATHS_MODEXP_L2048;\n+\t\tqat_function.bytesize = 256;\n+\t} else if (xform->modex.modulus.length <= 320) {\n+\t\tqat_function.func_id = MATHS_MODEXP_L2560;\n+\t\tqat_function.bytesize = 320;\n+\t} else if (xform->modex.modulus.length <= 384) {\n+\t\tqat_function.func_id = MATHS_MODEXP_L3072;\n+\t\tqat_function.bytesize = 384;\n+\t} else if (xform->modex.modulus.length <= 448) {\n+\t\tqat_function.func_id = MATHS_MODEXP_L3584;\n+\t\tqat_function.bytesize = 448;\n+\t} else if (xform->modex.modulus.length <= 512) {\n+\t\tqat_function.func_id = MATHS_MODEXP_L4096;\n+\t\tqat_function.bytesize = 512;\n+\t}\n+\treturn qat_function;\n+}\n \n-static const uint32_t RSA_DEC_IDS[][2] = {\n-\t\t{ 512,\tPKE_RSA_DP1_512 },\n-\t\t{ 1024,\tPKE_RSA_DP1_1024 },\n-\t\t{ 1536,\tPKE_RSA_DP1_1536 },\n-\t\t{ 2048,\tPKE_RSA_DP1_2048 },\n-\t\t{ 3072,\tPKE_RSA_DP1_3072 },\n-\t\t{ 4096,\tPKE_RSA_DP1_4096 },\n-};\n+static struct qat_asym_function\n+get_modinv_function(struct rte_crypto_asym_xform *xform)\n+{\n+\tstruct qat_asym_function qat_function = { };\n \n-static const uint32_t RSA_DEC_CRT_IDS[][2] = {\n-\t\t{ 512,\tPKE_RSA_DP2_512 },\n-\t\t{ 1024,\tPKE_RSA_DP2_1024 },\n-\t\t{ 1536,\tPKE_RSA_DP2_1536 },\n-\t\t{ 2048,\tPKE_RSA_DP2_2048 },\n-\t\t{ 3072,\tPKE_RSA_DP2_3072 },\n-\t\t{ 4096,\tPKE_RSA_DP2_4096 },\n-};\n+\tif (xform->modinv.modulus.data[\n+\t\txform->modinv.modulus.length - 1] & 0x01) {\n+\t\tif (xform->modex.modulus.length <= 16) {\n+\t\t\tqat_function.func_id = MATHS_MODINV_ODD_L128;\n+\t\t\tqat_function.bytesize = 16;\n+\t\t} else if (xform->modex.modulus.length <= 24) {\n+\t\t\tqat_function.func_id = MATHS_MODINV_ODD_L192;\n+\t\t\tqat_function.bytesize = 24;\n+\t\t} else if (xform->modex.modulus.length <= 32) {\n+\t\t\tqat_function.func_id = MATHS_MODINV_ODD_L256;\n+\t\t\tqat_function.bytesize = 32;\n+\t\t} else if (xform->modex.modulus.length <= 48) {\n+\t\t\tqat_function.func_id = MATHS_MODINV_ODD_L384;\n+\t\t\tqat_function.bytesize = 48;\n+\t\t} else if (xform->modex.modulus.length <= 64) {\n+\t\t\tqat_function.func_id = MATHS_MODINV_ODD_L512;\n+\t\t\tqat_function.bytesize = 64;\n+\t\t} else if (xform->modex.modulus.length <= 96) {\n+\t\t\tqat_function.func_id = MATHS_MODINV_ODD_L768;\n+\t\t\tqat_function.bytesize = 96;\n+\t\t} else if (xform->modex.modulus.length <= 128) {\n+\t\t\tqat_function.func_id = MATHS_MODINV_ODD_L1024;\n+\t\t\tqat_function.bytesize = 128;\n+\t\t} else if (xform->modex.modulus.length <= 192) {\n+\t\t\tqat_function.func_id = MATHS_MODINV_ODD_L1536;\n+\t\t\tqat_function.bytesize = 192;\n+\t\t} else if (xform->modex.modulus.length <= 256) {\n+\t\t\tqat_function.func_id = MATHS_MODINV_ODD_L2048;\n+\t\t\tqat_function.bytesize = 256;\n+\t\t} else if (xform->modex.modulus.length <= 384) {\n+\t\t\tqat_function.func_id = MATHS_MODINV_ODD_L3072;\n+\t\t\tqat_function.bytesize = 384;\n+\t\t} else if (xform->modex.modulus.length <= 512) {\n+\t\t\tqat_function.func_id = MATHS_MODINV_ODD_L4096;\n+\t\t\tqat_function.bytesize = 512;\n+\t\t}\n+\t} else {\n+\t\tif (xform->modex.modulus.length <= 16) {\n+\t\t\tqat_function.func_id = MATHS_MODINV_EVEN_L128;\n+\t\t\tqat_function.bytesize = 16;\n+\t\t} else if (xform->modex.modulus.length <= 24) {\n+\t\t\tqat_function.func_id = MATHS_MODINV_EVEN_L192;\n+\t\t\tqat_function.bytesize = 24;\n+\t\t} else if (xform->modex.modulus.length <= 32) {\n+\t\t\tqat_function.func_id = MATHS_MODINV_EVEN_L256;\n+\t\t\tqat_function.bytesize = 32;\n+\t\t} else if (xform->modex.modulus.length <= 48) {\n+\t\t\tqat_function.func_id = MATHS_MODINV_EVEN_L384;\n+\t\t\tqat_function.bytesize = 48;\n+\t\t} else if (xform->modex.modulus.length <= 64) {\n+\t\t\tqat_function.func_id = MATHS_MODINV_EVEN_L512;\n+\t\t\tqat_function.bytesize = 64;\n+\t\t} else if (xform->modex.modulus.length <= 96) {\n+\t\t\tqat_function.func_id = MATHS_MODINV_EVEN_L768;\n+\t\t\tqat_function.bytesize = 96;\n+\t\t} else if (xform->modex.modulus.length <= 128) {\n+\t\t\tqat_function.func_id = MATHS_MODINV_EVEN_L1024;\n+\t\t\tqat_function.bytesize = 128;\n+\t\t} else if (xform->modex.modulus.length <= 192) {\n+\t\t\tqat_function.func_id = MATHS_MODINV_EVEN_L1536;\n+\t\t\tqat_function.bytesize = 192;\n+\t\t} else if (xform->modex.modulus.length <= 256) {\n+\t\t\tqat_function.func_id = MATHS_MODINV_EVEN_L2048;\n+\t\t\tqat_function.bytesize = 256;\n+\t\t} else if (xform->modex.modulus.length <= 384) {\n+\t\t\tqat_function.func_id = MATHS_MODINV_EVEN_L3072;\n+\t\t\tqat_function.bytesize = 384;\n+\t\t} else if (xform->modex.modulus.length <= 512) {\n+\t\t\tqat_function.func_id = MATHS_MODINV_EVEN_L4096;\n+\t\t\tqat_function.bytesize = 512;\n+\t\t}\n+\t}\n+\n+\treturn qat_function;\n+}\n+\n+static struct qat_asym_function\n+get_rsa_enc_function(struct rte_crypto_asym_xform *xform)\n+{\n+\tstruct qat_asym_function qat_function = { };\n+\n+\tif (xform->rsa.n.length <= 64) {\n+\t\tqat_function.func_id = PKE_RSA_EP_512;\n+\t\tqat_function.bytesize = 64;\n+\t} else if (xform->rsa.n.length <= 128) {\n+\t\tqat_function.func_id = PKE_RSA_EP_1024;\n+\t\tqat_function.bytesize = 128;\n+\t} else if (xform->rsa.n.length <= 192) {\n+\t\tqat_function.func_id = PKE_RSA_EP_1536;\n+\t\tqat_function.bytesize = 192;\n+\t} else if (xform->rsa.n.length <= 256) {\n+\t\tqat_function.func_id = PKE_RSA_EP_2048;\n+\t\tqat_function.bytesize = 256;\n+\t} else if (xform->rsa.n.length <= 384) {\n+\t\tqat_function.func_id = PKE_RSA_EP_3072;\n+\t\tqat_function.bytesize = 384;\n+\t} else if (xform->rsa.n.length <= 512) {\n+\t\tqat_function.func_id = PKE_RSA_EP_4096;\n+\t\tqat_function.bytesize = 512;\n+\t}\n+\treturn qat_function;\n+}\n+\n+static struct qat_asym_function\n+get_rsa_dec_function(struct rte_crypto_asym_xform *xform)\n+{\n+\tstruct qat_asym_function qat_function = { };\n+\n+\tif (xform->rsa.n.length <= 64) {\n+\t\tqat_function.func_id = PKE_RSA_DP1_512;\n+\t\tqat_function.bytesize = 64;\n+\t} else if (xform->rsa.n.length <= 128) {\n+\t\tqat_function.func_id = PKE_RSA_DP1_1024;\n+\t\tqat_function.bytesize = 128;\n+\t} else if (xform->rsa.n.length <= 192) {\n+\t\tqat_function.func_id = PKE_RSA_DP1_1536;\n+\t\tqat_function.bytesize = 192;\n+\t} else if (xform->rsa.n.length <= 256) {\n+\t\tqat_function.func_id = PKE_RSA_DP1_2048;\n+\t\tqat_function.bytesize = 256;\n+\t} else if (xform->rsa.n.length <= 384) {\n+\t\tqat_function.func_id = PKE_RSA_DP1_3072;\n+\t\tqat_function.bytesize = 384;\n+\t} else if (xform->rsa.n.length <= 512) {\n+\t\tqat_function.func_id = PKE_RSA_DP1_4096;\n+\t\tqat_function.bytesize = 512;\n+\t}\n+\treturn qat_function;\n+}\n+\n+static struct qat_asym_function\n+get_rsa_crt_function(struct rte_crypto_asym_xform *xform)\n+{\n+\tstruct qat_asym_function qat_function = { };\n+\tint nlen = xform->rsa.qt.p.length * 2;\n+\n+\tif (nlen <= 64) {\n+\t\tqat_function.func_id = PKE_RSA_DP2_512;\n+\t\tqat_function.bytesize = 64;\n+\t} else if (nlen <= 128) {\n+\t\tqat_function.func_id = PKE_RSA_DP2_1024;\n+\t\tqat_function.bytesize = 128;\n+\t} else if (nlen <= 192) {\n+\t\tqat_function.func_id = PKE_RSA_DP2_1536;\n+\t\tqat_function.bytesize = 192;\n+\t} else if (nlen <= 256) {\n+\t\tqat_function.func_id = PKE_RSA_DP2_2048;\n+\t\tqat_function.bytesize = 256;\n+\t} else if (nlen <= 384) {\n+\t\tqat_function.func_id = PKE_RSA_DP2_3072;\n+\t\tqat_function.bytesize = 384;\n+\t} else if (nlen <= 512) {\n+\t\tqat_function.func_id = PKE_RSA_DP2_4096;\n+\t\tqat_function.bytesize = 512;\n+\t}\n+\treturn qat_function;\n+}\n \n #endif\ndiff --git a/drivers/crypto/qat/dev/qat_asym_pmd_gen1.c b/drivers/crypto/qat/dev/qat_asym_pmd_gen1.c\nindex 9ed1f21d9d..c3cee42c28 100644\n--- a/drivers/crypto/qat/dev/qat_asym_pmd_gen1.c\n+++ b/drivers/crypto/qat/dev/qat_asym_pmd_gen1.c\n@@ -7,7 +7,6 @@\n #include \"qat_asym.h\"\n #include \"qat_crypto.h\"\n #include \"qat_crypto_pmd_gens.h\"\n-#include \"qat_pke_functionality_arrays.h\"\n \n struct rte_cryptodev_ops qat_asym_crypto_ops_gen1 = {\n \t/* Device related operations */\ndiff --git a/drivers/crypto/qat/qat_asym.c b/drivers/crypto/qat/qat_asym.c\nindex f893508030..7fb4b0205a 100644\n--- a/drivers/crypto/qat/qat_asym.c\n+++ b/drivers/crypto/qat/qat_asym.c\n@@ -9,62 +9,52 @@\n #include \"icp_qat_fw.h\"\n #include \"qat_pke_functionality_arrays.h\"\n \n-#define qat_asym_sz_2param(arg) (arg, sizeof(arg)/sizeof(*arg))\n-\n-static int qat_asym_get_sz_and_func_id(const uint32_t arr[][2],\n-\t\tsize_t arr_sz, size_t *size, uint32_t *func_id)\n-{\n-\tsize_t i;\n-\n-\tfor (i = 0; i < arr_sz; i++) {\n-\t\tif (*size <= arr[i][0]) {\n-\t\t\t*size = arr[i][0];\n-\t\t\t*func_id = arr[i][1];\n-\t\t\treturn 0;\n-\t\t}\n-\t}\n-\treturn -1;\n-}\n+#if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG\n+#define HEXDUMP(name, where, size) QAT_DP_HEXDUMP_LOG(DEBUG, name, \\\n+\t\t\twhere, size)\n+#define HEXDUMP_OFF(name, where, size, idx) QAT_DP_HEXDUMP_LOG(DEBUG, name, \\\n+\t\t\t&where[idx * size], size)\n+#else\n+#define HEXDUMP(name, where, size)\n+#define HEXDUMP_OFF(name, where, size, idx)\n+#endif\n \n-static inline void qat_fill_req_tmpl(struct icp_qat_fw_pke_request *qat_req)\n+#define CHECK_IF_NOT_EMPTY(param, name, pname, status) \\\n+\tdo { \\\n+\t\tif (param.length == 0) {\t\\\n+\t\t\tQAT_LOG(ERR,\t\t\t\\\n+\t\t\t\t\"Invalid \" name\t\\\n+\t\t\t\t\" input parameter, zero length \" pname\t\\\n+\t\t\t);\t\\\n+\t\t\tstatus = -EINVAL;\t\\\n+\t\t} else if (check_zero(param)) { \\\n+\t\t\tQAT_LOG(ERR,\t\\\n+\t\t\t\t\"Invalid \" name \" input parameter, empty \" \\\n+\t\t\t\tpname \", length = %d\", \\\n+\t\t\t\t(int)param.length \\\n+\t\t\t); \\\n+\t\t\tstatus = -EINVAL;\t\\\n+\t\t} \\\n+\t} while (0)\n+\n+#define SET_PKE_LN(where, what, how, idx) \\\n+\trte_memcpy(where[idx] + how - \\\n+\t\twhat.length, \\\n+\t\twhat.data, \\\n+\t\twhat.length)\n+\n+static void\n+request_init(struct icp_qat_fw_pke_request *qat_req)\n {\n \tmemset(qat_req, 0, sizeof(*qat_req));\n \tqat_req->pke_hdr.service_type = ICP_QAT_FW_COMN_REQ_CPM_FW_PKE;\n-\n \tqat_req->pke_hdr.hdr_flags =\n \t\t\tICP_QAT_FW_COMN_HDR_FLAGS_BUILD\n \t\t\t(ICP_QAT_FW_COMN_REQ_FLAG_SET);\n }\n \n-static inline void qat_asym_build_req_tmpl(void *sess_private_data)\n-{\n-\tstruct icp_qat_fw_pke_request *qat_req;\n-\tstruct qat_asym_session *session = sess_private_data;\n-\n-\tqat_req = &session->req_tmpl;\n-\tqat_fill_req_tmpl(qat_req);\n-}\n-\n-static size_t max_of(int n, ...)\n-{\n-\tva_list args;\n-\tsize_t len = 0, num;\n-\tint i;\n-\n-\tva_start(args, n);\n-\tlen = va_arg(args, size_t);\n-\n-\tfor (i = 0; i < n - 1; i++) {\n-\t\tnum = va_arg(args, size_t);\n-\t\tif (num > len)\n-\t\t\tlen = num;\n-\t}\n-\tva_end(args);\n-\n-\treturn len;\n-}\n-\n-static void qat_clear_arrays(struct qat_asym_op_cookie *cookie,\n+static void\n+cleanup_arrays(struct qat_asym_op_cookie *cookie,\n \t\tint in_count, int out_count, int alg_size)\n {\n \tint i;\n@@ -75,7 +65,8 @@ static void qat_clear_arrays(struct qat_asym_op_cookie *cookie,\n \t\tmemset(cookie->output_array[i], 0x0, alg_size);\n }\n \n-static void qat_clear_arrays_crt(struct qat_asym_op_cookie *cookie,\n+static void\n+cleanup_crt(struct qat_asym_op_cookie *cookie,\n \t\tint alg_size)\n {\n \tint i;\n@@ -87,432 +78,503 @@ static void qat_clear_arrays_crt(struct qat_asym_op_cookie *cookie,\n \t\tmemset(cookie->output_array[i], 0x0, alg_size);\n }\n \n-static void qat_clear_arrays_by_alg(struct qat_asym_op_cookie *cookie,\n+static void\n+cleanup(struct qat_asym_op_cookie *cookie,\n \t\tstruct rte_crypto_asym_xform *xform, int alg_size)\n {\n \tif (xform->xform_type == RTE_CRYPTO_ASYM_XFORM_MODEX)\n-\t\tqat_clear_arrays(cookie, QAT_ASYM_MODEXP_NUM_IN_PARAMS,\n+\t\tcleanup_arrays(cookie, QAT_ASYM_MODEXP_NUM_IN_PARAMS,\n \t\t\t\tQAT_ASYM_MODEXP_NUM_OUT_PARAMS, alg_size);\n \telse if (xform->xform_type == RTE_CRYPTO_ASYM_XFORM_MODINV)\n-\t\tqat_clear_arrays(cookie, QAT_ASYM_MODINV_NUM_IN_PARAMS,\n+\t\tcleanup_arrays(cookie, QAT_ASYM_MODINV_NUM_IN_PARAMS,\n \t\t\t\tQAT_ASYM_MODINV_NUM_OUT_PARAMS, alg_size);\n \telse if (xform->xform_type == RTE_CRYPTO_ASYM_XFORM_RSA) {\n \t\tif (xform->rsa.key_type == RTE_RSA_KET_TYPE_QT)\n-\t\t\tqat_clear_arrays_crt(cookie, alg_size);\n+\t\t\tcleanup_crt(cookie, alg_size);\n \t\telse {\n-\t\t\tqat_clear_arrays(cookie, QAT_ASYM_RSA_NUM_IN_PARAMS,\n+\t\t\tcleanup_arrays(cookie, QAT_ASYM_RSA_NUM_IN_PARAMS,\n \t\t\t\tQAT_ASYM_RSA_NUM_OUT_PARAMS, alg_size);\n \t\t}\n \t}\n }\n \n-static int qat_asym_check_nonzero(rte_crypto_param n)\n+static inline void qat_asym_build_req_tmpl(void *sess_private_data)\n+{\n+\tstruct icp_qat_fw_pke_request *qat_req;\n+\tstruct qat_asym_session *session = sess_private_data;\n+\n+\tqat_req = &session->req_tmpl;\n+\trequest_init(qat_req);\n+}\n+\n+static int\n+check_zero(rte_crypto_param n)\n {\n+\tint i;\n+\tint len = n.length;\n+\n \tif (n.length < 8) {\n-\t\t/* Not a case for any cryptograpic function except for DH\n-\t\t * generator which very often can be of one byte length\n-\t\t */\n-\t\tsize_t i;\n-\n-\t\tif (n.data[n.length - 1] == 0x0) {\n-\t\t\tfor (i = 0; i < n.length - 1; i++)\n-\t\t\t\tif (n.data[i] != 0x0)\n-\t\t\t\t\tbreak;\n-\t\t\tif (i == n.length - 1)\n-\t\t\t\treturn -(EINVAL);\n+\t\tfor (i = len - 1; i >= 0; i--) {\n+\t\t\tif (n.data[i] != 0x0)\n+\t\t\t\treturn 0;\n \t\t}\n-\t} else if (*(uint64_t *)&n.data[\n-\t\t\t\tn.length - 8] == 0) {\n-\t\t/* Very likely it is zeroed modulus */\n-\t\tsize_t i;\n-\n-\t\tfor (i = 0; i < n.length - 8; i++)\n+\t} else if (len == 8 && *(uint64_t *)&n.data[n.length - 8] == 0) {\n+\t\treturn 1;\n+\t} else if (*(uint64_t *)&n.data[n.length - 8] == 0) {\n+\t\tfor (i = len - 9; i >= 0; i--) {\n \t\t\tif (n.data[i] != 0x0)\n-\t\t\t\tbreak;\n-\t\tif (i == n.length - 8)\n-\t\t\treturn -(EINVAL);\n+\t\t\t\treturn 0;\n+\t\t}\n+\t} else\n+\t\treturn 0;\n+\n+\treturn 1;\n+}\n+\n+static struct qat_asym_function\n+get_asym_function(struct rte_crypto_asym_xform *xform)\n+{\n+\tstruct qat_asym_function qat_function;\n+\n+\tswitch (xform->xform_type) {\n+\tcase RTE_CRYPTO_ASYM_XFORM_MODEX:\n+\t\tqat_function = get_modexp_function(xform);\n+\t\tbreak;\n+\tcase RTE_CRYPTO_ASYM_XFORM_MODINV:\n+\t\tqat_function = get_modinv_function(xform);\n+\t\tbreak;\n+\tdefault:\n+\t\tqat_function.func_id = 0;\n+\t\tbreak;\n \t}\n \n-\treturn 0;\n+\treturn qat_function;\n }\n \n static int\n-qat_asym_fill_arrays(struct rte_crypto_asym_op *asym_op,\n+modexp_set_input(struct rte_crypto_asym_op *asym_op,\n \t\tstruct icp_qat_fw_pke_request *qat_req,\n \t\tstruct qat_asym_op_cookie *cookie,\n \t\tstruct rte_crypto_asym_xform *xform)\n {\n-\tint err = 0;\n-\tsize_t alg_size;\n-\tsize_t alg_size_in_bytes;\n-\tuint32_t func_id = 0;\n+\tint status = 0;\n+\tuint32_t alg_bytesize;\n+\tuint32_t func_id;\n+\tstruct qat_asym_function qat_function;\n+\n+\tCHECK_IF_NOT_EMPTY(xform->modex.modulus, \"mod exp\",\n+\t\t\t\"modulus\", status);\n+\tCHECK_IF_NOT_EMPTY(xform->modex.exponent, \"mod exp\",\n+\t\t\t\t\"exponent\", status);\n+\tif (status)\n+\t\treturn status;\n+\n+\tqat_function = get_asym_function(xform);\n+\tfunc_id = qat_function.func_id;\n+\tif (qat_function.func_id == 0) {\n+\t\tQAT_LOG(ERR, \"Cannot obtain functionality id\");\n+\t\treturn -EINVAL;\n+\t}\n+\talg_bytesize = qat_function.bytesize;\n \n-\tif (xform->xform_type == RTE_CRYPTO_ASYM_XFORM_MODEX) {\n-\t\terr = qat_asym_check_nonzero(xform->modex.modulus);\n-\t\tif (err) {\n-\t\t\tQAT_LOG(ERR, \"Empty modulus in modular exponentiation,\"\n-\t\t\t\t\t\" aborting this operation\");\n-\t\t\treturn err;\n-\t\t}\n+\tSET_PKE_LN(cookie->input_array, asym_op->modex.base,\n+\t\t\talg_bytesize, 0);\n+\tSET_PKE_LN(cookie->input_array, xform->modex.exponent,\n+\t\t\talg_bytesize, 1);\n+\tSET_PKE_LN(cookie->input_array, xform->modex.modulus,\n+\t\t\talg_bytesize, 2);\n \n-\t\talg_size_in_bytes = max_of(3, asym_op->modex.base.length,\n-\t\t\t       xform->modex.exponent.length,\n-\t\t\t       xform->modex.modulus.length);\n-\t\talg_size = alg_size_in_bytes << 3;\n+\tcookie->alg_bytesize = alg_bytesize;\n+\tqat_req->pke_hdr.cd_pars.func_id = func_id;\n+\tqat_req->input_param_count = QAT_ASYM_MODEXP_NUM_IN_PARAMS;\n+\tqat_req->output_param_count = QAT_ASYM_MODEXP_NUM_OUT_PARAMS;\n \n-\t\tif (qat_asym_get_sz_and_func_id(MOD_EXP_SIZE,\n-\t\t\t\tsizeof(MOD_EXP_SIZE)/sizeof(*MOD_EXP_SIZE),\n-\t\t\t\t&alg_size, &func_id)) {\n-\t\t\treturn -(EINVAL);\n+\tHEXDUMP(\"ModExp base\", cookie->input_array[0], alg_bytesize);\n+\tHEXDUMP(\"ModExp exponent\", cookie->input_array[1], alg_bytesize);\n+\tHEXDUMP(\"ModExp modulus\", cookie->input_array[2], alg_bytesize);\n+\n+\treturn status;\n+}\n+\n+static uint8_t\n+modexp_collect(struct rte_crypto_asym_op *asym_op,\n+\t\tstruct qat_asym_op_cookie *cookie,\n+\t\tstruct rte_crypto_asym_xform *xform)\n+{\n+\trte_crypto_param n = xform->modex.modulus;\n+\tuint32_t alg_bytesize = cookie->alg_bytesize;\n+\tuint8_t *modexp_result = asym_op->modex.result.data;\n+\n+\trte_memcpy(modexp_result,\n+\t\tcookie->output_array[0] + alg_bytesize\n+\t\t- n.length, n.length);\n+\tHEXDUMP(\"ModExp result\", cookie->output_array[0],\n+\t\t\talg_bytesize);\n+\treturn RTE_CRYPTO_OP_STATUS_SUCCESS;\n+}\n+\n+static int\n+modinv_set_input(struct rte_crypto_asym_op *asym_op,\n+\t\tstruct icp_qat_fw_pke_request *qat_req,\n+\t\tstruct qat_asym_op_cookie *cookie,\n+\t\tstruct rte_crypto_asym_xform *xform)\n+{\n+\tint status = 0;\n+\tuint32_t alg_bytesize;\n+\tuint32_t func_id;\n+\tstruct qat_asym_function qat_function;\n+\n+\tCHECK_IF_NOT_EMPTY(xform->modex.modulus, \"mod inv\",\n+\t\t\t\"modulus\", status);\n+\tif (status)\n+\t\treturn status;\n+\n+\tqat_function = get_asym_function(xform);\n+\tfunc_id = qat_function.func_id;\n+\tif (func_id == 0) {\n+\t\tQAT_LOG(ERR, \"Cannot obtain functionality id\");\n+\t\treturn -EINVAL;\n+\t}\n+\talg_bytesize = qat_function.bytesize;\n+\n+\tSET_PKE_LN(cookie->input_array, asym_op->modinv.base,\n+\t\t\talg_bytesize, 0);\n+\tSET_PKE_LN(cookie->input_array, xform->modinv.modulus,\n+\t\t\talg_bytesize, 1);\n+\n+\tcookie->alg_bytesize = alg_bytesize;\n+\tqat_req->pke_hdr.cd_pars.func_id = func_id;\n+\tqat_req->input_param_count =\n+\t\t\tQAT_ASYM_MODINV_NUM_IN_PARAMS;\n+\tqat_req->output_param_count =\n+\t\t\tQAT_ASYM_MODINV_NUM_OUT_PARAMS;\n+\n+\tHEXDUMP(\"ModInv base\", cookie->input_array[0], alg_bytesize);\n+\tHEXDUMP(\"ModInv modulus\", cookie->input_array[1], alg_bytesize);\n+\n+\treturn 0;\n+}\n+\n+static uint8_t\n+modinv_collect(struct rte_crypto_asym_op *asym_op,\n+\t\tstruct qat_asym_op_cookie *cookie,\n+\t\tstruct rte_crypto_asym_xform *xform)\n+{\n+\trte_crypto_param n = xform->modinv.modulus;\n+\tuint32_t alg_bytesize = cookie->alg_bytesize;\n+\tuint8_t *modinv_result = asym_op->modinv.result.data;\n+\n+\trte_memcpy(modinv_result + (asym_op->modinv.result.length\n+\t\t- n.length),\n+\t\tcookie->output_array[0] + alg_bytesize\n+\t\t- n.length, n.length);\n+\tHEXDUMP(\"ModInv result\", cookie->output_array[0],\n+\t\t\talg_bytesize);\n+\treturn RTE_CRYPTO_OP_STATUS_SUCCESS;\n+}\n+\n+static int\n+rsa_set_pub_input(struct rte_crypto_asym_op *asym_op,\n+\t\tstruct icp_qat_fw_pke_request *qat_req,\n+\t\tstruct qat_asym_op_cookie *cookie,\n+\t\tstruct rte_crypto_asym_xform *xform)\n+{\n+\tint status = 0;\n+\tuint32_t alg_bytesize;\n+\tuint32_t func_id;\n+\tstruct qat_asym_function qat_function;\n+\n+\tqat_function = get_rsa_enc_function(xform);\n+\tfunc_id = qat_function.func_id;\n+\tif (func_id == 0) {\n+\t\tQAT_LOG(ERR, \"Cannot obtain functionality id\");\n+\t\treturn -EINVAL;\n+\t}\n+\talg_bytesize = qat_function.bytesize;\n+\n+\tif (asym_op->rsa.op_type == RTE_CRYPTO_ASYM_OP_ENCRYPT) {\n+\t\tswitch (asym_op->rsa.pad) {\n+\t\tcase RTE_CRYPTO_RSA_PADDING_NONE:\n+\t\t\tSET_PKE_LN(cookie->input_array, asym_op->rsa.message,\n+\t\t\t\t\talg_bytesize, 0);\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\tQAT_LOG(ERR,\n+\t\t\t\t\"Invalid RSA padding (Encryption)\"\n+\t\t\t\t);\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\t\tHEXDUMP(\"RSA Message\", cookie->input_array[0], alg_bytesize);\n+\t} else {\n+\t\tswitch (asym_op->rsa.pad) {\n+\t\tcase RTE_CRYPTO_RSA_PADDING_NONE:\n+\t\t\tSET_PKE_LN(cookie->input_array, asym_op->rsa.sign,\n+\t\t\t\t\talg_bytesize, 0);\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\tQAT_LOG(ERR,\n+\t\t\t\t\"Invalid RSA padding (Verify)\");\n+\t\t\treturn -EINVAL;\n \t\t}\n+\t\tHEXDUMP(\"RSA Signature\", cookie->input_array[0],\n+\t\t\t\talg_bytesize);\n+\t}\n \n-\t\talg_size_in_bytes = alg_size >> 3;\n-\t\trte_memcpy(cookie->input_array[0] + alg_size_in_bytes -\n-\t\t\tasym_op->modex.base.length\n-\t\t\t, asym_op->modex.base.data,\n-\t\t\tasym_op->modex.base.length);\n-\t\trte_memcpy(cookie->input_array[1] + alg_size_in_bytes -\n-\t\t\txform->modex.exponent.length\n-\t\t\t, xform->modex.exponent.data,\n-\t\t\txform->modex.exponent.length);\n-\t\trte_memcpy(cookie->input_array[2]  + alg_size_in_bytes -\n-\t\t\txform->modex.modulus.length,\n-\t\t\txform->modex.modulus.data,\n-\t\t\txform->modex.modulus.length);\n-\t\tcookie->alg_size = alg_size;\n-\t\tqat_req->pke_hdr.cd_pars.func_id = func_id;\n-\t\tqat_req->input_param_count = QAT_ASYM_MODEXP_NUM_IN_PARAMS;\n-\t\tqat_req->output_param_count = QAT_ASYM_MODEXP_NUM_OUT_PARAMS;\n-#if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG\n-\t\tQAT_DP_HEXDUMP_LOG(DEBUG, \"ModExp base\",\n-\t\t\t\tcookie->input_array[0],\n-\t\t\t\talg_size_in_bytes);\n-\t\tQAT_DP_HEXDUMP_LOG(DEBUG, \"ModExp exponent\",\n-\t\t\t\tcookie->input_array[1],\n-\t\t\t\talg_size_in_bytes);\n-\t\tQAT_DP_HEXDUMP_LOG(DEBUG, \" ModExpmodulus\",\n-\t\t\t\tcookie->input_array[2],\n-\t\t\t\talg_size_in_bytes);\n-#endif\n-\t} else if (xform->xform_type == RTE_CRYPTO_ASYM_XFORM_MODINV) {\n-\t\terr = qat_asym_check_nonzero(xform->modinv.modulus);\n-\t\tif (err) {\n-\t\t\tQAT_LOG(ERR, \"Empty modulus in modular multiplicative\"\n-\t\t\t\t\t\" inverse, aborting this operation\");\n-\t\t\treturn err;\n+\tSET_PKE_LN(cookie->input_array, xform->rsa.e,\n+\t\t\talg_bytesize, 1);\n+\tSET_PKE_LN(cookie->input_array, xform->rsa.n,\n+\t\t\talg_bytesize, 2);\n+\n+\tcookie->alg_bytesize = alg_bytesize;\n+\tqat_req->pke_hdr.cd_pars.func_id = func_id;\n+\n+\tHEXDUMP(\"RSA Public Key\", cookie->input_array[1], alg_bytesize);\n+\tHEXDUMP(\"RSA Modulus\", cookie->input_array[2], alg_bytesize);\n+\n+\treturn status;\n+}\n+\n+static int\n+rsa_set_priv_input(struct rte_crypto_asym_op *asym_op,\n+\t\tstruct icp_qat_fw_pke_request *qat_req,\n+\t\tstruct qat_asym_op_cookie *cookie,\n+\t\tstruct rte_crypto_asym_xform *xform)\n+{\n+\tint status = 0;\n+\tuint32_t alg_bytesize;\n+\tuint32_t func_id;\n+\tstruct qat_asym_function qat_function;\n+\n+\tif (xform->rsa.key_type == RTE_RSA_KET_TYPE_QT) {\n+\t\tqat_function = get_rsa_crt_function(xform);\n+\t\tfunc_id = qat_function.func_id;\n+\t\tif (func_id == 0) {\n+\t\t\tQAT_LOG(ERR, \"Cannot obtain functionality id\");\n+\t\t\treturn -EINVAL;\n \t\t}\n+\t\talg_bytesize = qat_function.bytesize;\n+\t\tqat_req->input_param_count =\n+\t\t\t\tQAT_ASYM_RSA_QT_NUM_IN_PARAMS;\n+\n+\t\tSET_PKE_LN(cookie->input_array, xform->rsa.qt.p,\n+\t\t\t(alg_bytesize >> 1), 1);\n+\t\tSET_PKE_LN(cookie->input_array, xform->rsa.qt.q,\n+\t\t\t(alg_bytesize >> 1), 2);\n+\t\tSET_PKE_LN(cookie->input_array, xform->rsa.qt.dP,\n+\t\t\t(alg_bytesize >> 1), 3);\n+\t\tSET_PKE_LN(cookie->input_array, xform->rsa.qt.dQ,\n+\t\t\t(alg_bytesize >> 1), 4);\n+\t\tSET_PKE_LN(cookie->input_array, xform->rsa.qt.qInv,\n+\t\t\t(alg_bytesize >> 1), 5);\n+\n+\t\tHEXDUMP(\"RSA p\", cookie->input_array[1],\n+\t\t\t\talg_bytesize);\n+\t\tHEXDUMP(\"RSA q\", cookie->input_array[2],\n+\t\t\t\talg_bytesize);\n+\t\tHEXDUMP(\"RSA dP\", cookie->input_array[3],\n+\t\t\t\talg_bytesize);\n+\t\tHEXDUMP(\"RSA dQ\", cookie->input_array[4],\n+\t\t\t\talg_bytesize);\n+\t\tHEXDUMP(\"RSA qInv\", cookie->input_array[5],\n+\t\t\t\talg_bytesize);\n+\t} else if (xform->rsa.key_type ==\n+\t\t\tRTE_RSA_KEY_TYPE_EXP) {\n+\t\tqat_function = get_rsa_dec_function(xform);\n+\t\tfunc_id = qat_function.func_id;\n+\t\tif (func_id == 0) {\n+\t\t\tQAT_LOG(ERR, \"Cannot obtain functionality id\");\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\t\talg_bytesize = qat_function.bytesize;\n \n-\t\talg_size_in_bytes = max_of(2, asym_op->modinv.base.length,\n-\t\t\t\txform->modinv.modulus.length);\n-\t\talg_size = alg_size_in_bytes << 3;\n-\n-\t\tif (xform->modinv.modulus.data[\n-\t\t\t\txform->modinv.modulus.length - 1] & 0x01) {\n-\t\t\tif (qat_asym_get_sz_and_func_id(MOD_INV_IDS_ODD,\n-\t\t\t\t\tsizeof(MOD_INV_IDS_ODD)/\n-\t\t\t\t\tsizeof(*MOD_INV_IDS_ODD),\n-\t\t\t\t\t&alg_size, &func_id)) {\n-\t\t\t\treturn -(EINVAL);\n-\t\t\t}\n-\t\t} else {\n-\t\t\tif (qat_asym_get_sz_and_func_id(MOD_INV_IDS_EVEN,\n-\t\t\t\t\tsizeof(MOD_INV_IDS_EVEN)/\n-\t\t\t\t\tsizeof(*MOD_INV_IDS_EVEN),\n-\t\t\t\t\t&alg_size, &func_id)) {\n-\t\t\t\treturn -(EINVAL);\n-\t\t\t}\n+\t\tSET_PKE_LN(cookie->input_array, xform->rsa.d,\n+\t\t\talg_bytesize, 1);\n+\t\tSET_PKE_LN(cookie->input_array, xform->rsa.n,\n+\t\t\talg_bytesize, 2);\n+\n+\t\tHEXDUMP(\"RSA d\", cookie->input_array[1],\n+\t\t\t\talg_bytesize);\n+\t\tHEXDUMP(\"RSA n\", cookie->input_array[2],\n+\t\t\t\talg_bytesize);\n+\t} else {\n+\t\tQAT_LOG(ERR, \"Invalid RSA key type\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (asym_op->rsa.op_type ==\n+\t\t\tRTE_CRYPTO_ASYM_OP_DECRYPT) {\n+\t\tswitch (asym_op->rsa.pad) {\n+\t\tcase RTE_CRYPTO_RSA_PADDING_NONE:\n+\t\t\tSET_PKE_LN(cookie->input_array, asym_op->rsa.cipher,\n+\t\t\t\talg_bytesize, 0);\n+\t\t\tHEXDUMP(\"RSA ciphertext\", cookie->input_array[0],\n+\t\t\t\talg_bytesize);\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\tQAT_LOG(ERR,\n+\t\t\t\t\"Invalid padding of RSA (Decrypt)\");\n+\t\t\treturn -(EINVAL);\n \t\t}\n \n-\t\talg_size_in_bytes = alg_size >> 3;\n-\t\trte_memcpy(cookie->input_array[0] + alg_size_in_bytes -\n-\t\t\tasym_op->modinv.base.length\n-\t\t\t\t, asym_op->modinv.base.data,\n-\t\t\t\tasym_op->modinv.base.length);\n-\t\trte_memcpy(cookie->input_array[1] + alg_size_in_bytes -\n-\t\t\t\txform->modinv.modulus.length\n-\t\t\t\t, xform->modinv.modulus.data,\n-\t\t\t\txform->modinv.modulus.length);\n-\t\tcookie->alg_size = alg_size;\n-\t\tqat_req->pke_hdr.cd_pars.func_id = func_id;\n-\t\tqat_req->input_param_count =\n-\t\t\t\tQAT_ASYM_MODINV_NUM_IN_PARAMS;\n-\t\tqat_req->output_param_count =\n-\t\t\t\tQAT_ASYM_MODINV_NUM_OUT_PARAMS;\n-#if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG\n-\t\tQAT_DP_HEXDUMP_LOG(DEBUG, \"ModInv base\",\n-\t\t\t\tcookie->input_array[0],\n-\t\t\t\talg_size_in_bytes);\n-\t\tQAT_DP_HEXDUMP_LOG(DEBUG, \"ModInv modulus\",\n-\t\t\t\tcookie->input_array[1],\n-\t\t\t\talg_size_in_bytes);\n-#endif\n-\t} else if (xform->xform_type == RTE_CRYPTO_ASYM_XFORM_RSA) {\n-\t\terr = qat_asym_check_nonzero(xform->rsa.n);\n-\t\tif (err) {\n-\t\t\tQAT_LOG(ERR, \"Empty modulus in RSA\"\n-\t\t\t\t\t\" inverse, aborting this operation\");\n-\t\t\treturn err;\n+\t} else if (asym_op->rsa.op_type ==\n+\t\t\tRTE_CRYPTO_ASYM_OP_SIGN) {\n+\t\tswitch (asym_op->rsa.pad) {\n+\t\tcase RTE_CRYPTO_RSA_PADDING_NONE:\n+\t\t\tSET_PKE_LN(cookie->input_array, asym_op->rsa.message,\n+\t\t\t\talg_bytesize, 0);\n+\t\t\tHEXDUMP(\"RSA text to be signed\", cookie->input_array[0],\n+\t\t\t\talg_bytesize);\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\tQAT_LOG(ERR,\n+\t\t\t\t\"Invalid padding of RSA (Signature)\");\n+\t\t\treturn -(EINVAL);\n \t\t}\n+\t}\n \n-\t\talg_size_in_bytes = xform->rsa.n.length;\n-\t\talg_size = alg_size_in_bytes << 3;\n+\tcookie->alg_bytesize = alg_bytesize;\n+\tqat_req->pke_hdr.cd_pars.func_id = func_id;\n+\treturn status;\n+}\n \n-\t\tqat_req->input_param_count =\n-\t\t\t\tQAT_ASYM_RSA_NUM_IN_PARAMS;\n-\t\tqat_req->output_param_count =\n-\t\t\t\tQAT_ASYM_RSA_NUM_OUT_PARAMS;\n-\n-\t\tif (asym_op->rsa.op_type == RTE_CRYPTO_ASYM_OP_ENCRYPT ||\n-\t\t\t\tasym_op->rsa.op_type ==\n-\t\t\t\t\t\tRTE_CRYPTO_ASYM_OP_VERIFY) {\n-\n-\t\t\tif (qat_asym_get_sz_and_func_id(RSA_ENC_IDS,\n-\t\t\t\t\tsizeof(RSA_ENC_IDS)/\n-\t\t\t\t\tsizeof(*RSA_ENC_IDS),\n-\t\t\t\t\t&alg_size, &func_id)) {\n-\t\t\t\terr = -(EINVAL);\n-\t\t\t\tQAT_LOG(ERR,\n-\t\t\t\t\t\"Not supported RSA parameter size (key)\");\n-\t\t\t\treturn err;\n-\t\t\t}\n-\t\t\talg_size_in_bytes = alg_size >> 3;\n-\t\t\tif (asym_op->rsa.op_type == RTE_CRYPTO_ASYM_OP_ENCRYPT) {\n-\t\t\t\tswitch (asym_op->rsa.pad) {\n-\t\t\t\tcase RTE_CRYPTO_RSA_PADDING_NONE:\n-\t\t\t\t\trte_memcpy(cookie->input_array[0] +\n-\t\t\t\t\t\talg_size_in_bytes -\n-\t\t\t\t\t\tasym_op->rsa.message.length\n-\t\t\t\t\t\t, asym_op->rsa.message.data,\n-\t\t\t\t\t\tasym_op->rsa.message.length);\n-\t\t\t\t\tbreak;\n-\t\t\t\tdefault:\n-\t\t\t\t\terr = -(EINVAL);\n-\t\t\t\t\tQAT_LOG(ERR,\n-\t\t\t\t\t\t\"Invalid RSA padding (Encryption)\");\n-\t\t\t\t\treturn err;\n-\t\t\t\t}\n-#if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG\n-\t\t\t\tQAT_DP_HEXDUMP_LOG(DEBUG, \"RSA Message\",\n-\t\t\t\t\t\tcookie->input_array[0],\n-\t\t\t\t\t\talg_size_in_bytes);\n-#endif\n-\t\t\t} else {\n-\t\t\t\tswitch (asym_op->rsa.pad) {\n-\t\t\t\tcase RTE_CRYPTO_RSA_PADDING_NONE:\n-\t\t\t\t\trte_memcpy(cookie->input_array[0],\n-\t\t\t\t\t\tasym_op->rsa.sign.data,\n-\t\t\t\t\t\talg_size_in_bytes);\n-\t\t\t\t\tbreak;\n-\t\t\t\tdefault:\n-\t\t\t\t\terr = -(EINVAL);\n-\t\t\t\t\tQAT_LOG(ERR,\n-\t\t\t\t\t\t\"Invalid RSA padding (Verify)\");\n-\t\t\t\t\treturn err;\n-\t\t\t\t}\n+static int\n+rsa_set_input(struct rte_crypto_asym_op *asym_op,\n+\t\tstruct icp_qat_fw_pke_request *qat_req,\n+\t\tstruct qat_asym_op_cookie *cookie,\n+\t\tstruct rte_crypto_asym_xform *xform)\n+{\n+\tqat_req->input_param_count =\n+\t\t\tQAT_ASYM_RSA_NUM_IN_PARAMS;\n+\tqat_req->output_param_count =\n+\t\t\tQAT_ASYM_RSA_NUM_OUT_PARAMS;\n+\n+\tif (asym_op->rsa.op_type == RTE_CRYPTO_ASYM_OP_ENCRYPT ||\n+\t\t\tasym_op->rsa.op_type ==\n+\t\t\t\tRTE_CRYPTO_ASYM_OP_VERIFY) {\n+\t\treturn rsa_set_pub_input(asym_op, qat_req, cookie, xform);\n+\t} else {\n+\t\treturn rsa_set_priv_input(asym_op, qat_req, cookie, xform);\n+\t}\n+}\n \n-#if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG\n-\t\t\t\tQAT_DP_HEXDUMP_LOG(DEBUG, \" RSA Signature\",\n-\t\t\t\t\t\tcookie->input_array[0],\n-\t\t\t\t\t\talg_size_in_bytes);\n-#endif\n+static uint8_t\n+rsa_collect(struct rte_crypto_asym_op *asym_op,\n+\t\tstruct qat_asym_op_cookie *cookie)\n+{\n+\tuint32_t alg_bytesize = cookie->alg_bytesize;\n \n-\t\t\t}\n-\t\t\trte_memcpy(cookie->input_array[1] +\n-\t\t\t\t\talg_size_in_bytes -\n-\t\t\t\t\txform->rsa.e.length\n-\t\t\t\t\t, xform->rsa.e.data,\n-\t\t\t\t\txform->rsa.e.length);\n-\t\t\trte_memcpy(cookie->input_array[2] +\n-\t\t\t\t\talg_size_in_bytes -\n-\t\t\t\t\txform->rsa.n.length,\n-\t\t\t\t\txform->rsa.n.data,\n-\t\t\t\t\txform->rsa.n.length);\n-\n-\t\t\tcookie->alg_size = alg_size;\n-\t\t\tqat_req->pke_hdr.cd_pars.func_id = func_id;\n+\tif (asym_op->rsa.op_type == RTE_CRYPTO_ASYM_OP_ENCRYPT ||\n+\t\tasym_op->rsa.op_type ==\tRTE_CRYPTO_ASYM_OP_VERIFY) {\n \n-#if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG\n-\t\t\tQAT_DP_HEXDUMP_LOG(DEBUG, \"RSA Public Key\",\n-\t\t\t\t\tcookie->input_array[1], alg_size_in_bytes);\n-\t\t\tQAT_DP_HEXDUMP_LOG(DEBUG, \"RSA Modulus\",\n-\t\t\t\t\tcookie->input_array[2], alg_size_in_bytes);\n-#endif\n-\t\t} else {\n-\t\t\tif (asym_op->rsa.op_type ==\n-\t\t\t\t\tRTE_CRYPTO_ASYM_OP_DECRYPT) {\n-\t\t\t\tswitch (asym_op->rsa.pad) {\n-\t\t\t\tcase RTE_CRYPTO_RSA_PADDING_NONE:\n-\t\t\t\t\trte_memcpy(cookie->input_array[0]\n-\t\t\t\t\t\t+ alg_size_in_bytes -\n-\t\t\t\t\t\tasym_op->rsa.cipher.length,\n-\t\t\t\t\t\tasym_op->rsa.cipher.data,\n-\t\t\t\t\t\tasym_op->rsa.cipher.length);\n-\t\t\t\t\tbreak;\n-\t\t\t\tdefault:\n-\t\t\t\t\tQAT_LOG(ERR,\n-\t\t\t\t\t\t\"Invalid padding of RSA (Decrypt)\");\n-\t\t\t\t\treturn -(EINVAL);\n-\t\t\t\t}\n-\n-\t\t\t} else if (asym_op->rsa.op_type ==\n-\t\t\t\t\tRTE_CRYPTO_ASYM_OP_SIGN) {\n-\t\t\t\tswitch (asym_op->rsa.pad) {\n-\t\t\t\tcase RTE_CRYPTO_RSA_PADDING_NONE:\n-\t\t\t\t\trte_memcpy(cookie->input_array[0]\n-\t\t\t\t\t\t+ alg_size_in_bytes -\n-\t\t\t\t\t\tasym_op->rsa.message.length,\n-\t\t\t\t\t\tasym_op->rsa.message.data,\n-\t\t\t\t\t\tasym_op->rsa.message.length);\n-\t\t\t\t\tbreak;\n-\t\t\t\tdefault:\n-\t\t\t\t\tQAT_LOG(ERR,\n-\t\t\t\t\t\t\"Invalid padding of RSA (Signature)\");\n-\t\t\t\t\treturn -(EINVAL);\n-\t\t\t\t}\n-\t\t\t}\n-\t\t\tif (xform->rsa.key_type == RTE_RSA_KET_TYPE_QT) {\n-\n-\t\t\t\tqat_req->input_param_count =\n-\t\t\t\t\t\tQAT_ASYM_RSA_QT_NUM_IN_PARAMS;\n-\t\t\t\tif (qat_asym_get_sz_and_func_id(RSA_DEC_CRT_IDS,\n-\t\t\t\t\t\tsizeof(RSA_DEC_CRT_IDS)/\n-\t\t\t\t\t\tsizeof(*RSA_DEC_CRT_IDS),\n-\t\t\t\t\t\t&alg_size, &func_id)) {\n-\t\t\t\t\treturn -(EINVAL);\n-\t\t\t\t}\n-\t\t\t\talg_size_in_bytes = alg_size >> 3;\n-\n-\t\t\t\trte_memcpy(cookie->input_array[1] +\n-\t\t\t\t\t\t(alg_size_in_bytes >> 1) -\n-\t\t\t\t\t\txform->rsa.qt.p.length\n-\t\t\t\t\t\t, xform->rsa.qt.p.data,\n-\t\t\t\t\t\txform->rsa.qt.p.length);\n-\t\t\t\trte_memcpy(cookie->input_array[2] +\n-\t\t\t\t\t\t(alg_size_in_bytes >> 1) -\n-\t\t\t\t\t\txform->rsa.qt.q.length\n-\t\t\t\t\t\t, xform->rsa.qt.q.data,\n-\t\t\t\t\t\txform->rsa.qt.q.length);\n-\t\t\t\trte_memcpy(cookie->input_array[3] +\n-\t\t\t\t\t\t(alg_size_in_bytes >> 1) -\n-\t\t\t\t\t\txform->rsa.qt.dP.length\n-\t\t\t\t\t\t, xform->rsa.qt.dP.data,\n-\t\t\t\t\t\txform->rsa.qt.dP.length);\n-\t\t\t\trte_memcpy(cookie->input_array[4] +\n-\t\t\t\t\t\t(alg_size_in_bytes >> 1) -\n-\t\t\t\t\t\txform->rsa.qt.dQ.length\n-\t\t\t\t\t\t, xform->rsa.qt.dQ.data,\n-\t\t\t\t\t\txform->rsa.qt.dQ.length);\n-\t\t\t\trte_memcpy(cookie->input_array[5] +\n-\t\t\t\t\t\t(alg_size_in_bytes >> 1) -\n-\t\t\t\t\t\txform->rsa.qt.qInv.length\n-\t\t\t\t\t\t, xform->rsa.qt.qInv.data,\n-\t\t\t\t\t\txform->rsa.qt.qInv.length);\n-\t\t\t\tcookie->alg_size = alg_size;\n-\t\t\t\tqat_req->pke_hdr.cd_pars.func_id = func_id;\n+\t\tif (asym_op->rsa.op_type ==\n+\t\t\t\tRTE_CRYPTO_ASYM_OP_ENCRYPT) {\n+\t\t\tuint8_t *rsa_result = asym_op->rsa.cipher.data;\n \n-#if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG\n-\t\t\t\tQAT_DP_HEXDUMP_LOG(DEBUG, \"C\",\n-\t\t\t\t\t\tcookie->input_array[0],\n-\t\t\t\t\t\talg_size_in_bytes);\n-\t\t\t\tQAT_DP_HEXDUMP_LOG(DEBUG, \"p\",\n-\t\t\t\t\t\tcookie->input_array[1],\n-\t\t\t\t\t\talg_size_in_bytes);\n-\t\t\t\tQAT_DP_HEXDUMP_LOG(DEBUG, \"q\",\n-\t\t\t\t\t\tcookie->input_array[2],\n-\t\t\t\t\t\talg_size_in_bytes);\n-\t\t\t\tQAT_DP_HEXDUMP_LOG(DEBUG,\n-\t\t\t\t\t\t\"dP\", cookie->input_array[3],\n-\t\t\t\t\t\talg_size_in_bytes);\n-\t\t\t\tQAT_DP_HEXDUMP_LOG(DEBUG,\n-\t\t\t\t\t\t\"dQ\", cookie->input_array[4],\n-\t\t\t\t\t\talg_size_in_bytes);\n-\t\t\t\tQAT_DP_HEXDUMP_LOG(DEBUG,\n-\t\t\t\t\t\t\"qInv\", cookie->input_array[5],\n-\t\t\t\t\t\talg_size_in_bytes);\n-#endif\n-\t\t\t} else if (xform->rsa.key_type ==\n-\t\t\t\t\tRTE_RSA_KEY_TYPE_EXP) {\n-\t\t\t\tif (qat_asym_get_sz_and_func_id(\n-\t\t\t\t\t\tRSA_DEC_IDS,\n-\t\t\t\t\t\tsizeof(RSA_DEC_IDS)/\n-\t\t\t\t\t\tsizeof(*RSA_DEC_IDS),\n-\t\t\t\t\t\t&alg_size, &func_id)) {\n-\t\t\t\t\treturn -(EINVAL);\n-\t\t\t\t}\n-\t\t\t\talg_size_in_bytes = alg_size >> 3;\n-\t\t\t\trte_memcpy(cookie->input_array[1] +\n-\t\t\t\t\t\talg_size_in_bytes -\n-\t\t\t\t\t\txform->rsa.d.length,\n-\t\t\t\t\t\txform->rsa.d.data,\n-\t\t\t\t\t\txform->rsa.d.length);\n-\t\t\t\trte_memcpy(cookie->input_array[2] +\n-\t\t\t\t\t\talg_size_in_bytes -\n-\t\t\t\t\t\txform->rsa.n.length,\n-\t\t\t\t\t\txform->rsa.n.data,\n-\t\t\t\t\t\txform->rsa.n.length);\n-#if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG\n-\t\t\tQAT_DP_HEXDUMP_LOG(DEBUG, \"RSA ciphertext\",\n-\t\t\t\t\tcookie->input_array[0],\n-\t\t\t\t\talg_size_in_bytes);\n-\t\t\tQAT_DP_HEXDUMP_LOG(DEBUG, \"RSA d\", cookie->input_array[1],\n-\t\t\t\t\talg_size_in_bytes);\n-\t\t\tQAT_DP_HEXDUMP_LOG(DEBUG, \"RSA n\", cookie->input_array[2],\n-\t\t\t\t\talg_size_in_bytes);\n-#endif\n+\t\t\trte_memcpy(rsa_result,\n+\t\t\t\t\tcookie->output_array[0],\n+\t\t\t\t\talg_bytesize);\n+\t\t\tHEXDUMP(\"RSA Encrypted data\", cookie->output_array[0],\n+\t\t\t\talg_bytesize);\n+\t\t} else {\n+\t\t\tuint8_t *rsa_result = asym_op->rsa.cipher.data;\n \n-\t\t\t\tcookie->alg_size = alg_size;\n-\t\t\t\tqat_req->pke_hdr.cd_pars.func_id = func_id;\n-\t\t\t} else {\n-\t\t\t\tQAT_LOG(ERR, \"Invalid RSA key type\");\n-\t\t\t\treturn -(EINVAL);\n+\t\t\tswitch (asym_op->rsa.pad) {\n+\t\t\tcase RTE_CRYPTO_RSA_PADDING_NONE:\n+\t\t\t\trte_memcpy(rsa_result,\n+\t\t\t\t\t\tcookie->output_array[0],\n+\t\t\t\t\t\talg_bytesize);\n+\t\t\t\tHEXDUMP(\"RSA signature\",\n+\t\t\t\t\tcookie->output_array[0],\n+\t\t\t\t\talg_bytesize);\n+\t\t\t\tbreak;\n+\t\t\tdefault:\n+\t\t\t\tQAT_LOG(ERR, \"Padding not supported\");\n+\t\t\t\treturn RTE_CRYPTO_OP_STATUS_ERROR;\n \t\t\t}\n \t\t}\n \t} else {\n-\t\tQAT_LOG(ERR, \"Invalid asymmetric crypto xform\");\n-\t\treturn -(EINVAL);\n+\t\tif (asym_op->rsa.op_type == RTE_CRYPTO_ASYM_OP_DECRYPT) {\n+\t\t\tuint8_t *rsa_result = asym_op->rsa.message.data;\n+\n+\t\t\tswitch (asym_op->rsa.pad) {\n+\t\t\tcase RTE_CRYPTO_RSA_PADDING_NONE:\n+\t\t\t\trte_memcpy(rsa_result,\n+\t\t\t\t\tcookie->output_array[0],\n+\t\t\t\t\talg_bytesize);\n+\t\t\t\tHEXDUMP(\"RSA Decrypted Message\",\n+\t\t\t\t\tcookie->output_array[0],\n+\t\t\t\t\talg_bytesize);\n+\t\t\t\tbreak;\n+\t\t\tdefault:\n+\t\t\t\tQAT_LOG(ERR, \"Padding not supported\");\n+\t\t\t\treturn RTE_CRYPTO_OP_STATUS_ERROR;\n+\t\t\t}\n+\t\t} else {\n+\t\t\tuint8_t *rsa_result = asym_op->rsa.sign.data;\n+\n+\t\t\trte_memcpy(rsa_result,\n+\t\t\t\t\tcookie->output_array[0],\n+\t\t\t\t\talg_bytesize);\n+\t\t\tHEXDUMP(\"RSA Signature\", cookie->output_array[0],\n+\t\t\t\talg_bytesize);\n+\t\t}\n \t}\n-\treturn 0;\n+\treturn RTE_CRYPTO_OP_STATUS_SUCCESS;\n+}\n+\n+\n+static int\n+asym_set_input(struct rte_crypto_asym_op *asym_op,\n+\t\tstruct icp_qat_fw_pke_request *qat_req,\n+\t\tstruct qat_asym_op_cookie *cookie,\n+\t\tstruct rte_crypto_asym_xform *xform)\n+{\n+\tswitch (xform->xform_type) {\n+\tcase RTE_CRYPTO_ASYM_XFORM_MODEX:\n+\t\treturn modexp_set_input(asym_op, qat_req,\n+\t\t\t\tcookie, xform);\n+\tcase RTE_CRYPTO_ASYM_XFORM_MODINV:\n+\t\treturn modinv_set_input(asym_op, qat_req,\n+\t\t\t\tcookie, xform);\n+\tcase RTE_CRYPTO_ASYM_XFORM_RSA:\n+\t\treturn rsa_set_input(asym_op, qat_req,\n+\t\t\t\tcookie, xform);\n+\tdefault:\n+\t\tQAT_LOG(ERR, \"Invalid/unsupported asymmetric crypto xform\");\n+\t\treturn -EINVAL;\n+\t}\n+\treturn 1;\n }\n \n int\n-qat_asym_build_request(void *in_op,\n-\t\t\tuint8_t *out_msg,\n-\t\t\tvoid *op_cookie,\n+qat_asym_build_request(void *in_op, uint8_t *out_msg, void *op_cookie,\n \t\t\t__rte_unused enum qat_device_gen qat_dev_gen)\n {\n-\tstruct qat_asym_session *ctx;\n \tstruct rte_crypto_op *op = (struct rte_crypto_op *)in_op;\n \tstruct rte_crypto_asym_op *asym_op = op->asym;\n \tstruct icp_qat_fw_pke_request *qat_req =\n \t\t\t(struct icp_qat_fw_pke_request *)out_msg;\n \tstruct qat_asym_op_cookie *cookie =\n-\t\t\t\t(struct qat_asym_op_cookie *)op_cookie;\n+\t\t\t(struct qat_asym_op_cookie *)op_cookie;\n \tint err = 0;\n \n \top->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED;\n-\tif (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {\n-\t\tctx = (struct qat_asym_session *)\n-\t\t\tget_asym_session_private_data(\n-\t\t\top->asym->session, qat_asym_driver_id);\n-\t\tif (unlikely(ctx == NULL)) {\n-\t\t\tQAT_LOG(ERR, \"Session has not been created for this device\");\n-\t\t\tgoto error;\n-\t\t}\n-\t\trte_mov64((uint8_t *)qat_req, (const uint8_t *)&(ctx->req_tmpl));\n-\t\terr = qat_asym_fill_arrays(asym_op, qat_req, cookie, ctx->xform);\n-\t\tif (err) {\n-\t\t\top->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;\n-\t\t\tgoto error;\n-\t\t}\n-\t} else if (op->sess_type == RTE_CRYPTO_OP_SESSIONLESS) {\n-\t\tqat_fill_req_tmpl(qat_req);\n-\t\terr = qat_asym_fill_arrays(asym_op, qat_req, cookie,\n+\tswitch (op->sess_type) {\n+\tcase RTE_CRYPTO_OP_WITH_SESSION:\n+\t\tQAT_LOG(ERR,\n+\t\t\t\"QAT asymmetric crypto PMD does not support session\"\n+\t\t\t);\n+\t\tgoto error;\n+\tcase RTE_CRYPTO_OP_SESSIONLESS:\n+\t\trequest_init(qat_req);\n+\t\terr = asym_set_input(asym_op, qat_req, cookie,\n \t\t\t\top->asym->xform);\n \t\tif (err) {\n \t\t\top->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;\n \t\t\tgoto error;\n \t\t}\n-\t} else {\n+\t\tbreak;\n+\tdefault:\n \t\tQAT_DP_LOG(ERR, \"Invalid session/xform settings\");\n \t\top->status = RTE_CRYPTO_OP_STATUS_INVALID_SESSION;\n \t\tgoto error;\n@@ -522,21 +584,12 @@ qat_asym_build_request(void *in_op,\n \tqat_req->pke_mid.src_data_addr = cookie->input_addr;\n \tqat_req->pke_mid.dest_data_addr = cookie->output_addr;\n \n-#if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG\n-\tQAT_DP_HEXDUMP_LOG(DEBUG, \"qat_req:\", qat_req,\n-\t\t\tsizeof(struct icp_qat_fw_pke_request));\n-#endif\n+\tHEXDUMP(\"qat_req:\", qat_req, sizeof(struct icp_qat_fw_pke_request));\n \n \treturn 0;\n error:\n-\n \tqat_req->pke_mid.opaque = (uint64_t)(uintptr_t)op;\n-\n-#if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG\n-\tQAT_DP_HEXDUMP_LOG(DEBUG, \"qat_req:\", qat_req,\n-\t\tsizeof(struct icp_qat_fw_pke_request));\n-#endif\n-\n+\tHEXDUMP(\"qat_req:\", qat_req, sizeof(struct icp_qat_fw_pke_request));\n \tqat_req->output_param_count = 0;\n \tqat_req->input_param_count = 0;\n \tqat_req->pke_hdr.service_type = ICP_QAT_FW_COMN_REQ_NULL;\n@@ -545,144 +598,30 @@ qat_asym_build_request(void *in_op,\n \treturn 0;\n }\n \n-static void qat_asym_collect_response(struct rte_crypto_op *rx_op,\n+static uint8_t\n+qat_asym_collect_response(struct rte_crypto_op *rx_op,\n \t\tstruct qat_asym_op_cookie *cookie,\n \t\tstruct rte_crypto_asym_xform *xform)\n {\n-\tsize_t alg_size, alg_size_in_bytes = 0;\n \tstruct rte_crypto_asym_op *asym_op = rx_op->asym;\n \n-\tif (xform->xform_type == RTE_CRYPTO_ASYM_XFORM_MODEX) {\n-\t\trte_crypto_param n = xform->modex.modulus;\n-\n-\t\talg_size = cookie->alg_size;\n-\t\talg_size_in_bytes = alg_size >> 3;\n-\t\tuint8_t *modexp_result = asym_op->modex.result.data;\n-\n-\t\tif (rx_op->status == RTE_CRYPTO_OP_STATUS_NOT_PROCESSED) {\n-\t\t\trte_memcpy(modexp_result +\n-\t\t\t\t(asym_op->modex.result.length -\n-\t\t\t\t\tn.length),\n-\t\t\t\tcookie->output_array[0] + alg_size_in_bytes\n-\t\t\t\t- n.length, n.length\n-\t\t\t\t);\n-\t\t\trx_op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;\n-#if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG\n-\t\t\tQAT_DP_HEXDUMP_LOG(DEBUG, \"ModExp result\",\n-\t\t\t\t\tcookie->output_array[0],\n-\t\t\t\t\talg_size_in_bytes);\n-\n-#endif\n-\t\t}\n-\t} else if (xform->xform_type == RTE_CRYPTO_ASYM_XFORM_MODINV) {\n-\t\trte_crypto_param n = xform->modinv.modulus;\n-\n-\t\talg_size = cookie->alg_size;\n-\t\talg_size_in_bytes = alg_size >> 3;\n-\t\tuint8_t *modinv_result = asym_op->modinv.result.data;\n-\n-\t\tif (rx_op->status == RTE_CRYPTO_OP_STATUS_NOT_PROCESSED) {\n-\t\t\trte_memcpy(modinv_result + (asym_op->modinv.result.length\n-\t\t\t\t- n.length),\n-\t\t\t\tcookie->output_array[0] + alg_size_in_bytes\n-\t\t\t\t- n.length, n.length);\n-\t\t\trx_op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;\n-#if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG\n-\t\t\tQAT_DP_HEXDUMP_LOG(DEBUG, \"ModInv result\",\n-\t\t\t\t\tcookie->output_array[0],\n-\t\t\t\t\talg_size_in_bytes);\n-#endif\n-\t\t}\n-\t} else if (xform->xform_type == RTE_CRYPTO_ASYM_XFORM_RSA) {\n-\n-\t\talg_size = cookie->alg_size;\n-\t\talg_size_in_bytes = alg_size >> 3;\n-\t\tif (asym_op->rsa.op_type == RTE_CRYPTO_ASYM_OP_ENCRYPT ||\n-\t\t\t\tasym_op->rsa.op_type ==\n-\t\t\t\t\tRTE_CRYPTO_ASYM_OP_VERIFY) {\n-\t\t\tif (asym_op->rsa.op_type ==\n-\t\t\t\t\tRTE_CRYPTO_ASYM_OP_ENCRYPT) {\n-\t\t\t\tuint8_t *rsa_result = asym_op->rsa.cipher.data;\n-\n-\t\t\t\trte_memcpy(rsa_result,\n-\t\t\t\t\t\tcookie->output_array[0],\n-\t\t\t\t\t\talg_size_in_bytes);\n-\t\t\t\trx_op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;\n-#if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG\n-\t\t\t\tQAT_DP_HEXDUMP_LOG(DEBUG, \"RSA Encrypted data\",\n-\t\t\t\t\t\tcookie->output_array[0],\n-\t\t\t\t\t\talg_size_in_bytes);\n-#endif\n-\t\t\t} else if (asym_op->rsa.op_type ==\n-\t\t\t\t\tRTE_CRYPTO_ASYM_OP_VERIFY) {\n-\t\t\t\tuint8_t *rsa_result = asym_op->rsa.cipher.data;\n-\n-\t\t\t\tswitch (asym_op->rsa.pad) {\n-\t\t\t\tcase RTE_CRYPTO_RSA_PADDING_NONE:\n-\t\t\t\t\trte_memcpy(rsa_result,\n-\t\t\t\t\t\t\tcookie->output_array[0],\n-\t\t\t\t\t\t\talg_size_in_bytes);\n-\t\t\t\t\trx_op->status =\n-\t\t\t\t\t\tRTE_CRYPTO_OP_STATUS_SUCCESS;\n-#if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG\n-\t\t\t\tQAT_DP_HEXDUMP_LOG(DEBUG, \"RSA Signature\",\n-\t\t\t\t\t\tcookie->output_array[0],\n-\t\t\t\t\t\talg_size_in_bytes);\n-#endif\n-\t\t\t\t\tbreak;\n-\t\t\t\tdefault:\n-\t\t\t\t\tQAT_LOG(ERR, \"Padding not supported\");\n-\t\t\t\t\trx_op->status =\n-\t\t\t\t\t\tRTE_CRYPTO_OP_STATUS_ERROR;\n-\t\t\t\t\tbreak;\n-\t\t\t\t}\n-\t\t\t}\n-\t\t} else {\n-\t\t\tif (asym_op->rsa.op_type ==\n-\t\t\t\t\tRTE_CRYPTO_ASYM_OP_DECRYPT) {\n-\t\t\t\tuint8_t *rsa_result = asym_op->rsa.message.data;\n-\n-\t\t\t\tswitch (asym_op->rsa.pad) {\n-\t\t\t\tcase RTE_CRYPTO_RSA_PADDING_NONE:\n-\t\t\t\t\trte_memcpy(rsa_result,\n-\t\t\t\t\t\tcookie->output_array[0],\n-\t\t\t\t\t\talg_size_in_bytes);\n-\t\t\t\t\trx_op->status =\n-\t\t\t\t\t\tRTE_CRYPTO_OP_STATUS_SUCCESS;\n-\t\t\t\t\tbreak;\n-\t\t\t\tdefault:\n-\t\t\t\t\tQAT_LOG(ERR, \"Padding not supported\");\n-\t\t\t\t\trx_op->status =\n-\t\t\t\t\t\tRTE_CRYPTO_OP_STATUS_ERROR;\n-\t\t\t\t\tbreak;\n-\t\t\t\t}\n-#if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG\n-\t\t\t\tQAT_DP_HEXDUMP_LOG(DEBUG, \"RSA Decrypted Message\",\n-\t\t\t\t\t\trsa_result, alg_size_in_bytes);\n-#endif\n-\t\t\t} else if (asym_op->rsa.op_type == RTE_CRYPTO_ASYM_OP_SIGN) {\n-\t\t\t\tuint8_t *rsa_result = asym_op->rsa.sign.data;\n-\n-\t\t\t\trte_memcpy(rsa_result,\n-\t\t\t\t\t\tcookie->output_array[0],\n-\t\t\t\t\t\talg_size_in_bytes);\n-\t\t\t\trx_op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;\n-#if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG\n-\t\t\t\tQAT_DP_HEXDUMP_LOG(DEBUG, \"RSA Signature\",\n-\t\t\t\t\t\tcookie->output_array[0],\n-\t\t\t\t\t\talg_size_in_bytes);\n-#endif\n-\t\t\t}\n-\t\t}\n+\tswitch (xform->xform_type) {\n+\tcase RTE_CRYPTO_ASYM_XFORM_MODEX:\n+\t\treturn modexp_collect(asym_op, cookie, xform);\n+\tcase RTE_CRYPTO_ASYM_XFORM_MODINV:\n+\t\treturn modinv_collect(asym_op, cookie, xform);\n+\tcase RTE_CRYPTO_ASYM_XFORM_RSA:\n+\t\treturn rsa_collect(asym_op, cookie);\n+\tdefault:\n+\t\tQAT_LOG(ERR, \"Not supported xform type\");\n+\t\treturn  RTE_CRYPTO_OP_STATUS_ERROR;\n \t}\n-\tqat_clear_arrays_by_alg(cookie, xform, alg_size_in_bytes);\n }\n \n void\n qat_asym_process_response(void **op, uint8_t *resp,\n \t\tvoid *op_cookie)\n {\n-\tstruct qat_asym_session *ctx;\n \tstruct icp_qat_fw_pke_resp *resp_msg =\n \t\t\t(struct icp_qat_fw_pke_resp *)resp;\n \tstruct rte_crypto_op *rx_op = (struct rte_crypto_op *)(uintptr_t)\n@@ -709,99 +648,37 @@ qat_asym_process_response(void **op, uint8_t *resp,\n \t\t\t\t\t\" returned error\");\n \t\t}\n \t}\n-\n-\tif (rx_op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {\n-\t\tctx = (struct qat_asym_session *)get_asym_session_private_data(\n-\t\t\trx_op->asym->session, qat_asym_driver_id);\n-\t\tqat_asym_collect_response(rx_op, cookie, ctx->xform);\n-\t} else if (rx_op->sess_type == RTE_CRYPTO_OP_SESSIONLESS) {\n-\t\tqat_asym_collect_response(rx_op, cookie, rx_op->asym->xform);\n+\tif (rx_op->status == RTE_CRYPTO_OP_STATUS_NOT_PROCESSED) {\n+\t\trx_op->status = qat_asym_collect_response(rx_op,\n+\t\t\t\t\tcookie, rx_op->asym->xform);\n+\t\tcleanup(cookie, rx_op->asym->xform,\n+\t\t\t\t\tcookie->alg_bytesize);\n \t}\n-\t*op = rx_op;\n \n-#if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG\n-\tQAT_DP_HEXDUMP_LOG(DEBUG, \"resp_msg:\", resp_msg,\n-\t\t\tsizeof(struct icp_qat_fw_pke_resp));\n-#endif\n+\t*op = rx_op;\n+\tHEXDUMP(\"resp_msg:\", resp_msg, sizeof(struct icp_qat_fw_pke_resp));\n }\n \n int\n-qat_asym_session_configure(struct rte_cryptodev *dev,\n-\t\tstruct rte_crypto_asym_xform *xform,\n-\t\tstruct rte_cryptodev_asym_session *sess,\n-\t\tstruct rte_mempool *mempool)\n+qat_asym_session_configure(struct rte_cryptodev *dev __rte_unused,\n+\t\tstruct rte_crypto_asym_xform *xform __rte_unused,\n+\t\tstruct rte_cryptodev_asym_session *sess __rte_unused,\n+\t\tstruct rte_mempool *mempool __rte_unused)\n {\n-\tint err = 0;\n-\tvoid *sess_private_data;\n-\tstruct qat_asym_session *session;\n-\n-\tif (rte_mempool_get(mempool, &sess_private_data)) {\n-\t\tQAT_LOG(ERR,\n-\t\t\t\"Couldn't get object from session mempool\");\n-\t\treturn -ENOMEM;\n-\t}\n-\n-\tsession = sess_private_data;\n-\tif (xform->xform_type == RTE_CRYPTO_ASYM_XFORM_MODEX) {\n-\t\tif (xform->modex.exponent.length == 0 ||\n-\t\t\t\txform->modex.modulus.length == 0) {\n-\t\t\tQAT_LOG(ERR, \"Invalid mod exp input parameter\");\n-\t\t\terr = -EINVAL;\n-\t\t\tgoto error;\n-\t\t}\n-\t} else if (xform->xform_type == RTE_CRYPTO_ASYM_XFORM_MODINV) {\n-\t\tif (xform->modinv.modulus.length == 0) {\n-\t\t\tQAT_LOG(ERR, \"Invalid mod inv input parameter\");\n-\t\t\terr = -EINVAL;\n-\t\t\tgoto error;\n-\t\t}\n-\t} else if (xform->xform_type == RTE_CRYPTO_ASYM_XFORM_RSA) {\n-\t\tif (xform->rsa.n.length == 0) {\n-\t\t\tQAT_LOG(ERR, \"Invalid rsa input parameter\");\n-\t\t\terr = -EINVAL;\n-\t\t\tgoto error;\n-\t\t}\n-\t} else if (xform->xform_type >= RTE_CRYPTO_ASYM_XFORM_TYPE_LIST_END\n-\t\t\t|| xform->xform_type <= RTE_CRYPTO_ASYM_XFORM_NONE) {\n-\t\tQAT_LOG(ERR, \"Invalid asymmetric crypto xform\");\n-\t\terr = -EINVAL;\n-\t\tgoto error;\n-\t} else {\n-\t\tQAT_LOG(ERR, \"Asymmetric crypto xform not implemented\");\n-\t\terr = -EINVAL;\n-\t\tgoto error;\n-\t}\n-\n-\tsession->xform = xform;\n-\tqat_asym_build_req_tmpl(sess_private_data);\n-\tset_asym_session_private_data(sess, dev->driver_id,\n-\t\tsess_private_data);\n \n-\treturn 0;\n-error:\n-\trte_mempool_put(mempool, sess_private_data);\n-\treturn err;\n+\tQAT_LOG(ERR, \"QAT asymmetric PMD currently does not support session\");\n+\treturn -ENOTSUP;\n }\n \n-unsigned int qat_asym_session_get_private_size(\n-\t\tstruct rte_cryptodev *dev __rte_unused)\n+unsigned int\n+qat_asym_session_get_private_size(struct rte_cryptodev *dev __rte_unused)\n {\n-\treturn RTE_ALIGN_CEIL(sizeof(struct qat_asym_session), 8);\n+\treturn 0;\n }\n \n void\n-qat_asym_session_clear(struct rte_cryptodev *dev,\n-\t\tstruct rte_cryptodev_asym_session *sess)\n+qat_asym_session_clear(struct rte_cryptodev *dev __rte_unused,\n+\t\tstruct rte_cryptodev_asym_session *sess __rte_unused)\n {\n-\tuint8_t index = dev->driver_id;\n-\tvoid *sess_priv = get_asym_session_private_data(sess, index);\n-\tstruct qat_asym_session *s = (struct qat_asym_session *)sess_priv;\n-\n-\tif (sess_priv) {\n-\t\tmemset(s, 0, qat_asym_session_get_private_size(dev));\n-\t\tstruct rte_mempool *sess_mp = rte_mempool_from_obj(sess_priv);\n \n-\t\tset_asym_session_private_data(sess, index, NULL);\n-\t\trte_mempool_put(sess_mp, sess_priv);\n-\t}\n }\ndiff --git a/drivers/crypto/qat/qat_asym.h b/drivers/crypto/qat/qat_asym.h\nindex 308b6b2e0b..ed4367ac4d 100644\n--- a/drivers/crypto/qat/qat_asym.h\n+++ b/drivers/crypto/qat/qat_asym.h\n@@ -27,7 +27,7 @@ typedef uint64_t large_int_ptr;\n #define QAT_ASYM_RSA_QT_NUM_IN_PARAMS\t\t6\n \n struct qat_asym_op_cookie {\n-\tsize_t alg_size;\n+\tsize_t alg_bytesize;\n \tuint64_t error;\n \trte_iova_t input_addr;\n \trte_iova_t output_addr;\n",
    "prefixes": [
        "1/2"
    ]
}