get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 46887,
    "url": "http://patches.dpdk.org/api/patches/46887/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20181016103352.2678-3-akhil.goyal@nxp.com/",
    "project": {
        "id": 1,
        "url": "http://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": "<20181016103352.2678-3-akhil.goyal@nxp.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20181016103352.2678-3-akhil.goyal@nxp.com",
    "date": "2018-10-16T10:39:06",
    "name": "[v5,2/3] crypto/dpaa2_sec: add sample pdcp descriptor apis",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "178d09db171e505337d3e107a1f52baa6dc9de10",
    "submitter": {
        "id": 517,
        "url": "http://patches.dpdk.org/api/people/517/?format=api",
        "name": "Akhil Goyal",
        "email": "akhil.goyal@nxp.com"
    },
    "delegate": {
        "id": 6690,
        "url": "http://patches.dpdk.org/api/users/6690/?format=api",
        "username": "akhil",
        "first_name": "akhil",
        "last_name": "goyal",
        "email": "gakhil@marvell.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20181016103352.2678-3-akhil.goyal@nxp.com/mbox/",
    "series": [
        {
            "id": 1919,
            "url": "http://patches.dpdk.org/api/series/1919/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=1919",
            "date": "2018-10-16T10:38:54",
            "name": "security: support for pdcp",
            "version": 5,
            "mbox": "http://patches.dpdk.org/series/1919/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/46887/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/46887/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 A579A4CA9;\n\tTue, 16 Oct 2018 12:39:11 +0200 (CEST)",
            "from EUR04-HE1-obe.outbound.protection.outlook.com\n\t(mail-eopbgr70042.outbound.protection.outlook.com [40.107.7.42])\n\tby dpdk.org (Postfix) with ESMTP id 9FF714C95\n\tfor <dev@dpdk.org>; Tue, 16 Oct 2018 12:39:09 +0200 (CEST)",
            "from VI1PR04MB4893.eurprd04.prod.outlook.com (20.177.49.154) by\n\tVI1PR04MB3231.eurprd04.prod.outlook.com (10.170.227.28) with\n\tMicrosoft SMTP Server (version=TLS1_2,\n\tcipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id\n\t15.20.1228.31; Tue, 16 Oct 2018 10:39:06 +0000",
            "from VI1PR04MB4893.eurprd04.prod.outlook.com\n\t([fe80::cc19:b6c6:27db:3fec]) by\n\tVI1PR04MB4893.eurprd04.prod.outlook.com\n\t([fe80::cc19:b6c6:27db:3fec%3]) with mapi id 15.20.1228.027;\n\tTue, 16 Oct 2018 10:39:06 +0000"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1;\n\th=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;\n\tbh=i50FwPDwJ5/b5LmCTgM7AbCXoMQbgrCwSXAazrL1UwE=;\n\tb=ITsyMimXA+885oC0azimxAyyhwgnmY5KyHjRGqRbdM4uD1LPpT+xTiDBlnuWfkl5KjJ1QNIwVfco7yjLSDVqNUu0aV9KS+KKklWG6lOf21R9f5tIULFbLtCBd7tW3ge//dw/wO7zXDOuAY3YtLGtr0QLaprVSP9Fq/6iArN/iZ0=",
        "From": "Akhil Goyal <akhil.goyal@nxp.com>",
        "To": "\"dev@dpdk.org\" <dev@dpdk.org>",
        "CC": "\"pablo.de.lara.guarch@intel.com\" <pablo.de.lara.guarch@intel.com>,\n\t\"radu.nicolau@intel.com\" <radu.nicolau@intel.com>,\n\t\"jerin.jacob@caviumnetworks.com\" <jerin.jacob@caviumnetworks.com>,\n\t\"narayanaprasad.athreya@caviumnetworks.com\"\n\t<narayanaprasad.athreya@caviumnetworks.com>,\n\t\"Shally.Verma@caviumnetworks.com\" <Shally.Verma@caviumnetworks.com>, \n\t\"Anoob.Joseph@caviumnetworks.com\" <Anoob.Joseph@caviumnetworks.com>, \n\t\"Vidya.Velumuri@caviumnetworks.com\" <Vidya.Velumuri@caviumnetworks.com>, \n\tHemant Agrawal <hemant.agrawal@nxp.com>,\n\tAkhil Goyal <akhil.goyal@nxp.com>",
        "Thread-Topic": "[PATCH v5 2/3] crypto/dpaa2_sec: add sample pdcp descriptor\n\tapis",
        "Thread-Index": "AQHUZTx2yj14mPLKQEu6w1yKagyQ5w==",
        "Date": "Tue, 16 Oct 2018 10:39:06 +0000",
        "Message-ID": "<20181016103352.2678-3-akhil.goyal@nxp.com>",
        "References": "<20181015124858.5562-1-akhil.goyal@nxp.com>\n\t<20181016103352.2678-1-akhil.goyal@nxp.com>",
        "In-Reply-To": "<20181016103352.2678-1-akhil.goyal@nxp.com>",
        "Accept-Language": "en-IN, en-US",
        "Content-Language": "en-US",
        "X-MS-Has-Attach": "",
        "X-MS-TNEF-Correlator": "",
        "x-clientproxiedby": "TYAPR01CA0026.jpnprd01.prod.outlook.com\n\t(2603:1096:404:28::14) To VI1PR04MB4893.eurprd04.prod.outlook.com\n\t(2603:10a6:803:56::26)",
        "authentication-results": "spf=none (sender IP is )\n\tsmtp.mailfrom=akhil.goyal@nxp.com; ",
        "x-ms-exchange-messagesentrepresentingtype": "1",
        "x-originating-ip": "[14.143.30.134]",
        "x-ms-publictraffictype": "Email",
        "x-microsoft-exchange-diagnostics": "1; VI1PR04MB3231;\n\t6:115FNyNBHeCaQn/3sT4lMmzeyyijdaIb2VS3x31/phY85f/2RfgAqCOJEy3JWNx+bI+EkfyTuyNMM+/RJtf8x80RlEs6gnIGuvD675WoQM5bd1S/QlrrICoQRDvBpQvoHYBnCdCMC/IESjEZG11b0RpiRfWw0UryHNYZOMHUSLkLM4N5F+qII3emnTlNbC2WPeqitzLorlfTnKu6KoMafd25hmUMZKQ8ue/gIKI2IRi2IKxJQErMa/WTy/nxfVVkutcIOWA7qZl0dlvkxa3nWrXUiq7gDxdbkg2QMUMvs4Vu0tElBFI0AxCr++FEzXRejSe9o6TkusDtf00oazsCKxcZ/Aok0Y5Gk+LMSCiFr5c1HZgTWVgAgjX6QfxVLwuaZzJCo6Osp0wMjjepwRmuZdlzxTKbDyi6kuX23pOJUODPjsFP4jI++6svFfLTsNm0ZG6efLWeegu6rZSGw6wqqg==;\n\t5:QVCqWlhlIXF5LNB/Bk79kKTha4puksYKTDXbpRIO+AvgQfxf0yHfYfmBYqQ+M40tBSbqeAFJpJOgpK8cAWuzW5LKMnBivmljsnbDSSB2a9pTUUxwry0eaQWRaIePpQ0g1yLl3I63mIHw+PJ7eN/+uQBb8+ADFUCc+7Dt4BarwEY=;\n\t7:8F8IXHJtL/zMhx1+3wRlTuUdf9mAJI9AhEcY7Q4Hm6myijM7lT6eghaER4ZILI71mboAabwCipBijRnMnaysjXzBPibQsxhxrHFYr3XrqHEo/6NquK8HV5PuY5kPvmx5/GvH/1psI5YeXH/7vcb0JMLOOjCwfHTDT+XB9pKgO79zZYZFjtetJmHv+iScoVU0lxEjCzKjp9CErMKqBOyvp8IKynaCS4UCSEsV7m6fqDEVIDYC8frgn2yrt+bGSuCK",
        "x-ms-office365-filtering-correlation-id": "b0ae15a6-80c0-4ca6-f665-08d63353985e",
        "x-ms-office365-filtering-ht": "Tenant",
        "x-microsoft-antispam": "BCL:0; PCL:0;\n\tRULEID:(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020);\n\tSRVR:VI1PR04MB3231; ",
        "x-ms-traffictypediagnostic": "VI1PR04MB3231:",
        "x-microsoft-antispam-prvs": "<VI1PR04MB32314FD3316EFFC18FCCEE32E6FE0@VI1PR04MB3231.eurprd04.prod.outlook.com>",
        "x-exchange-antispam-report-test": "UriScan:(269456686620040)(185117386973197); ",
        "x-ms-exchange-senderadcheck": "1",
        "x-exchange-antispam-report-cfa-test": "BCL:0; PCL:0;\n\tRULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231355)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(6055026)(149066)(150057)(6041310)(20161123560045)(20161123558120)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051);\n\tSRVR:VI1PR04MB3231; BCL:0; PCL:0; RULEID:; SRVR:VI1PR04MB3231; ",
        "x-forefront-prvs": "0827D7ACB9",
        "x-forefront-antispam-report": "SFV:NSPM;\n\tSFS:(10009020)(136003)(39860400002)(396003)(346002)(366004)(376002)(189003)(199004)(1076002)(53936002)(6512007)(14444005)(256004)(575784001)(6916009)(3846002)(86362001)(44832011)(97736004)(5640700003)(476003)(68736007)(6436002)(4744004)(16200700003)(55236004)(66066001)(6116002)(76176011)(2900100001)(36756003)(6506007)(6486002)(53946003)(386003)(71200400001)(71190400001)(105586002)(2351001)(5250100002)(106356001)(99286004)(102836004)(8936002)(1730700003)(8676002)(2906002)(305945005)(478600001)(25786009)(81166006)(446003)(4326008)(81156014)(7736002)(316002)(54906003)(14454004)(2501003)(2616005)(486006)(186003)(11346002)(52116002)(26005)(5660300001)(569006);\n\tDIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR04MB3231;\n\tH:VI1PR04MB4893.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en;\n\tPTR:InfoNoRecords; MX:1; A:1; ",
        "received-spf": "None (protection.outlook.com: nxp.com does not designate\n\tpermitted sender hosts)",
        "x-microsoft-antispam-message-info": "986AxU1/HA1FtC2XjlVm9BQ5qybcuOnGvRVoc7F+HjAgm0KpOyq0FpUIHN3peR0pfOQ6uB63BpB7ddUdjq3Sid+SC4EZuFCfgV07ekKAibV5G2qotzAMdH3mi5w1krZLpEpbteL26X/l9guCZsAIfCxZOokisfe2NQ1AFSn0KDjzGJ5q7k9wBslkCmar+u9EZ+yZHHJWc3d6980I9s5JKpYak2qAC3huKPe3J2X3XQ9ka1izkAwVz3HeS7rZtHNZXhhU5z6gjvn4fcygdI0Ua8OOsZ8q1POLxXToVJb+9jkxW85SbB/qVv5zMt7M+PxjfoMLrLTwq0B4gdyWqKSHNoFpYW3dUWqQjFng2cFDEYo=",
        "spamdiagnosticoutput": "1:99",
        "spamdiagnosticmetadata": "NSPM",
        "Content-Type": "text/plain; charset=\"iso-8859-1\"",
        "Content-Transfer-Encoding": "quoted-printable",
        "MIME-Version": "1.0",
        "X-OriginatorOrg": "nxp.com",
        "X-MS-Exchange-CrossTenant-Network-Message-Id": "b0ae15a6-80c0-4ca6-f665-08d63353985e",
        "X-MS-Exchange-CrossTenant-originalarrivaltime": "16 Oct 2018 10:39:06.6647\n\t(UTC)",
        "X-MS-Exchange-CrossTenant-fromentityheader": "Hosted",
        "X-MS-Exchange-CrossTenant-id": "686ea1d3-bc2b-4c6f-a92c-d99c5c301635",
        "X-MS-Exchange-Transport-CrossTenantHeadersStamped": "VI1PR04MB3231",
        "Subject": "[dpdk-dev] [PATCH v5 2/3] crypto/dpaa2_sec: add sample pdcp\n\tdescriptor apis",
        "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": "From: Akhil Goyal <akhil.goyal@nxp.com>\n\nDPAA2 SEC platform can support look aside protocol\noffload for PDCP protocol.\n\nThe relevant APIs for configuring the hardware for PDCP\nis added for various modes and crypto algorithms.\n\nSigned-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>\nSigned-off-by: Horia Geanta Neag <horia.geanta@nxp.com>\nSigned-off-by: Alex Porosanu <alexandru.porosanu@nxp.com>\nSigned-off-by: Akhil Goyal <akhil.goyal@nxp.com>\n---\n drivers/crypto/dpaa2_sec/hw/desc.h      |    2 +-\n drivers/crypto/dpaa2_sec/hw/desc/pdcp.h | 2796 +++++++++++++++++++++++\n 2 files changed, 2797 insertions(+), 1 deletion(-)\n create mode 100644 drivers/crypto/dpaa2_sec/hw/desc/pdcp.h",
    "diff": "diff --git a/drivers/crypto/dpaa2_sec/hw/desc.h b/drivers/crypto/dpaa2_sec/hw/desc.h\nindex ca94ea3ff..5d99dd8af 100644\n--- a/drivers/crypto/dpaa2_sec/hw/desc.h\n+++ b/drivers/crypto/dpaa2_sec/hw/desc.h\n@@ -868,7 +868,7 @@\n #define OP_PCL_LTE_MIXED_AUTH_SHIFT\t0\n #define OP_PCL_LTE_MIXED_AUTH_MASK\t(3 << OP_PCL_LTE_MIXED_AUTH_SHIFT)\n #define OP_PCL_LTE_MIXED_ENC_SHIFT\t8\n-#define OP_PCL_LTE_MIXED_ENC_MASK\t(3 < OP_PCL_LTE_MIXED_ENC_SHIFT)\n+#define OP_PCL_LTE_MIXED_ENC_MASK\t(3 << OP_PCL_LTE_MIXED_ENC_SHIFT)\n #define OP_PCL_LTE_MIXED_AUTH_NULL\t(OP_PCL_LTE_NULL << \\\n \t\t\t\t\t OP_PCL_LTE_MIXED_AUTH_SHIFT)\n #define OP_PCL_LTE_MIXED_AUTH_SNOW\t(OP_PCL_LTE_SNOW << \\\ndiff --git a/drivers/crypto/dpaa2_sec/hw/desc/pdcp.h b/drivers/crypto/dpaa2_sec/hw/desc/pdcp.h\nnew file mode 100644\nindex 000000000..719ef605f\n--- /dev/null\n+++ b/drivers/crypto/dpaa2_sec/hw/desc/pdcp.h\n@@ -0,0 +1,2796 @@\n+/*\n+ * Copyright 2008-2013 Freescale Semiconductor, Inc.\n+ *\n+ * SPDX-License-Identifier: BSD-3-Clause or GPL-2.0+\n+ */\n+\n+#ifndef __DESC_PDCP_H__\n+#define __DESC_PDCP_H__\n+\n+#include \"hw/rta.h\"\n+#include \"common.h\"\n+\n+/**\n+ * DOC: PDCP Shared Descriptor Constructors\n+ *\n+ * Shared descriptors for PDCP protocol.\n+ */\n+\n+/**\n+ * PDCP_NULL_MAX_FRAME_LEN - The maximum frame frame length that is supported by\n+ *                           PDCP NULL protocol.\n+ */\n+#define PDCP_NULL_MAX_FRAME_LEN\t\t0x00002FFF\n+\n+/**\n+ * PDCP_MAC_I_LEN - The length of the MAC-I for PDCP protocol operation\n+ */\n+#define PDCP_MAC_I_LEN\t\t\t0x00000004\n+\n+/**\n+ * PDCP_MAX_FRAME_LEN_STATUS - The status returned in FD status/command field in\n+ *                             case the input frame is larger than\n+ *                             PDCP_NULL_MAX_FRAME_LEN.\n+ */\n+#define PDCP_MAX_FRAME_LEN_STATUS\t0xF1\n+\n+/**\n+ * PDCP_C_PLANE_SN_MASK - This mask is used in the PDCP descriptors for\n+ *                        extracting the sequence number (SN) from the PDCP\n+ *                        Control Plane header. For PDCP Control Plane, the SN\n+ *                        is constant (5 bits) as opposed to PDCP Data Plane\n+ *                        (7/12/15 bits).\n+ */\n+#define PDCP_C_PLANE_SN_MASK\t\t0x1F000000\n+#define PDCP_C_PLANE_SN_MASK_BE\t\t0x0000001F\n+\n+/**\n+ * PDCP_U_PLANE_15BIT_SN_MASK - This mask is used in the PDCP descriptors for\n+ *                              extracting the sequence number (SN) from the\n+ *                              PDCP User Plane header. For PDCP Control Plane,\n+ *                              the SN is constant (5 bits) as opposed to PDCP\n+ *                              Data Plane (7/12/15 bits).\n+ */\n+#define PDCP_U_PLANE_15BIT_SN_MASK\t0xFF7F0000\n+#define PDCP_U_PLANE_15BIT_SN_MASK_BE\t0x00007FFF\n+\n+/**\n+ * PDCP_BEARER_MASK - This mask is used masking out the bearer for PDCP\n+ *                    processing with SNOW f9 in LTE.\n+ *\n+ * The value on which this mask is applied is formatted as below:\n+ *     Count-C (32 bit) | Bearer (5 bit) | Direction (1 bit) | 0 (26 bits)\n+ *\n+ * Applying this mask is done for creating the upper 64 bits of the IV needed\n+ * for SNOW f9.\n+ *\n+ * The lower 32 bits of the mask are used for masking the direction for AES\n+ * CMAC IV.\n+ */\n+#define PDCP_BEARER_MASK\t\t0x00000004FFFFFFFFull\n+#define PDCP_BEARER_MASK_BE\t\t0xFFFFFFFF04000000ull\n+\n+/**\n+ * PDCP_DIR_MASK - This mask is used masking out the direction for PDCP\n+ *                 processing with SNOW f9 in LTE.\n+ *\n+ * The value on which this mask is applied is formatted as below:\n+ *     Bearer (5 bit) | Direction (1 bit) | 0 (26 bits)\n+ *\n+ * Applying this mask is done for creating the lower 32 bits of the IV needed\n+ * for SNOW f9.\n+ *\n+ * The upper 32 bits of the mask are used for masking the direction for AES\n+ * CMAC IV.\n+ */\n+#define PDCP_DIR_MASK\t\t\t0x00000000000000F8ull\n+#define PDCP_DIR_MASK_BE\t\t\t0xF800000000000000ull\n+\n+/**\n+ * PDCP_NULL_INT_MAC_I_VAL - The value of the PDCP PDU MAC-I in case NULL\n+ *                           integrity is used.\n+ */\n+\n+#define PDCP_NULL_INT_MAC_I_VAL\t\t0x00000000\n+\n+/**\n+ * PDCP_NULL_INT_ICV_CHECK_FAILED_STATUS - The status used to report ICV check\n+ *                                         failed in case of NULL integrity\n+ *                                         Control Plane processing.\n+ */\n+#define PDCP_NULL_INT_ICV_CHECK_FAILED_STATUS\t0x0A\n+/**\n+ * PDCP_DPOVRD_HFN_OV_EN - Value to be used in the FD status/cmd field to\n+ *                         indicate the HFN override mechanism is active for the\n+ *                         frame.\n+ */\n+#define PDCP_DPOVRD_HFN_OV_EN\t\t0x80000000\n+\n+/**\n+ * PDCP_P4080REV2_HFN_OV_BUFLEN - The length in bytes of the supplementary space\n+ *                                that must be provided by the user at the\n+ *                                beginning of the input frame buffer for\n+ *                                P4080 REV 2.\n+ *\n+ * The format of the frame buffer is the following:\n+ *\n+ *  |<---PDCP_P4080REV2_HFN_OV_BUFLEN-->|\n+ * //===================================||============||==============\\\\\n+ * || PDCP_DPOVRD_HFN_OV_EN | HFN value || PDCP Header|| PDCP Payload ||\n+ * \\\\===================================||============||==============//\n+ *\n+ * If HFN override mechanism is not desired, then the MSB of the first 4 bytes\n+ * must be set to 0b.\n+ */\n+#define PDCP_P4080REV2_HFN_OV_BUFLEN\t4\n+\n+/**\n+ * enum cipher_type_pdcp - Type selectors for cipher types in PDCP protocol OP\n+ *                         instructions.\n+ * @PDCP_CIPHER_TYPE_NULL: NULL\n+ * @PDCP_CIPHER_TYPE_SNOW: SNOW F8\n+ * @PDCP_CIPHER_TYPE_AES: AES\n+ * @PDCP_CIPHER_TYPE_ZUC: ZUCE\n+ * @PDCP_CIPHER_TYPE_INVALID: invalid option\n+ */\n+enum cipher_type_pdcp {\n+\tPDCP_CIPHER_TYPE_NULL,\n+\tPDCP_CIPHER_TYPE_SNOW,\n+\tPDCP_CIPHER_TYPE_AES,\n+\tPDCP_CIPHER_TYPE_ZUC,\n+\tPDCP_CIPHER_TYPE_INVALID\n+};\n+\n+/**\n+ * enum auth_type_pdcp - Type selectors for integrity types in PDCP protocol OP\n+ *                       instructions.\n+ * @PDCP_AUTH_TYPE_NULL: NULL\n+ * @PDCP_AUTH_TYPE_SNOW: SNOW F9\n+ * @PDCP_AUTH_TYPE_AES: AES CMAC\n+ * @PDCP_AUTH_TYPE_ZUC: ZUCA\n+ * @PDCP_AUTH_TYPE_INVALID: invalid option\n+ */\n+enum auth_type_pdcp {\n+\tPDCP_AUTH_TYPE_NULL,\n+\tPDCP_AUTH_TYPE_SNOW,\n+\tPDCP_AUTH_TYPE_AES,\n+\tPDCP_AUTH_TYPE_ZUC,\n+\tPDCP_AUTH_TYPE_INVALID\n+};\n+\n+/**\n+ * enum pdcp_dir - Type selectors for direction for PDCP protocol\n+ * @PDCP_DIR_UPLINK: uplink direction\n+ * @PDCP_DIR_DOWNLINK: downlink direction\n+ * @PDCP_DIR_INVALID: invalid option\n+ */\n+enum pdcp_dir {\n+\tPDCP_DIR_UPLINK = 0,\n+\tPDCP_DIR_DOWNLINK = 1,\n+\tPDCP_DIR_INVALID\n+};\n+\n+/**\n+ * enum pdcp_plane - PDCP domain selectors\n+ * @PDCP_CONTROL_PLANE: Control Plane\n+ * @PDCP_DATA_PLANE: Data Plane\n+ * @PDCP_SHORT_MAC: Short MAC\n+ */\n+enum pdcp_plane {\n+\tPDCP_CONTROL_PLANE,\n+\tPDCP_DATA_PLANE,\n+\tPDCP_SHORT_MAC\n+};\n+\n+/**\n+ * enum pdcp_sn_size - Sequence Number Size selectors for PDCP protocol\n+ * @PDCP_SN_SIZE_5: 5bit sequence number\n+ * @PDCP_SN_SIZE_7: 7bit sequence number\n+ * @PDCP_SN_SIZE_12: 12bit sequence number\n+ * @PDCP_SN_SIZE_15: 15bit sequence number\n+ * @PDCP_SN_SIZE_18: 18bit sequence number\n+ */\n+enum pdcp_sn_size {\n+\tPDCP_SN_SIZE_5 = 5,\n+\tPDCP_SN_SIZE_7 = 7,\n+\tPDCP_SN_SIZE_12 = 12,\n+\tPDCP_SN_SIZE_15 = 15\n+};\n+\n+/*\n+ * PDCP Control Plane Protocol Data Blocks\n+ */\n+#define PDCP_C_PLANE_PDB_HFN_SHIFT\t\t5\n+#define PDCP_C_PLANE_PDB_BEARER_SHIFT\t\t27\n+#define PDCP_C_PLANE_PDB_DIR_SHIFT\t\t26\n+#define PDCP_C_PLANE_PDB_HFN_THR_SHIFT\t\t5\n+\n+#define PDCP_U_PLANE_PDB_OPT_SHORT_SN\t\t0x2\n+#define PDCP_U_PLANE_PDB_OPT_15B_SN\t\t0x4\n+#define PDCP_U_PLANE_PDB_SHORT_SN_HFN_SHIFT\t7\n+#define PDCP_U_PLANE_PDB_LONG_SN_HFN_SHIFT\t12\n+#define PDCP_U_PLANE_PDB_15BIT_SN_HFN_SHIFT\t15\n+#define PDCP_U_PLANE_PDB_BEARER_SHIFT\t\t27\n+#define PDCP_U_PLANE_PDB_DIR_SHIFT\t\t26\n+#define PDCP_U_PLANE_PDB_SHORT_SN_HFN_THR_SHIFT\t7\n+#define PDCP_U_PLANE_PDB_LONG_SN_HFN_THR_SHIFT\t12\n+#define PDCP_U_PLANE_PDB_15BIT_SN_HFN_THR_SHIFT\t15\n+\n+struct pdcp_pdb {\n+\tunion {\n+\t\tuint32_t opt;\n+\t\tuint32_t rsvd;\n+\t} opt_res;\n+\tuint32_t hfn_res;\t/* HyperFrame number,(27, 25 or 21 bits),\n+\t\t\t\t * left aligned & right-padded with zeros.\n+\t\t\t\t */\n+\tuint32_t bearer_dir_res;/* Bearer(5 bits), packet direction (1 bit),\n+\t\t\t\t * left aligned & right-padded with zeros.\n+\t\t\t\t */\n+\tuint32_t hfn_thr_res;\t/* HyperFrame number threshold (27, 25 or 21\n+\t\t\t\t * bits), left aligned & right-padded with\n+\t\t\t\t * zeros.\n+\t\t\t\t */\n+};\n+\n+/*\n+ * PDCP internal PDB types\n+ */\n+enum pdb_type_e {\n+\tPDCP_PDB_TYPE_NO_PDB,\n+\tPDCP_PDB_TYPE_FULL_PDB,\n+\tPDCP_PDB_TYPE_REDUCED_PDB,\n+\tPDCP_PDB_TYPE_INVALID\n+};\n+\n+/*\n+ * Function for appending the portion of a PDCP Control Plane shared descriptor\n+ * which performs NULL encryption and integrity (i.e. copies the input frame\n+ * to the output frame, appending 32 bits of zeros at the end (MAC-I for\n+ * NULL integrity).\n+ */\n+static inline int\n+pdcp_insert_cplane_null_op(struct program *p,\n+\t\t\t   bool swap __maybe_unused,\n+\t\t\t   struct alginfo *cipherdata __maybe_unused,\n+\t\t\t   struct alginfo *authdata __maybe_unused,\n+\t\t\t   unsigned int dir,\n+\t\t\t   unsigned char era_2_sw_hfn_ovrd __maybe_unused)\n+{\n+\tLABEL(local_offset);\n+\tREFERENCE(move_cmd_read_descbuf);\n+\tREFERENCE(move_cmd_write_descbuf);\n+\n+\tif (rta_sec_era > RTA_SEC_ERA_2) {\n+\t\tMATHB(p, SEQINSZ, ADD, ZERO, VSEQINSZ, 4, 0);\n+\t\tif (dir == OP_TYPE_ENCAP_PROTOCOL)\n+\t\t\tMATHB(p, SEQINSZ, ADD, PDCP_MAC_I_LEN, VSEQOUTSZ, 4,\n+\t\t\t      IMMED2);\n+\t\telse\n+\t\t\tMATHB(p, SEQINSZ, SUB, PDCP_MAC_I_LEN, VSEQOUTSZ, 4,\n+\t\t\t      IMMED2);\n+\t} else {\n+\t\tMATHB(p, SEQINSZ, ADD, ONE, VSEQINSZ, 4, 0);\n+\t\tMATHB(p, VSEQINSZ, SUB, ONE, VSEQINSZ, 4, 0);\n+\n+\t\tif (dir == OP_TYPE_ENCAP_PROTOCOL) {\n+\t\t\tMATHB(p, SEQINSZ, ADD, PDCP_MAC_I_LEN, VSEQOUTSZ, 4,\n+\t\t\t      IMMED2);\n+\t\t\tMATHB(p, VSEQINSZ, SUB, ONE, MATH0, 4, 0);\n+\t\t} else {\n+\t\t\tMATHB(p, VSEQINSZ, SUB, PDCP_MAC_I_LEN, VSEQINSZ, 4,\n+\t\t\t      IMMED2);\n+\t\t\tMATHB(p, SEQINSZ, SUB, PDCP_MAC_I_LEN, VSEQOUTSZ, 4,\n+\t\t\t      IMMED2);\n+\t\t\tMATHB(p, VSEQOUTSZ, SUB, ONE, MATH0, 4, 0);\n+\t\t}\n+\n+\t\tMATHB(p, MATH0, ADD, ONE, MATH0, 4, 0);\n+\n+\t\t/*\n+\t\t * Since MOVELEN is available only starting with\n+\t\t * SEC ERA 3, use poor man's MOVELEN: create a MOVE\n+\t\t * command dynamically by writing the length from M1 by\n+\t\t * OR-ing the command in the M1 register and MOVE the\n+\t\t * result into the descriptor buffer. Care must be taken\n+\t\t * wrt. the location of the command because of SEC\n+\t\t * pipelining. The actual MOVEs are written at the end\n+\t\t * of the descriptor due to calculations needed on the\n+\t\t * offset in the descriptor for the MOVE command.\n+\t\t */\n+\t\tmove_cmd_read_descbuf = MOVE(p, DESCBUF, 0, MATH0, 0, 6,\n+\t\t\t\t\t     IMMED);\n+\t\tmove_cmd_write_descbuf = MOVE(p, MATH0, 0, DESCBUF, 0, 8,\n+\t\t\t\t\t      WAITCOMP | IMMED);\n+\t}\n+\tMATHB(p, VSEQINSZ, SUB, PDCP_NULL_MAX_FRAME_LEN, NONE, 4,\n+\t      IMMED2);\n+\tJUMP(p, PDCP_MAX_FRAME_LEN_STATUS, HALT_STATUS, ALL_FALSE, MATH_N);\n+\n+\tif (rta_sec_era > RTA_SEC_ERA_2) {\n+\t\tif (dir == OP_TYPE_ENCAP_PROTOCOL)\n+\t\t\tMATHB(p, VSEQINSZ, ADD, ZERO, MATH0, 4, 0);\n+\t\telse\n+\t\t\tMATHB(p, VSEQOUTSZ, ADD, ZERO, MATH0, 4, 0);\n+\t}\n+\tSEQFIFOSTORE(p, MSG, 0, 0, VLF);\n+\tSEQFIFOLOAD(p, MSG1, 0, VLF | LAST1 | FLUSH1);\n+\n+\tif (rta_sec_era > RTA_SEC_ERA_2) {\n+\t\tMOVE(p, AB1, 0, OFIFO, 0, MATH0, 0);\n+\t} else {\n+\t\tSET_LABEL(p, local_offset);\n+\n+\t\t/* Shut off automatic Info FIFO entries */\n+\t\tLOAD(p, 0, DCTRL, LDOFF_DISABLE_AUTO_NFIFO, 0, IMMED);\n+\t\t/* Placeholder for MOVE command with length from M1 register */\n+\t\tMOVE(p, IFIFOAB1, 0, OFIFO, 0, 0, IMMED);\n+\t\t/* Enable automatic Info FIFO entries */\n+\t\tLOAD(p, 0, DCTRL, LDOFF_ENABLE_AUTO_NFIFO, 0, IMMED);\n+\t}\n+\n+\tif (dir == OP_TYPE_ENCAP_PROTOCOL) {\n+\t\tMATHB(p, MATH1, XOR, MATH1, MATH0, 8, 0);\n+\t\tMOVE(p, MATH0, 0, OFIFO, 0, 4, IMMED);\n+\t}\n+\n+\tif (rta_sec_era < RTA_SEC_ERA_3) {\n+\t\tPATCH_MOVE(p, move_cmd_read_descbuf, local_offset);\n+\t\tPATCH_MOVE(p, move_cmd_write_descbuf, local_offset);\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static inline int\n+insert_copy_frame_op(struct program *p,\n+\t\t     struct alginfo *cipherdata __maybe_unused,\n+\t\t     unsigned int dir __maybe_unused)\n+{\n+\tLABEL(local_offset);\n+\tREFERENCE(move_cmd_read_descbuf);\n+\tREFERENCE(move_cmd_write_descbuf);\n+\n+\tif (rta_sec_era > RTA_SEC_ERA_2) {\n+\t\tMATHB(p, SEQINSZ, ADD, ZERO, VSEQINSZ,  4, 0);\n+\t\tMATHB(p, SEQINSZ, ADD, ZERO, VSEQOUTSZ,  4, 0);\n+\t} else {\n+\t\tMATHB(p, SEQINSZ, ADD, ONE, VSEQINSZ,  4, 0);\n+\t\tMATHB(p, VSEQINSZ, SUB, ONE, VSEQINSZ,  4, 0);\n+\t\tMATHB(p, SEQINSZ, ADD, ONE, VSEQOUTSZ,  4, 0);\n+\t\tMATHB(p, VSEQOUTSZ, SUB, ONE, VSEQOUTSZ,  4, 0);\n+\t\tMATHB(p, VSEQINSZ, SUB, ONE, MATH0,  4, 0);\n+\t\tMATHB(p, MATH0, ADD, ONE, MATH0,  4, 0);\n+\n+\t\t/*\n+\t\t * Since MOVELEN is available only starting with\n+\t\t * SEC ERA 3, use poor man's MOVELEN: create a MOVE\n+\t\t * command dynamically by writing the length from M1 by\n+\t\t * OR-ing the command in the M1 register and MOVE the\n+\t\t * result into the descriptor buffer. Care must be taken\n+\t\t * wrt. the location of the command because of SEC\n+\t\t * pipelining. The actual MOVEs are written at the end\n+\t\t * of the descriptor due to calculations needed on the\n+\t\t * offset in the descriptor for the MOVE command.\n+\t\t */\n+\t\tmove_cmd_read_descbuf = MOVE(p, DESCBUF, 0, MATH0, 0, 6,\n+\t\t\t\t\t     IMMED);\n+\t\tmove_cmd_write_descbuf = MOVE(p, MATH0, 0, DESCBUF, 0, 8,\n+\t\t\t\t\t      WAITCOMP | IMMED);\n+\t}\n+\tMATHB(p, SEQINSZ, SUB, PDCP_NULL_MAX_FRAME_LEN, NONE,  4,\n+\t      IFB | IMMED2);\n+\tJUMP(p, PDCP_MAX_FRAME_LEN_STATUS, HALT_STATUS, ALL_FALSE, MATH_N);\n+\n+\tif (rta_sec_era > RTA_SEC_ERA_2)\n+\t\tMATHB(p, VSEQINSZ, ADD, ZERO, MATH0,  4, 0);\n+\n+\tSEQFIFOLOAD(p, MSG1, 0, VLF | LAST1 | FLUSH1);\n+\tif (rta_sec_era > RTA_SEC_ERA_2) {\n+\t\tMOVE(p, AB1, 0, OFIFO, 0, MATH0, 0);\n+\t} else {\n+\t\tSET_LABEL(p, local_offset);\n+\n+\t\t/* Shut off automatic Info FIFO entries */\n+\t\tLOAD(p, 0, DCTRL, LDOFF_DISABLE_AUTO_NFIFO, 0, IMMED);\n+\n+\t\t/* Placeholder for MOVE command with length from M0 register */\n+\t\tMOVE(p, IFIFOAB1, 0, OFIFO, 0, 0, IMMED);\n+\n+\t\t/* Enable automatic Info FIFO entries */\n+\t\tLOAD(p, 0, DCTRL, LDOFF_ENABLE_AUTO_NFIFO, 0, IMMED);\n+\t}\n+\n+\tSEQFIFOSTORE(p, MSG, 0, 0, VLF);\n+\n+\tif (rta_sec_era < RTA_SEC_ERA_3) {\n+\t\tPATCH_MOVE(p, move_cmd_read_descbuf, local_offset);\n+\t\tPATCH_MOVE(p, move_cmd_write_descbuf, local_offset);\n+\t}\n+\treturn 0;\n+}\n+\n+static inline int\n+pdcp_insert_cplane_int_only_op(struct program *p,\n+\t\t\t       bool swap __maybe_unused,\n+\t\t\t       struct alginfo *cipherdata __maybe_unused,\n+\t\t\t       struct alginfo *authdata, unsigned int dir,\n+\t\t\t       unsigned char era_2_sw_hfn_ovrd)\n+{\n+\tLABEL(local_offset);\n+\tREFERENCE(move_cmd_read_descbuf);\n+\tREFERENCE(move_cmd_write_descbuf);\n+\n+\tswitch (authdata->algtype) {\n+\tcase PDCP_AUTH_TYPE_SNOW:\n+\t\t/* Insert Auth Key */\n+\t\tKEY(p, KEY2, authdata->key_enc_flags, authdata->key,\n+\t\t    authdata->keylen, INLINE_KEY(authdata));\n+\t\tSEQLOAD(p, MATH0, 7, 1, 0);\n+\t\tJUMP(p, 1, LOCAL_JUMP, ALL_TRUE, CALM);\n+\n+\t\tif (rta_sec_era > RTA_SEC_ERA_2 ||\n+\t\t    (rta_sec_era == RTA_SEC_ERA_2 &&\n+\t\t\t\t   era_2_sw_hfn_ovrd == 0)) {\n+\t\t\tSEQINPTR(p, 0, 1, RTO);\n+\t\t} else {\n+\t\t\tSEQINPTR(p, 0, 5, RTO);\n+\t\t\tSEQFIFOLOAD(p, SKIP, 4, 0);\n+\t\t}\n+\n+\t\tif (swap == false) {\n+\t\t\tMATHB(p, MATH0, AND, PDCP_C_PLANE_SN_MASK, MATH1,  8,\n+\t\t\t      IFB | IMMED2);\n+\t\t\tMATHB(p, MATH1, SHLD, MATH1, MATH1,  8, 0);\n+\n+\t\t\tMOVEB(p, DESCBUF, 8, MATH2, 0, 8, WAITCOMP | IMMED);\n+\n+\t\t\tMATHB(p, MATH2, AND, PDCP_BEARER_MASK, MATH2, 8,\n+\t\t\t      IMMED2);\n+\t\t\tMOVEB(p, DESCBUF, 0x0C, MATH3, 0, 4, WAITCOMP | IMMED);\n+\t\t\tMATHB(p, MATH3, AND, PDCP_DIR_MASK, MATH3, 8, IMMED2);\n+\t\t\tMATHB(p, MATH1, OR, MATH2, MATH2, 8, 0);\n+\t\t\tMOVEB(p, MATH2, 0, CONTEXT2, 0, 0x0C, WAITCOMP | IMMED);\n+\t\t} else {\n+\t\t\tMATHB(p, MATH0, AND, PDCP_C_PLANE_SN_MASK_BE, MATH1,  8,\n+\t\t\t      IFB | IMMED2);\n+\t\t\tMATHB(p, MATH1, SHLD, MATH1, MATH1,  8, 0);\n+\n+\t\t\tMOVE(p, DESCBUF, 8, MATH2, 0, 8, WAITCOMP | IMMED);\n+\t\t\tMATHB(p, MATH2, AND, PDCP_BEARER_MASK_BE, MATH2, 8,\n+\t\t\t      IMMED2);\n+\n+\t\t\tMOVE(p, DESCBUF, 0x0C, MATH3, 0, 4, WAITCOMP | IMMED);\n+\t\t\tMATHB(p, MATH3, AND, PDCP_DIR_MASK_BE, MATH3, 8,\n+\t\t\t      IMMED2);\n+\t\t\tMATHB(p, MATH1, OR, MATH2, MATH2, 8, 0);\n+\t\t\tMOVE(p, MATH2, 0, CONTEXT2, 0, 0x0C, WAITCOMP | IMMED);\n+\t\t}\n+\n+\t\tif (dir == OP_TYPE_DECAP_PROTOCOL) {\n+\t\t\tMATHB(p, SEQINSZ, SUB, PDCP_MAC_I_LEN, MATH1, 4,\n+\t\t\t      IMMED2);\n+\t\t} else {\n+\t\t\tif (rta_sec_era > RTA_SEC_ERA_2) {\n+\t\t\t\tMATHB(p, SEQINSZ, SUB, ZERO, MATH1, 4,\n+\t\t\t\t      0);\n+\t\t\t} else {\n+\t\t\t\tMATHB(p, SEQINSZ, ADD, ONE, MATH1, 4,\n+\t\t\t\t      0);\n+\t\t\t\tMATHB(p, MATH1, SUB, ONE, MATH1, 4,\n+\t\t\t\t      0);\n+\t\t\t}\n+\t\t}\n+\n+\t\tif (rta_sec_era > RTA_SEC_ERA_2) {\n+\t\t\tMATHB(p, MATH1, SUB, ZERO, VSEQINSZ, 4, 0);\n+\t\t\tMATHB(p, MATH1, SUB, ZERO, VSEQOUTSZ, 4, 0);\n+\t\t} else {\n+\t\t\tMATHB(p, ZERO, ADD, MATH1, VSEQINSZ, 4, 0);\n+\t\t\tMATHB(p, ZERO, ADD, MATH1, VSEQOUTSZ, 4, 0);\n+\n+\t\t\t/*\n+\t\t\t * Since MOVELEN is available only starting with\n+\t\t\t * SEC ERA 3, use poor man's MOVELEN: create a MOVE\n+\t\t\t * command dynamically by writing the length from M1 by\n+\t\t\t * OR-ing the command in the M1 register and MOVE the\n+\t\t\t * result into the descriptor buffer. Care must be taken\n+\t\t\t * wrt. the location of the command because of SEC\n+\t\t\t * pipelining. The actual MOVEs are written at the end\n+\t\t\t * of the descriptor due to calculations needed on the\n+\t\t\t * offset in the descriptor for the MOVE command.\n+\t\t\t */\n+\t\t\tmove_cmd_read_descbuf = MOVE(p, DESCBUF, 0, MATH1, 0, 6,\n+\t\t\t\t\t\t     IMMED);\n+\t\t\tmove_cmd_write_descbuf = MOVE(p, MATH1, 0, DESCBUF, 0,\n+\t\t\t\t\t\t      8, WAITCOMP | IMMED);\n+\t\t}\n+\n+\t\tSEQFIFOSTORE(p, MSG, 0, 0, VLF);\n+\t\tALG_OPERATION(p, OP_ALG_ALGSEL_SNOW_F9, OP_ALG_AAI_F9,\n+\t\t\t      OP_ALG_AS_INITFINAL,\n+\t\t\t      dir == OP_TYPE_ENCAP_PROTOCOL ?\n+\t\t\t\t     ICV_CHECK_DISABLE : ICV_CHECK_ENABLE,\n+\t\t\t      DIR_ENC);\n+\n+\t\tif (rta_sec_era > RTA_SEC_ERA_2) {\n+\t\t\tSEQFIFOLOAD(p, MSGINSNOOP, 0,\n+\t\t\t\t    VLF | LAST1 | LAST2 | FLUSH1);\n+\t\t\tMOVE(p, AB1, 0, OFIFO, 0, MATH1, 0);\n+\t\t} else {\n+\t\t\tSEQFIFOLOAD(p, MSGINSNOOP, 0,\n+\t\t\t\t    VLF | LAST1 | LAST2 | FLUSH1);\n+\t\t\tSET_LABEL(p, local_offset);\n+\n+\t\t\t/* Shut off automatic Info FIFO entries */\n+\t\t\tLOAD(p, 0, DCTRL, LDOFF_DISABLE_AUTO_NFIFO, 0, IMMED);\n+\t\t\t/*\n+\t\t\t * Placeholder for MOVE command with length from M1\n+\t\t\t * register\n+\t\t\t */\n+\t\t\tMOVE(p, IFIFOAB1, 0, OFIFO, 0, 0, IMMED);\n+\t\t\t/* Enable automatic Info FIFO entries */\n+\t\t\tLOAD(p, 0, DCTRL, LDOFF_ENABLE_AUTO_NFIFO, 0, IMMED);\n+\t\t}\n+\n+\t\tif (dir == OP_TYPE_DECAP_PROTOCOL)\n+\t\t\tSEQFIFOLOAD(p, ICV2, 4, LAST2);\n+\t\telse\n+\t\t\tSEQSTORE(p, CONTEXT2, 0, 4, 0);\n+\n+\t\tbreak;\n+\n+\tcase PDCP_AUTH_TYPE_AES:\n+\t\t/* Insert Auth Key */\n+\t\tKEY(p, KEY1, authdata->key_enc_flags, authdata->key,\n+\t\t    authdata->keylen, INLINE_KEY(authdata));\n+\t\tSEQLOAD(p, MATH0, 7, 1, 0);\n+\t\tJUMP(p, 1, LOCAL_JUMP, ALL_TRUE, CALM);\n+\t\tif (rta_sec_era > RTA_SEC_ERA_2 ||\n+\t\t    (rta_sec_era == RTA_SEC_ERA_2 &&\n+\t\t     era_2_sw_hfn_ovrd == 0)) {\n+\t\t\tSEQINPTR(p, 0, 1, RTO);\n+\t\t} else {\n+\t\t\tSEQINPTR(p, 0, 5, RTO);\n+\t\t\tSEQFIFOLOAD(p, SKIP, 4, 0);\n+\t\t}\n+\n+\t\tif (swap == false) {\n+\t\t\tMATHB(p, MATH0, AND, PDCP_C_PLANE_SN_MASK, MATH1, 8,\n+\t\t\t      IFB | IMMED2);\n+\t\t\tMATHB(p, MATH1, SHLD, MATH1, MATH1, 8, 0);\n+\n+\t\t\tMOVEB(p, DESCBUF, 8, MATH2, 0, 8, WAITCOMP | IMMED);\n+\t\t\tMATHB(p, MATH1, OR, MATH2, MATH2, 8, 0);\n+\t\t\tMOVEB(p, MATH2, 0, IFIFOAB1, 0, 8, IMMED);\n+\t\t} else {\n+\t\t\tMATHB(p, MATH0, AND, PDCP_C_PLANE_SN_MASK_BE, MATH1, 8,\n+\t\t\t      IFB | IMMED2);\n+\t\t\tMATHB(p, MATH1, SHLD, MATH1, MATH1, 8, 0);\n+\n+\t\t\tMOVE(p, DESCBUF, 8, MATH2, 0, 8, WAITCOMP | IMMED);\n+\t\t\tMATHB(p, MATH1, OR, MATH2, MATH2, 8, 0);\n+\t\t\tMOVE(p, MATH2, 0, IFIFOAB1, 0, 8, IMMED);\n+\t\t}\n+\n+\t\tif (dir == OP_TYPE_DECAP_PROTOCOL) {\n+\t\t\tMATHB(p, SEQINSZ, SUB, PDCP_MAC_I_LEN, MATH1, 4,\n+\t\t\t      IMMED2);\n+\t\t} else {\n+\t\t\tif (rta_sec_era > RTA_SEC_ERA_2) {\n+\t\t\t\tMATHB(p, SEQINSZ, SUB, ZERO, MATH1, 4,\n+\t\t\t\t      0);\n+\t\t\t} else {\n+\t\t\t\tMATHB(p, SEQINSZ, ADD, ONE, MATH1, 4,\n+\t\t\t\t      0);\n+\t\t\t\tMATHB(p, MATH1, SUB, ONE, MATH1, 4,\n+\t\t\t\t      0);\n+\t\t\t}\n+\t\t}\n+\n+\t\tif (rta_sec_era > RTA_SEC_ERA_2) {\n+\t\t\tMATHB(p, MATH1, SUB, ZERO, VSEQINSZ, 4, 0);\n+\t\t\tMATHB(p, MATH1, SUB, ZERO, VSEQOUTSZ, 4, 0);\n+\t\t} else {\n+\t\t\tMATHB(p, ZERO, ADD, MATH1, VSEQINSZ, 4, 0);\n+\t\t\tMATHB(p, ZERO, ADD, MATH1, VSEQOUTSZ, 4, 0);\n+\n+\t\t\t/*\n+\t\t\t * Since MOVELEN is available only starting with\n+\t\t\t * SEC ERA 3, use poor man's MOVELEN: create a MOVE\n+\t\t\t * command dynamically by writing the length from M1 by\n+\t\t\t * OR-ing the command in the M1 register and MOVE the\n+\t\t\t * result into the descriptor buffer. Care must be taken\n+\t\t\t * wrt. the location of the command because of SEC\n+\t\t\t * pipelining. The actual MOVEs are written at the end\n+\t\t\t * of the descriptor due to calculations needed on the\n+\t\t\t * offset in the descriptor for the MOVE command.\n+\t\t\t */\n+\t\t\tmove_cmd_read_descbuf = MOVE(p, DESCBUF, 0, MATH1, 0, 6,\n+\t\t\t\t\t\t     IMMED);\n+\t\t\tmove_cmd_write_descbuf = MOVE(p, MATH1, 0, DESCBUF, 0,\n+\t\t\t\t\t\t      8, WAITCOMP | IMMED);\n+\t\t}\n+\t\tSEQFIFOSTORE(p, MSG, 0, 0, VLF);\n+\t\tALG_OPERATION(p, OP_ALG_ALGSEL_AES,\n+\t\t\t      OP_ALG_AAI_CMAC,\n+\t\t\t      OP_ALG_AS_INITFINAL,\n+\t\t\t      dir == OP_TYPE_ENCAP_PROTOCOL ?\n+\t\t\t\t     ICV_CHECK_DISABLE : ICV_CHECK_ENABLE,\n+\t\t\t      DIR_ENC);\n+\n+\t\tif (rta_sec_era > RTA_SEC_ERA_2) {\n+\t\t\tMOVE(p, AB2, 0, OFIFO, 0, MATH1, 0);\n+\t\t\tSEQFIFOLOAD(p, MSGINSNOOP, 0,\n+\t\t\t\t    VLF | LAST1 | LAST2 | FLUSH1);\n+\t\t} else {\n+\t\t\tSEQFIFOLOAD(p, MSGINSNOOP, 0,\n+\t\t\t\t    VLF | LAST1 | LAST2 | FLUSH1);\n+\t\t\tSET_LABEL(p, local_offset);\n+\n+\t\t\t/* Shut off automatic Info FIFO entries */\n+\t\t\tLOAD(p, 0, DCTRL, LDOFF_DISABLE_AUTO_NFIFO, 0, IMMED);\n+\n+\t\t\t/*\n+\t\t\t * Placeholder for MOVE command with length from\n+\t\t\t * M1 register\n+\t\t\t */\n+\t\t\tMOVE(p, IFIFOAB2, 0, OFIFO, 0, 0, IMMED);\n+\n+\t\t\t/* Enable automatic Info FIFO entries */\n+\t\t\tLOAD(p, 0, DCTRL, LDOFF_ENABLE_AUTO_NFIFO, 0, IMMED);\n+\t\t}\n+\n+\t\tif (dir == OP_TYPE_DECAP_PROTOCOL)\n+\t\t\tSEQFIFOLOAD(p, ICV1, 4, LAST1 | FLUSH1);\n+\t\telse\n+\t\t\tSEQSTORE(p, CONTEXT1, 0, 4, 0);\n+\n+\t\tbreak;\n+\n+\tcase PDCP_AUTH_TYPE_ZUC:\n+\t\tif (rta_sec_era < RTA_SEC_ERA_5) {\n+\t\t\tpr_err(\"Invalid era for selected algorithm\\n\");\n+\t\t\treturn -ENOTSUP;\n+\t\t}\n+\t\t/* Insert Auth Key */\n+\t\tKEY(p, KEY2, authdata->key_enc_flags, authdata->key,\n+\t\t    authdata->keylen, INLINE_KEY(authdata));\n+\t\tSEQLOAD(p, MATH0, 7, 1, 0);\n+\t\tJUMP(p, 1, LOCAL_JUMP, ALL_TRUE, CALM);\n+\t\tSEQINPTR(p, 0, 1, RTO);\n+\t\tif (swap == false) {\n+\t\t\tMATHB(p, MATH0, AND, PDCP_C_PLANE_SN_MASK, MATH1, 8,\n+\t\t\t      IFB | IMMED2);\n+\t\t\tMATHB(p, MATH1, SHLD, MATH1, MATH1, 8, 0);\n+\n+\t\t\tMOVEB(p, DESCBUF, 8, MATH2, 0, 8, WAITCOMP | IMMED);\n+\t\t\tMATHB(p, MATH1, OR, MATH2, MATH2, 8, 0);\n+\t\t\tMOVEB(p, MATH2, 0, CONTEXT2, 0, 8, IMMED);\n+\n+\t\t} else {\n+\t\t\tMATHB(p, MATH0, AND, PDCP_C_PLANE_SN_MASK_BE, MATH1, 8,\n+\t\t\t      IFB | IMMED2);\n+\t\t\tMATHB(p, MATH1, SHLD, MATH1, MATH1, 8, 0);\n+\n+\t\t\tMOVE(p, DESCBUF, 8, MATH2, 0, 8, WAITCOMP | IMMED);\n+\t\t\tMATHB(p, MATH1, OR, MATH2, MATH2, 8, 0);\n+\t\t\tMOVE(p, MATH2, 0, CONTEXT2, 0, 8, IMMED);\n+\t\t}\n+\t\tif (dir == OP_TYPE_DECAP_PROTOCOL)\n+\t\t\tMATHB(p, SEQINSZ, SUB, PDCP_MAC_I_LEN, MATH1, 4,\n+\t\t\t      IMMED2);\n+\t\telse\n+\t\t\tMATHB(p, SEQINSZ, SUB, ZERO, MATH1, 4, 0);\n+\n+\t\tMATHB(p, MATH1, SUB, ZERO, VSEQINSZ, 4, 0);\n+\t\tMATHB(p, MATH1, SUB, ZERO, VSEQOUTSZ, 4, 0);\n+\t\tSEQFIFOSTORE(p, MSG, 0, 0, VLF);\n+\t\tALG_OPERATION(p, OP_ALG_ALGSEL_ZUCA,\n+\t\t\t      OP_ALG_AAI_F9,\n+\t\t\t      OP_ALG_AS_INITFINAL,\n+\t\t\t      dir == OP_TYPE_ENCAP_PROTOCOL ?\n+\t\t\t\t     ICV_CHECK_DISABLE : ICV_CHECK_ENABLE,\n+\t\t\t      DIR_ENC);\n+\t\tSEQFIFOLOAD(p, MSGINSNOOP, 0, VLF | LAST1 | LAST2 | FLUSH1);\n+\t\tMOVE(p, AB1, 0, OFIFO, 0, MATH1, 0);\n+\n+\t\tif (dir == OP_TYPE_DECAP_PROTOCOL)\n+\t\t\tSEQFIFOLOAD(p, ICV2, 4, LAST2);\n+\t\telse\n+\t\t\tSEQSTORE(p, CONTEXT2, 0, 4, 0);\n+\n+\t\tbreak;\n+\n+\tdefault:\n+\t\tpr_err(\"%s: Invalid integrity algorithm selected: %d\\n\",\n+\t\t       \"pdcp_insert_cplane_int_only_op\", authdata->algtype);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (rta_sec_era < RTA_SEC_ERA_3) {\n+\t\tPATCH_MOVE(p, move_cmd_read_descbuf, local_offset);\n+\t\tPATCH_MOVE(p, move_cmd_write_descbuf, local_offset);\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static inline int\n+pdcp_insert_cplane_enc_only_op(struct program *p,\n+\t\t\t       bool swap __maybe_unused,\n+\t\t\t       struct alginfo *cipherdata,\n+\t\t\t       struct alginfo *authdata __maybe_unused,\n+\t\t\t       unsigned int dir,\n+\t\t\t       unsigned char era_2_sw_hfn_ovrd __maybe_unused)\n+{\n+\t/* Insert Cipher Key */\n+\tKEY(p, KEY1, cipherdata->key_enc_flags, cipherdata->key,\n+\t    cipherdata->keylen, INLINE_KEY(cipherdata));\n+\n+\tif (rta_sec_era >= RTA_SEC_ERA_8) {\n+\t\tPROTOCOL(p, dir, OP_PCLID_LTE_PDCP_CTRL_MIXED,\n+\t\t\t\t(uint16_t)cipherdata->algtype << 8);\n+\t\treturn 0;\n+\t}\n+\n+\tSEQLOAD(p, MATH0, 7, 1, 0);\n+\tJUMP(p, 1, LOCAL_JUMP, ALL_TRUE, CALM);\n+\tif (swap == false)\n+\t\tMATHB(p, MATH0, AND, PDCP_C_PLANE_SN_MASK, MATH1, 8,\n+\t\t\tIFB | IMMED2);\n+\telse\n+\t\tMATHB(p, MATH0, AND, PDCP_C_PLANE_SN_MASK_BE, MATH1, 8,\n+\t\t\tIFB | IMMED2);\n+\tSEQSTORE(p, MATH0, 7, 1, 0);\n+\tMATHB(p, MATH1, SHLD, MATH1, MATH1, 8, 0);\n+\tMOVE(p, DESCBUF, 8, MATH2, 0, 8, WAITCOMP | IMMED);\n+\tMATHB(p, MATH1, OR, MATH2, MATH2, 8, 0);\n+\n+\tswitch (cipherdata->algtype) {\n+\tcase PDCP_CIPHER_TYPE_SNOW:\n+\t\tMOVE(p, MATH2, 0, CONTEXT1, 0, 8, WAITCOMP | IMMED);\n+\n+\t\tif (rta_sec_era > RTA_SEC_ERA_2) {\n+\t\t\tMATHB(p, SEQINSZ, SUB, ZERO, VSEQINSZ, 4, 0);\n+\t\t} else {\n+\t\t\tMATHB(p, SEQINSZ, SUB, ONE, MATH1, 4, 0);\n+\t\t\tMATHB(p, MATH1, ADD, ONE, VSEQINSZ, 4, 0);\n+\t\t}\n+\n+\t\tif (dir == OP_TYPE_ENCAP_PROTOCOL)\n+\t\t\tMATHB(p, SEQINSZ, ADD, PDCP_MAC_I_LEN, VSEQOUTSZ, 4,\n+\t\t\t      IMMED2);\n+\t\telse\n+\t\t\tMATHB(p, SEQINSZ, SUB, PDCP_MAC_I_LEN, VSEQOUTSZ, 4,\n+\t\t\t      IMMED2);\n+\t\tSEQFIFOSTORE(p, MSG, 0, 0, VLF | CONT);\n+\t\tALG_OPERATION(p, OP_ALG_ALGSEL_SNOW_F8,\n+\t\t\t      OP_ALG_AAI_F8,\n+\t\t\t      OP_ALG_AS_INITFINAL, ICV_CHECK_DISABLE,\n+\t\t\t      dir == OP_TYPE_ENCAP_PROTOCOL ?\n+\t\t\t\t\tDIR_ENC : DIR_DEC);\n+\t\tbreak;\n+\n+\tcase PDCP_CIPHER_TYPE_AES:\n+\t\tMOVE(p, MATH2, 0, CONTEXT1, 0x10, 0x10, WAITCOMP | IMMED);\n+\n+\t\tif (rta_sec_era > RTA_SEC_ERA_2) {\n+\t\t\tMATHB(p, SEQINSZ, SUB, ZERO, VSEQINSZ, 4, 0);\n+\t\t} else {\n+\t\t\tMATHB(p, SEQINSZ, SUB, ONE, MATH1, 4, 0);\n+\t\t\tMATHB(p, MATH1, ADD, ONE, VSEQINSZ, 4, 0);\n+\t\t}\n+\n+\t\tif (dir == OP_TYPE_ENCAP_PROTOCOL)\n+\t\t\tMATHB(p, SEQINSZ, ADD, PDCP_MAC_I_LEN, VSEQOUTSZ, 4,\n+\t\t\t      IMMED2);\n+\t\telse\n+\t\t\tMATHB(p, SEQINSZ, SUB, PDCP_MAC_I_LEN, VSEQOUTSZ, 4,\n+\t\t\t      IMMED2);\n+\n+\t\tSEQFIFOSTORE(p, MSG, 0, 0, VLF | CONT);\n+\t\tALG_OPERATION(p, OP_ALG_ALGSEL_AES,\n+\t\t\t      OP_ALG_AAI_CTR,\n+\t\t\t      OP_ALG_AS_INITFINAL,\n+\t\t\t      ICV_CHECK_DISABLE,\n+\t\t\t      dir == OP_TYPE_ENCAP_PROTOCOL ?\n+\t\t\t\t\tDIR_ENC : DIR_DEC);\n+\t\tbreak;\n+\n+\tcase PDCP_CIPHER_TYPE_ZUC:\n+\t\tif (rta_sec_era < RTA_SEC_ERA_5) {\n+\t\t\tpr_err(\"Invalid era for selected algorithm\\n\");\n+\t\t\treturn -ENOTSUP;\n+\t\t}\n+\n+\t\tMOVE(p, MATH2, 0, CONTEXT1, 0, 0x08, IMMED);\n+\t\tMOVE(p, MATH2, 0, CONTEXT1, 0x08, 0x08, WAITCOMP | IMMED);\n+\t\tMATHB(p, SEQINSZ, SUB, ZERO, VSEQINSZ, 4, 0);\n+\t\tif (dir == OP_TYPE_ENCAP_PROTOCOL)\n+\t\t\tMATHB(p, SEQINSZ, ADD, PDCP_MAC_I_LEN, VSEQOUTSZ, 4,\n+\t\t\t      IMMED2);\n+\t\telse\n+\t\t\tMATHB(p, SEQINSZ, SUB, PDCP_MAC_I_LEN, VSEQOUTSZ, 4,\n+\t\t\t      IMMED2);\n+\n+\t\tSEQFIFOSTORE(p, MSG, 0, 0, VLF | CONT);\n+\t\tALG_OPERATION(p, OP_ALG_ALGSEL_ZUCE,\n+\t\t\t      OP_ALG_AAI_F8,\n+\t\t\t      OP_ALG_AS_INITFINAL,\n+\t\t\t      ICV_CHECK_DISABLE,\n+\t\t\t      dir == OP_TYPE_ENCAP_PROTOCOL ?\n+\t\t\t\t\tDIR_ENC : DIR_DEC);\n+\t\tbreak;\n+\n+\tdefault:\n+\t\tpr_err(\"%s: Invalid encrypt algorithm selected: %d\\n\",\n+\t\t       \"pdcp_insert_cplane_enc_only_op\", cipherdata->algtype);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (dir == OP_TYPE_ENCAP_PROTOCOL) {\n+\t\tSEQFIFOLOAD(p, MSG1, 0, VLF);\n+\t\tFIFOLOAD(p, MSG1, PDCP_NULL_INT_MAC_I_VAL, 4,\n+\t\t\t LAST1 | FLUSH1 | IMMED);\n+\t} else {\n+\t\tSEQFIFOLOAD(p, MSG1, 0, VLF | LAST1 | FLUSH1);\n+\t\tMOVE(p, OFIFO, 0, MATH1, 4, PDCP_MAC_I_LEN, WAITCOMP | IMMED);\n+\t\tMATHB(p, MATH1, XOR, PDCP_NULL_INT_MAC_I_VAL, NONE, 4, IMMED2);\n+\t\tJUMP(p, PDCP_NULL_INT_ICV_CHECK_FAILED_STATUS,\n+\t\t     HALT_STATUS, ALL_FALSE, MATH_Z);\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static inline int\n+pdcp_insert_cplane_acc_op(struct program *p,\n+\t\t\t  bool swap __maybe_unused,\n+\t\t\t  struct alginfo *cipherdata,\n+\t\t\t  struct alginfo *authdata,\n+\t\t\t  unsigned int dir,\n+\t\t\t  unsigned char era_2_hfn_ovrd __maybe_unused)\n+{\n+\t/* Insert Auth Key */\n+\tKEY(p, KEY2, authdata->key_enc_flags, authdata->key, authdata->keylen,\n+\t    INLINE_KEY(authdata));\n+\n+\t/* Insert Cipher Key */\n+\tKEY(p, KEY1, cipherdata->key_enc_flags, cipherdata->key,\n+\t    cipherdata->keylen, INLINE_KEY(cipherdata));\n+\tPROTOCOL(p, dir, OP_PCLID_LTE_PDCP_CTRL, (uint16_t)cipherdata->algtype);\n+\n+\treturn 0;\n+}\n+\n+static inline int\n+pdcp_insert_cplane_snow_aes_op(struct program *p,\n+\t\t\t       bool swap __maybe_unused,\n+\t\t\t       struct alginfo *cipherdata,\n+\t\t\t       struct alginfo *authdata,\n+\t\t\t       unsigned int dir,\n+\t\t\t       unsigned char era_2_sw_hfn_ovrd)\n+{\n+\tLABEL(back_to_sd_offset);\n+\tLABEL(end_desc);\n+\tLABEL(local_offset);\n+\tLABEL(jump_to_beginning);\n+\tLABEL(fifo_load_mac_i_offset);\n+\tREFERENCE(seqin_ptr_read);\n+\tREFERENCE(seqin_ptr_write);\n+\tREFERENCE(seq_out_read);\n+\tREFERENCE(jump_back_to_sd_cmd);\n+\tREFERENCE(move_mac_i_to_desc_buf);\n+\n+\tif (rta_sec_era >= RTA_SEC_ERA_8) {\n+\t\tKEY(p, KEY1, cipherdata->key_enc_flags, cipherdata->key,\n+\t\t\t\tcipherdata->keylen, INLINE_KEY(cipherdata));\n+\t\tKEY(p, KEY2, authdata->key_enc_flags, authdata->key,\n+\t\t\t\tauthdata->keylen, INLINE_KEY(authdata));\n+\n+\t\tPROTOCOL(p, dir, OP_PCLID_LTE_PDCP_CTRL_MIXED,\n+\t\t\t ((uint16_t)cipherdata->algtype << 8) |\n+\t\t\t (uint16_t)authdata->algtype);\n+\n+\t\treturn 0;\n+\t}\n+\n+\tSEQLOAD(p, MATH0, 7, 1, 0);\n+\tJUMP(p, 1, LOCAL_JUMP, ALL_TRUE, CALM);\n+\tif (swap == false)\n+\t\tMATHB(p, MATH0, AND, PDCP_C_PLANE_SN_MASK, MATH1, 8,\n+\t\t\tIFB | IMMED2);\n+\telse\n+\t\tMATHB(p, MATH0, AND, PDCP_C_PLANE_SN_MASK_BE, MATH1, 8,\n+\t\t\tIFB | IMMED2);\n+\tMATHB(p, MATH1, SHLD, MATH1, MATH1, 8, 0);\n+\tMOVE(p, DESCBUF, 4, MATH2, 0, 0x08, WAITCOMP | IMMED);\n+\tMATHB(p, MATH1, OR, MATH2, MATH2, 8, 0);\n+\tSEQSTORE(p, MATH0, 7, 1, 0);\n+\tif (dir == OP_TYPE_ENCAP_PROTOCOL) {\n+\t\tif (rta_sec_era > RTA_SEC_ERA_2 ||\n+\t\t    (rta_sec_era == RTA_SEC_ERA_2 &&\n+\t\t\t\t   era_2_sw_hfn_ovrd == 0)) {\n+\t\t\tSEQINPTR(p, 0, 1, RTO);\n+\t\t} else {\n+\t\t\tSEQINPTR(p, 0, 5, RTO);\n+\t\t\tSEQFIFOLOAD(p, SKIP, 4, 0);\n+\t\t}\n+\t\tKEY(p, KEY1, authdata->key_enc_flags, authdata->key,\n+\t\t    authdata->keylen, INLINE_KEY(authdata));\n+\t\tMOVE(p, MATH2, 0, IFIFOAB1, 0, 0x08, IMMED);\n+\n+\t\tif (rta_sec_era > RTA_SEC_ERA_2) {\n+\t\t\tMATHB(p, SEQINSZ, SUB, ZERO, VSEQINSZ, 4, 0);\n+\t\t\tMATHB(p, SEQINSZ, SUB, ZERO, MATH1, 4, 0);\n+\t\t\tMATHB(p, VSEQINSZ, ADD, PDCP_MAC_I_LEN - 1, VSEQOUTSZ,\n+\t\t\t      4, IMMED2);\n+\t\t} else {\n+\t\t\tMATHB(p, SEQINSZ, SUB, MATH3, VSEQINSZ, 4, 0);\n+\t\t\tMATHB(p, VSEQINSZ, ADD, PDCP_MAC_I_LEN - 1, VSEQOUTSZ,\n+\t\t\t      4, IMMED2);\n+\t\t\t/*\n+\t\t\t * Note: Although the calculations below might seem a\n+\t\t\t * little off, the logic is the following:\n+\t\t\t *\n+\t\t\t * - SEQ IN PTR RTO below needs the full length of the\n+\t\t\t *   frame; in case of P4080_REV_2_HFN_OV_WORKAROUND,\n+\t\t\t *   this means the length of the frame to be processed\n+\t\t\t *   + 4 bytes (the HFN override flag and value).\n+\t\t\t *   The length of the frame to be processed minus 1\n+\t\t\t *   byte is in the VSIL register (because\n+\t\t\t *   VSIL = SIL + 3, due to 1 byte, the header being\n+\t\t\t *   already written by the SEQ STORE above). So for\n+\t\t\t *   calculating the length to use in RTO, I add one\n+\t\t\t *   to the VSIL value in order to obtain the total\n+\t\t\t *   frame length. This helps in case of P4080 which\n+\t\t\t *   can have the value 0 as an operand in a MATH\n+\t\t\t *   command only as SRC1 When the HFN override\n+\t\t\t *   workaround is not enabled, the length of the\n+\t\t\t *   frame is given by the SIL register; the\n+\t\t\t *   calculation is similar to the one in the SEC 4.2\n+\t\t\t *   and SEC 5.3 cases.\n+\t\t\t */\n+\t\t\tif (era_2_sw_hfn_ovrd)\n+\t\t\t\tMATHB(p, VSEQOUTSZ, ADD, ONE, MATH1, 4,\n+\t\t\t\t      0);\n+\t\t\telse\n+\t\t\t\tMATHB(p, SEQINSZ, ADD, MATH3, MATH1, 4,\n+\t\t\t\t      0);\n+\t\t}\n+\t\t/*\n+\t\t * Placeholder for filling the length in\n+\t\t * SEQIN PTR RTO below\n+\t\t */\n+\t\tseqin_ptr_read = MOVE(p, DESCBUF, 0, MATH1, 0, 6, IMMED);\n+\t\tseqin_ptr_write = MOVE(p, MATH1, 0, DESCBUF, 0, 8,\n+\t\t\t\t       WAITCOMP | IMMED);\n+\t\tALG_OPERATION(p, OP_ALG_ALGSEL_AES,\n+\t\t\t      OP_ALG_AAI_CMAC,\n+\t\t\t      OP_ALG_AS_INITFINAL,\n+\t\t\t      ICV_CHECK_DISABLE,\n+\t\t\t      DIR_DEC);\n+\t\tSEQFIFOLOAD(p, MSG1, 0, VLF | LAST1 | FLUSH1);\n+\t\tMOVE(p, CONTEXT1, 0, MATH3, 0, 4, WAITCOMP | IMMED);\n+\t\tif (rta_sec_era <= RTA_SEC_ERA_3)\n+\t\t\tLOAD(p, CLRW_CLR_C1KEY |\n+\t\t\t     CLRW_CLR_C1CTX |\n+\t\t\t     CLRW_CLR_C1ICV |\n+\t\t\t     CLRW_CLR_C1DATAS |\n+\t\t\t     CLRW_CLR_C1MODE,\n+\t\t\t     CLRW, 0, 4, IMMED);\n+\t\telse\n+\t\t\tLOAD(p, CLRW_RESET_CLS1_CHA |\n+\t\t\t     CLRW_CLR_C1KEY |\n+\t\t\t     CLRW_CLR_C1CTX |\n+\t\t\t     CLRW_CLR_C1ICV |\n+\t\t\t     CLRW_CLR_C1DATAS |\n+\t\t\t     CLRW_CLR_C1MODE,\n+\t\t\t     CLRW, 0, 4, IMMED);\n+\n+\t\tif (rta_sec_era <= RTA_SEC_ERA_3)\n+\t\t\tLOAD(p, CCTRL_RESET_CHA_ALL, CCTRL, 0, 4, IMMED);\n+\n+\t\tKEY(p, KEY1, cipherdata->key_enc_flags, cipherdata->key,\n+\t\t    cipherdata->keylen, INLINE_KEY(cipherdata));\n+\t\tSET_LABEL(p, local_offset);\n+\t\tMOVE(p, MATH2, 0, CONTEXT1, 0, 8, IMMED);\n+\t\tSEQINPTR(p, 0, 0, RTO);\n+\n+\t\tif (rta_sec_era == RTA_SEC_ERA_2 && era_2_sw_hfn_ovrd) {\n+\t\t\tSEQFIFOLOAD(p, SKIP, 5, 0);\n+\t\t\tMATHB(p, SEQINSZ, ADD, ONE, SEQINSZ, 4, 0);\n+\t\t}\n+\n+\t\tMATHB(p, SEQINSZ, SUB, ONE, VSEQINSZ, 4, 0);\n+\t\tALG_OPERATION(p, OP_ALG_ALGSEL_SNOW_F8,\n+\t\t\t      OP_ALG_AAI_F8,\n+\t\t\t      OP_ALG_AS_INITFINAL,\n+\t\t\t      ICV_CHECK_DISABLE,\n+\t\t\t      DIR_ENC);\n+\t\tSEQFIFOSTORE(p, MSG, 0, 0, VLF);\n+\n+\t\tif (rta_sec_era > RTA_SEC_ERA_2 ||\n+\t\t    (rta_sec_era == RTA_SEC_ERA_2 &&\n+\t\t\t\t   era_2_sw_hfn_ovrd == 0))\n+\t\t\tSEQFIFOLOAD(p, SKIP, 1, 0);\n+\n+\t\tSEQFIFOLOAD(p, MSG1, 0, VLF);\n+\t\tMOVE(p, MATH3, 0, IFIFOAB1, 0, 4, LAST1 | FLUSH1 | IMMED);\n+\t\tPATCH_MOVE(p, seqin_ptr_read, local_offset);\n+\t\tPATCH_MOVE(p, seqin_ptr_write, local_offset);\n+\t} else {\n+\t\tMOVE(p, MATH2, 0, CONTEXT1, 0, 8, IMMED);\n+\n+\t\tif (rta_sec_era >= RTA_SEC_ERA_5)\n+\t\t\tMOVE(p, CONTEXT1, 0, CONTEXT2, 0, 8, IMMED);\n+\n+\t\tif (rta_sec_era > RTA_SEC_ERA_2)\n+\t\t\tMATHB(p, SEQINSZ, SUB, ZERO, VSEQINSZ, 4, 0);\n+\t\telse\n+\t\t\tMATHB(p, SEQINSZ, SUB, MATH3, VSEQINSZ, 4, 0);\n+\n+\t\tMATHB(p, SEQINSZ, SUB, PDCP_MAC_I_LEN, VSEQOUTSZ, 4, IMMED2);\n+/*\n+ * TODO: To be changed when proper support is added in RTA (can't load a\n+ * command that is also written by RTA (or patch it for that matter).\n+ * Change when proper RTA support is added.\n+ */\n+\t\tif (p->ps)\n+\t\t\tWORD(p, 0x168B0004);\n+\t\telse\n+\t\t\tWORD(p, 0x16880404);\n+\n+\t\tjump_back_to_sd_cmd = JUMP(p, 0, LOCAL_JUMP, ALL_TRUE, 0);\n+\t\t/*\n+\t\t * Placeholder for command reading  the SEQ OUT command in\n+\t\t * JD. Done for rereading the decrypted data and performing\n+\t\t * the integrity check\n+\t\t */\n+/*\n+ * TODO: RTA currently doesn't support patching of length of a MOVE command\n+ * Thus, it is inserted as a raw word, as per PS setting.\n+ */\n+\t\tif (p->ps)\n+\t\t\tseq_out_read = MOVE(p, DESCBUF, 0, MATH1, 0, 20,\n+\t\t\t\t\t    WAITCOMP | IMMED);\n+\t\telse\n+\t\t\tseq_out_read = MOVE(p, DESCBUF, 0, MATH1, 0, 16,\n+\t\t\t\t\t    WAITCOMP | IMMED);\n+\n+\t\tMATHB(p, MATH1, XOR, CMD_SEQ_IN_PTR ^ CMD_SEQ_OUT_PTR, MATH1, 4,\n+\t\t      IMMED2);\n+\t\t/* Placeholder for overwriting the SEQ IN  with SEQ OUT */\n+/*\n+ * TODO: RTA currently doesn't support patching of length of a MOVE command\n+ * Thus, it is inserted as a raw word, as per PS setting.\n+ */\n+\t\tif (p->ps)\n+\t\t\tMOVE(p, MATH1, 0, DESCBUF, 0, 24, IMMED);\n+\t\telse\n+\t\t\tMOVE(p, MATH1, 0, DESCBUF, 0, 20, IMMED);\n+\n+\t\tKEY(p, KEY1, cipherdata->key_enc_flags, cipherdata->key,\n+\t\t    cipherdata->keylen, INLINE_KEY(cipherdata));\n+\n+\t\tif (rta_sec_era >= RTA_SEC_ERA_4)\n+\t\t\tMOVE(p, CONTEXT1, 0, CONTEXT2, 0, 8, IMMED);\n+\t\telse\n+\t\t\tMOVE(p, CONTEXT1, 0, MATH3, 0, 8, IMMED);\n+\n+\t\tALG_OPERATION(p, OP_ALG_ALGSEL_SNOW_F8,\n+\t\t\t      OP_ALG_AAI_F8,\n+\t\t\t      OP_ALG_AS_INITFINAL,\n+\t\t\t      ICV_CHECK_DISABLE,\n+\t\t\t      DIR_DEC);\n+\t\tSEQFIFOSTORE(p, MSG, 0, 0, VLF | CONT);\n+\t\tSEQFIFOLOAD(p, MSG1, 0, VLF | LAST1 | FLUSH1);\n+\n+\t\tif (rta_sec_era <= RTA_SEC_ERA_3)\n+\t\t\tmove_mac_i_to_desc_buf = MOVE(p, OFIFO, 0, DESCBUF, 0,\n+\t\t\t\t\t\t      4, WAITCOMP | IMMED);\n+\t\telse\n+\t\t\tMOVE(p, OFIFO, 0, MATH3, 0, 4, IMMED);\n+\n+\t\tif (rta_sec_era <= RTA_SEC_ERA_3)\n+\t\t\tLOAD(p, CCTRL_RESET_CHA_ALL, CCTRL, 0, 4, IMMED);\n+\t\telse\n+\t\t\tLOAD(p, CLRW_RESET_CLS1_CHA |\n+\t\t\t     CLRW_CLR_C1KEY |\n+\t\t\t     CLRW_CLR_C1CTX |\n+\t\t\t     CLRW_CLR_C1ICV |\n+\t\t\t     CLRW_CLR_C1DATAS |\n+\t\t\t     CLRW_CLR_C1MODE,\n+\t\t\t     CLRW, 0, 4, IMMED);\n+\n+\t\tKEY(p, KEY1, authdata->key_enc_flags, authdata->key,\n+\t\t    authdata->keylen, INLINE_KEY(authdata));\n+\t\t/*\n+\t\t * Placeholder for jump in SD for executing the new SEQ IN PTR\n+\t\t * command (which is actually the old SEQ OUT PTR command\n+\t\t * copied over from JD.\n+\t\t */\n+\t\tSET_LABEL(p, jump_to_beginning);\n+\t\tJUMP(p, 1 - jump_to_beginning, LOCAL_JUMP, ALL_TRUE, 0);\n+\t\tSET_LABEL(p, back_to_sd_offset);\n+\t\tALG_OPERATION(p, OP_ALG_ALGSEL_AES,\n+\t\t\t      OP_ALG_AAI_CMAC,\n+\t\t\t      OP_ALG_AS_INITFINAL,\n+\t\t\t      ICV_CHECK_ENABLE,\n+\t\t\t      DIR_DEC);\n+\n+\t\t/* Read the # of bytes written in the output buffer + 1 (HDR) */\n+\t\tMATHB(p, VSEQOUTSZ, ADD, ONE, VSEQINSZ, 4, 0);\n+\n+\t\tif (rta_sec_era <= RTA_SEC_ERA_3)\n+\t\t\tMOVE(p, MATH3, 0, IFIFOAB1, 0, 8, IMMED);\n+\t\telse\n+\t\t\tMOVE(p, CONTEXT2, 0, IFIFOAB1, 0, 8, IMMED);\n+\n+\t\tif (rta_sec_era == RTA_SEC_ERA_2 && era_2_sw_hfn_ovrd)\n+\t\t\tSEQFIFOLOAD(p, SKIP, 4, 0);\n+\n+\t\tSEQFIFOLOAD(p, MSG1, 0, VLF | LAST1 | FLUSH1);\n+\n+\t\tif (rta_sec_era >= RTA_SEC_ERA_4) {\n+\t\t\tLOAD(p, NFIFOENTRY_STYPE_ALTSOURCE |\n+\t\t\t     NFIFOENTRY_DEST_CLASS1 |\n+\t\t\t     NFIFOENTRY_DTYPE_ICV |\n+\t\t\t     NFIFOENTRY_LC1 |\n+\t\t\t     NFIFOENTRY_FC1 | 4, NFIFO_SZL, 0, 4, IMMED);\n+\t\t\tMOVE(p, MATH3, 0, ALTSOURCE, 0, 4, IMMED);\n+\t\t} else {\n+\t\t\tSET_LABEL(p, fifo_load_mac_i_offset);\n+\t\t\tFIFOLOAD(p, ICV1, fifo_load_mac_i_offset, 4,\n+\t\t\t\t LAST1 | FLUSH1 | IMMED);\n+\t\t}\n+\n+\t\tSET_LABEL(p, end_desc);\n+\n+\t\tif (!p->ps) {\n+\t\t\tPATCH_MOVE(p, seq_out_read, end_desc + 1);\n+\t\t\tPATCH_JUMP(p, jump_back_to_sd_cmd,\n+\t\t\t\t   back_to_sd_offset + jump_back_to_sd_cmd - 5);\n+\n+\t\t\tif (rta_sec_era <= RTA_SEC_ERA_3)\n+\t\t\t\tPATCH_MOVE(p, move_mac_i_to_desc_buf,\n+\t\t\t\t\t   fifo_load_mac_i_offset + 1);\n+\t\t} else {\n+\t\t\tPATCH_MOVE(p, seq_out_read, end_desc + 2);\n+\t\t\tPATCH_JUMP(p, jump_back_to_sd_cmd,\n+\t\t\t\t   back_to_sd_offset + jump_back_to_sd_cmd - 5);\n+\n+\t\t\tif (rta_sec_era <= RTA_SEC_ERA_3)\n+\t\t\t\tPATCH_MOVE(p, move_mac_i_to_desc_buf,\n+\t\t\t\t\t   fifo_load_mac_i_offset + 1);\n+\t\t}\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static inline int\n+pdcp_insert_cplane_aes_snow_op(struct program *p,\n+\t\t\t       bool swap __maybe_unused,\n+\t\t\t       struct alginfo *cipherdata,\n+\t\t\t       struct alginfo *authdata,\n+\t\t\t       unsigned int dir,\n+\t\t\t       unsigned char era_2_sw_hfn_ovrd __maybe_unused)\n+{\n+\tKEY(p, KEY1, cipherdata->key_enc_flags, cipherdata->key,\n+\t    cipherdata->keylen, INLINE_KEY(cipherdata));\n+\tKEY(p, KEY2, authdata->key_enc_flags, authdata->key, authdata->keylen,\n+\t    INLINE_KEY(authdata));\n+\n+\tif (rta_sec_era >= RTA_SEC_ERA_8) {\n+\t\tPROTOCOL(p, dir, OP_PCLID_LTE_PDCP_CTRL_MIXED,\n+\t\t\t ((uint16_t)cipherdata->algtype << 8) |\n+\t\t\t (uint16_t)authdata->algtype);\n+\n+\t\treturn 0;\n+\t}\n+\n+\tif (dir == OP_TYPE_ENCAP_PROTOCOL)\n+\t\tMATHB(p, SEQINSZ, SUB, ONE, VSEQINSZ, 4, 0);\n+\n+\tSEQLOAD(p, MATH0, 7, 1, 0);\n+\tJUMP(p, 1, LOCAL_JUMP, ALL_TRUE, CALM);\n+\tMOVE(p, MATH0, 7, IFIFOAB2, 0, 1, IMMED);\n+\tif (swap == false)\n+\t\tMATHB(p, MATH0, AND, PDCP_C_PLANE_SN_MASK, MATH1, 8,\n+\t\t\tIFB | IMMED2);\n+\telse\n+\t\tMATHB(p, MATH0, AND, PDCP_C_PLANE_SN_MASK_BE, MATH1, 8,\n+\t\t\tIFB | IMMED2);\n+\n+\tSEQSTORE(p, MATH0, 7, 1, 0);\n+\tMATHB(p, MATH1, SHLD, MATH1, MATH1, 8, 0);\n+\tMOVE(p, DESCBUF, 4, MATH2, 0, 8, WAITCOMP | IMMED);\n+\tMATHB(p, MATH1, OR, MATH2, MATH1, 8, 0);\n+\tMOVE(p, MATH1, 0, CONTEXT1, 16, 8, IMMED);\n+\tMOVE(p, MATH1, 0, CONTEXT2, 0, 4, IMMED);\n+\tif (swap == false) {\n+\t\tMATHB(p, MATH1, AND, lower_32_bits(PDCP_BEARER_MASK), MATH2, 4,\n+\t\t\tIMMED2);\n+\t\tMATHB(p, MATH1, AND, upper_32_bits(PDCP_DIR_MASK), MATH3, 4,\n+\t\t\tIMMED2);\n+\t} else {\n+\t\tMATHB(p, MATH1, AND, lower_32_bits(PDCP_BEARER_MASK_BE), MATH2,\n+\t\t\t4, IMMED2);\n+\t\tMATHB(p, MATH1, AND, upper_32_bits(PDCP_DIR_MASK_BE), MATH3,\n+\t\t\t4, IMMED2);\n+\t}\n+\tMATHB(p, MATH3, SHLD, MATH3, MATH3, 8, 0);\n+\tMOVE(p, MATH2, 4, OFIFO, 0, 12, IMMED);\n+\tMOVE(p, OFIFO, 0, CONTEXT2, 4, 12, IMMED);\n+\tif (dir == OP_TYPE_ENCAP_PROTOCOL) {\n+\t\tMATHB(p, SEQINSZ, ADD, PDCP_MAC_I_LEN, VSEQOUTSZ, 4, IMMED2);\n+\t} else {\n+\t\tMATHB(p, SEQINSZ, SUB, PDCP_MAC_I_LEN, MATH1, 4, IMMED2);\n+\n+\t\tMATHB(p, ZERO, ADD, MATH1, VSEQOUTSZ, 4, 0);\n+\t\tMATHB(p, ZERO, ADD, MATH1, VSEQINSZ, 4, 0);\n+\t}\n+\n+\tif (dir == OP_TYPE_ENCAP_PROTOCOL)\n+\t\tSEQFIFOSTORE(p, MSG, 0, 0, VLF);\n+\telse\n+\t\tSEQFIFOSTORE(p, MSG, 0, 0, VLF | CONT);\n+\n+\tALG_OPERATION(p, OP_ALG_ALGSEL_SNOW_F9,\n+\t\t      OP_ALG_AAI_F9,\n+\t\t      OP_ALG_AS_INITFINAL,\n+\t\t      dir == OP_TYPE_ENCAP_PROTOCOL ?\n+\t\t\t     ICV_CHECK_DISABLE : ICV_CHECK_ENABLE,\n+\t\t      DIR_DEC);\n+\tALG_OPERATION(p, OP_ALG_ALGSEL_AES,\n+\t\t      OP_ALG_AAI_CTR,\n+\t\t      OP_ALG_AS_INITFINAL,\n+\t\t      ICV_CHECK_DISABLE,\n+\t\t      dir == OP_TYPE_ENCAP_PROTOCOL ? DIR_ENC : DIR_DEC);\n+\n+\tif (dir == OP_TYPE_ENCAP_PROTOCOL) {\n+\t\tSEQFIFOLOAD(p, MSGINSNOOP, 0, VLF | LAST2);\n+\t\tMOVE(p, CONTEXT2, 0, IFIFOAB1, 0, 4, LAST1 | FLUSH1 | IMMED);\n+\t} else {\n+\t\tSEQFIFOLOAD(p, MSGOUTSNOOP, 0, VLF | LAST2);\n+\t\tSEQFIFOLOAD(p, MSG1, 4, LAST1 | FLUSH1);\n+\t\tJUMP(p, 1, LOCAL_JUMP, ALL_TRUE, CLASS1 | NOP | NIFP);\n+\n+\t\tif (rta_sec_era >= RTA_SEC_ERA_6)\n+\t\t\tLOAD(p, 0, DCTRL, 0, LDLEN_RST_CHA_OFIFO_PTR, IMMED);\n+\n+\t\tMOVE(p, OFIFO, 0, MATH0, 0, 4, WAITCOMP | IMMED);\n+\n+\t\tNFIFOADD(p, IFIFO, ICV2, 4, LAST2);\n+\n+\t\tif (rta_sec_era <= RTA_SEC_ERA_2) {\n+\t\t\t/* Shut off automatic Info FIFO entries */\n+\t\t\tLOAD(p, 0, DCTRL, LDOFF_DISABLE_AUTO_NFIFO, 0, IMMED);\n+\t\t\tMOVE(p, MATH0, 0, IFIFOAB2, 0, 4, WAITCOMP | IMMED);\n+\t\t} else {\n+\t\t\tMOVE(p, MATH0, 0, IFIFO, 0, 4, WAITCOMP | IMMED);\n+\t\t}\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static inline int\n+pdcp_insert_cplane_snow_zuc_op(struct program *p,\n+\t\t\t       bool swap __maybe_unused,\n+\t\t\t       struct alginfo *cipherdata,\n+\t\t\t       struct alginfo *authdata,\n+\t\t\t       unsigned int dir,\n+\t\t\t       unsigned char era_2_sw_hfn_ovrd __maybe_unused)\n+{\n+\tLABEL(keyjump);\n+\tREFERENCE(pkeyjump);\n+\n+\tif (rta_sec_era < RTA_SEC_ERA_5) {\n+\t\tpr_err(\"Invalid era for selected algorithm\\n\");\n+\t\treturn -ENOTSUP;\n+\t}\n+\n+\tpkeyjump = JUMP(p, keyjump, LOCAL_JUMP, ALL_TRUE, SHRD | SELF | BOTH);\n+\tKEY(p, KEY1, cipherdata->key_enc_flags, cipherdata->key,\n+\t    cipherdata->keylen, INLINE_KEY(cipherdata));\n+\tKEY(p, KEY2, authdata->key_enc_flags, authdata->key, authdata->keylen,\n+\t    INLINE_KEY(authdata));\n+\n+\tSET_LABEL(p, keyjump);\n+\n+\tif (rta_sec_era >= RTA_SEC_ERA_8) {\n+\t\tPROTOCOL(p, dir, OP_PCLID_LTE_PDCP_CTRL_MIXED,\n+\t\t\t ((uint16_t)cipherdata->algtype << 8) |\n+\t\t\t (uint16_t)authdata->algtype);\n+\t\treturn 0;\n+\t}\n+\n+\tSEQLOAD(p, MATH0, 7, 1, 0);\n+\tJUMP(p, 1, LOCAL_JUMP, ALL_TRUE, CALM);\n+\tMOVE(p, MATH0, 7, IFIFOAB2, 0, 1, IMMED);\n+\tif (swap == false)\n+\t\tMATHB(p, MATH0, AND, PDCP_C_PLANE_SN_MASK, MATH1, 8,\n+\t\t\tIFB | IMMED2);\n+\telse\n+\t\tMATHB(p, MATH0, AND, PDCP_C_PLANE_SN_MASK, MATH1, 8,\n+\t\t\tIFB | IMMED2);\n+\n+\tMATHB(p, MATH1, SHLD, MATH1, MATH1, 8, 0);\n+\tMOVE(p, DESCBUF, 4, MATH2, 0, 8, WAITCOMP | IMMED);\n+\tMATHB(p, MATH1, OR, MATH2, MATH2, 8, 0);\n+\tMOVE(p, MATH2, 0, CONTEXT1, 0, 8, IMMED);\n+\tMOVE(p, MATH2, 0, CONTEXT2, 0, 8, WAITCOMP | IMMED);\n+\n+\tif (dir == OP_TYPE_ENCAP_PROTOCOL)\n+\t\tMATHB(p, SEQINSZ, ADD, PDCP_MAC_I_LEN, VSEQOUTSZ, 4, IMMED2);\n+\telse\n+\t\tMATHB(p, SEQINSZ, SUB, PDCP_MAC_I_LEN, VSEQOUTSZ, 4, IMMED2);\n+\n+\tMATHB(p, SEQINSZ, SUB, ZERO, VSEQINSZ, 4, 0);\n+\tSEQSTORE(p, MATH0, 7, 1, 0);\n+\n+\tif (dir == OP_TYPE_ENCAP_PROTOCOL) {\n+\t\tSEQFIFOSTORE(p, MSG, 0, 0, VLF);\n+\t\tSEQFIFOLOAD(p, MSGINSNOOP, 0, VLF | LAST2);\n+\t} else {\n+\t\tSEQFIFOSTORE(p, MSG, 0, 0, VLF | CONT);\n+\t\tSEQFIFOLOAD(p, MSGOUTSNOOP, 0, VLF | LAST1 | FLUSH1);\n+\t}\n+\n+\tALG_OPERATION(p, OP_ALG_ALGSEL_ZUCA,\n+\t\t      OP_ALG_AAI_F9,\n+\t\t      OP_ALG_AS_INITFINAL,\n+\t\t      dir == OP_TYPE_ENCAP_PROTOCOL ?\n+\t\t\t     ICV_CHECK_DISABLE : ICV_CHECK_ENABLE,\n+\t\t      DIR_ENC);\n+\n+\tALG_OPERATION(p, OP_ALG_ALGSEL_SNOW_F8,\n+\t\t      OP_ALG_AAI_F8,\n+\t\t      OP_ALG_AS_INITFINAL,\n+\t\t      ICV_CHECK_DISABLE,\n+\t\t      dir == OP_TYPE_ENCAP_PROTOCOL ? DIR_ENC : DIR_DEC);\n+\tif (dir == OP_TYPE_ENCAP_PROTOCOL) {\n+\t\tMOVE(p, CONTEXT2, 0, IFIFOAB1, 0, 4, LAST1 | FLUSH1 | IMMED);\n+\t} else {\n+\t\t/* Save ICV */\n+\t\tMOVE(p, OFIFO, 0, MATH0, 0, 4, IMMED);\n+\t\tLOAD(p, NFIFOENTRY_STYPE_ALTSOURCE |\n+\t\t     NFIFOENTRY_DEST_CLASS2 |\n+\t\t     NFIFOENTRY_DTYPE_ICV |\n+\t\t     NFIFOENTRY_LC2 | 4, NFIFO_SZL, 0, 4, IMMED);\n+\t\tMOVE(p, MATH0, 0, ALTSOURCE, 0, 4, WAITCOMP | IMMED);\n+\t}\n+\n+\t/* Reset ZUCA mode and done interrupt */\n+\tLOAD(p, CLRW_CLR_C2MODE, CLRW, 0, 4, IMMED);\n+\tLOAD(p, CIRQ_ZADI, ICTRL, 0, 4, IMMED);\n+\n+\tPATCH_JUMP(p, pkeyjump, keyjump);\n+\treturn 0;\n+}\n+\n+static inline int\n+pdcp_insert_cplane_aes_zuc_op(struct program *p,\n+\t\t\t      bool swap __maybe_unused,\n+\t\t\t      struct alginfo *cipherdata,\n+\t\t\t      struct alginfo *authdata,\n+\t\t\t      unsigned int dir,\n+\t\t\t      unsigned char era_2_sw_hfn_ovrd __maybe_unused)\n+{\n+\tLABEL(keyjump);\n+\tREFERENCE(pkeyjump);\n+\n+\tif (rta_sec_era < RTA_SEC_ERA_5) {\n+\t\tpr_err(\"Invalid era for selected algorithm\\n\");\n+\t\treturn -ENOTSUP;\n+\t}\n+\n+\tpkeyjump = JUMP(p, keyjump, LOCAL_JUMP, ALL_TRUE, SHRD | SELF | BOTH);\n+\tKEY(p, KEY1, cipherdata->key_enc_flags, cipherdata->key,\n+\t    cipherdata->keylen, INLINE_KEY(cipherdata));\n+\tKEY(p, KEY2, authdata->key_enc_flags, authdata->key, authdata->keylen,\n+\t    INLINE_KEY(authdata));\n+\n+\tif (rta_sec_era >= RTA_SEC_ERA_8) {\n+\t\tPROTOCOL(p, dir, OP_PCLID_LTE_PDCP_CTRL_MIXED,\n+\t\t\t ((uint16_t)cipherdata->algtype << 8) |\n+\t\t\t (uint16_t)authdata->algtype);\n+\n+\t\treturn 0;\n+\t}\n+\n+\tSET_LABEL(p, keyjump);\n+\tSEQLOAD(p, MATH0, 7, 1, 0);\n+\tJUMP(p, 1, LOCAL_JUMP, ALL_TRUE, CALM);\n+\tMOVE(p, MATH0, 7, IFIFOAB2, 0, 1, IMMED);\n+\tif (swap == false)\n+\t\tMATHB(p, MATH0, AND, PDCP_C_PLANE_SN_MASK, MATH1, 8,\n+\t\t\tIFB | IMMED2);\n+\telse\n+\t\tMATHB(p, MATH0, AND, PDCP_C_PLANE_SN_MASK, MATH1, 8,\n+\t\t\tIFB | IMMED2);\n+\n+\tMATHB(p, MATH1, SHLD, MATH1, MATH1, 8, 0);\n+\tMOVE(p, DESCBUF, 4, MATH2, 0, 8, WAITCOMP | IMMED);\n+\tMATHB(p, MATH1, OR, MATH2, MATH2, 8, 0);\n+\tMOVE(p, MATH2, 0, CONTEXT1, 16, 8, IMMED);\n+\tMOVE(p, MATH2, 0, CONTEXT2, 0, 8, WAITCOMP | IMMED);\n+\n+\tif (dir == OP_TYPE_ENCAP_PROTOCOL)\n+\t\tMATHB(p, SEQINSZ, ADD, PDCP_MAC_I_LEN, VSEQOUTSZ, 4, IMMED2);\n+\telse\n+\t\tMATHB(p, SEQINSZ, SUB, PDCP_MAC_I_LEN, VSEQOUTSZ, 4, IMMED2);\n+\n+\tMATHB(p, SEQINSZ, SUB, ZERO, VSEQINSZ, 4, 0);\n+\tSEQSTORE(p, MATH0, 7, 1, 0);\n+\n+\tif (dir == OP_TYPE_ENCAP_PROTOCOL) {\n+\t\tSEQFIFOSTORE(p, MSG, 0, 0, VLF);\n+\t\tSEQFIFOLOAD(p, MSGINSNOOP, 0, VLF | LAST2);\n+\t} else {\n+\t\tSEQFIFOSTORE(p, MSG, 0, 0, VLF | CONT);\n+\t\tSEQFIFOLOAD(p, MSGOUTSNOOP, 0, VLF | LAST1 | FLUSH1);\n+\t}\n+\n+\tALG_OPERATION(p, OP_ALG_ALGSEL_ZUCA,\n+\t\t      OP_ALG_AAI_F9,\n+\t\t      OP_ALG_AS_INITFINAL,\n+\t\t      dir == OP_TYPE_ENCAP_PROTOCOL ?\n+\t\t\t     ICV_CHECK_DISABLE : ICV_CHECK_ENABLE,\n+\t\t      DIR_ENC);\n+\n+\tALG_OPERATION(p, OP_ALG_ALGSEL_AES,\n+\t\t      OP_ALG_AAI_CTR,\n+\t\t      OP_ALG_AS_INITFINAL,\n+\t\t      ICV_CHECK_DISABLE,\n+\t\t      dir == OP_TYPE_ENCAP_PROTOCOL ? DIR_ENC : DIR_DEC);\n+\n+\tif (dir == OP_TYPE_ENCAP_PROTOCOL) {\n+\t\tMOVE(p, CONTEXT2, 0, IFIFOAB1, 0, 4, LAST1 | FLUSH1 | IMMED);\n+\t} else {\n+\t\t/* Save ICV */\n+\t\tMOVE(p, OFIFO, 0, MATH0, 0, 4, IMMED);\n+\n+\t\tLOAD(p, NFIFOENTRY_STYPE_ALTSOURCE |\n+\t\t     NFIFOENTRY_DEST_CLASS2 |\n+\t\t     NFIFOENTRY_DTYPE_ICV |\n+\t\t     NFIFOENTRY_LC2 | 4, NFIFO_SZL, 0, 4, IMMED);\n+\t\tMOVE(p, MATH0, 0, ALTSOURCE, 0, 4, WAITCOMP | IMMED);\n+\t}\n+\n+\t/* Reset ZUCA mode and done interrupt */\n+\tLOAD(p, CLRW_CLR_C2MODE, CLRW, 0, 4, IMMED);\n+\tLOAD(p, CIRQ_ZADI, ICTRL, 0, 4, IMMED);\n+\n+\tPATCH_JUMP(p, pkeyjump, keyjump);\n+\n+\treturn 0;\n+}\n+\n+static inline int\n+pdcp_insert_cplane_zuc_snow_op(struct program *p,\n+\t\t\t       bool swap __maybe_unused,\n+\t\t\t       struct alginfo *cipherdata,\n+\t\t\t       struct alginfo *authdata,\n+\t\t\t       unsigned int dir,\n+\t\t\t       unsigned char era_2_sw_hfn_ovrd __maybe_unused)\n+{\n+\tLABEL(keyjump);\n+\tREFERENCE(pkeyjump);\n+\n+\tif (rta_sec_era < RTA_SEC_ERA_5) {\n+\t\tpr_err(\"Invalid era for selected algorithm\\n\");\n+\t\treturn -ENOTSUP;\n+\t}\n+\n+\tpkeyjump = JUMP(p, keyjump, LOCAL_JUMP, ALL_TRUE, SHRD | SELF | BOTH);\n+\tKEY(p, KEY1, cipherdata->key_enc_flags, cipherdata->key,\n+\t    cipherdata->keylen, INLINE_KEY(cipherdata));\n+\tKEY(p, KEY2, authdata->key_enc_flags, authdata->key, authdata->keylen,\n+\t    INLINE_KEY(authdata));\n+\n+\tif (rta_sec_era >= RTA_SEC_ERA_8) {\n+\t\tPROTOCOL(p, dir, OP_PCLID_LTE_PDCP_CTRL_MIXED,\n+\t\t\t ((uint16_t)cipherdata->algtype << 8) |\n+\t\t\t (uint16_t)authdata->algtype);\n+\n+\t\treturn 0;\n+\t}\n+\n+\tSET_LABEL(p, keyjump);\n+\tSEQLOAD(p, MATH0, 7, 1, 0);\n+\tJUMP(p, 1, LOCAL_JUMP, ALL_TRUE, CALM);\n+\tMOVE(p, MATH0, 7, IFIFOAB2, 0, 1, IMMED);\n+\tif (swap == false)\n+\t\tMATHB(p, MATH0, AND, PDCP_C_PLANE_SN_MASK, MATH1, 8,\n+\t\t\tIFB | IMMED2);\n+\telse\n+\t\tMATHB(p, MATH0, AND, PDCP_C_PLANE_SN_MASK, MATH1, 8,\n+\t\t\tIFB | IMMED2);\n+\n+\tMATHB(p, MATH1, SHLD, MATH1, MATH1, 8, 0);\n+\tMOVE(p, DESCBUF, 4, MATH2, 0, 8, WAITCOMP | IMMED);\n+\tMATHB(p, MATH1, OR, MATH2, MATH1, 8, 0);\n+\tMOVE(p, MATH1, 0, CONTEXT1, 0, 8, IMMED);\n+\tMOVE(p, MATH1, 0, CONTEXT2, 0, 4, IMMED);\n+\tif (swap == false) {\n+\t\tMATHB(p, MATH1, AND, lower_32_bits(PDCP_BEARER_MASK), MATH2,\n+\t\t\t4, IMMED2);\n+\t\tMATHB(p, MATH1, AND, upper_32_bits(PDCP_DIR_MASK), MATH3,\n+\t\t\t4, IMMED2);\n+\t} else {\n+\t\tMATHB(p, MATH1, AND, lower_32_bits(PDCP_BEARER_MASK_BE), MATH2,\n+\t\t\t4, IMMED2);\n+\t\tMATHB(p, MATH1, AND, upper_32_bits(PDCP_DIR_MASK_BE), MATH3,\n+\t\t\t4, IMMED2);\n+\t}\n+\tMATHB(p, MATH3, SHLD, MATH3, MATH3, 8, 0);\n+\tMOVE(p, MATH2, 4, OFIFO, 0, 12, IMMED);\n+\tMOVE(p, OFIFO, 0, CONTEXT2, 4, 12, IMMED);\n+\n+\tif (dir == OP_TYPE_ENCAP_PROTOCOL) {\n+\t\tMATHB(p, SEQINSZ, ADD, PDCP_MAC_I_LEN, VSEQOUTSZ, 4, IMMED2);\n+\t\tMATHB(p, SEQINSZ, SUB, ZERO, VSEQINSZ, 4, 0);\n+\t} else {\n+\t\tMATHB(p, SEQINSZ, SUB, PDCP_MAC_I_LEN, VSEQOUTSZ, 4, IMMED2);\n+\t\tMATHB(p, VSEQOUTSZ, SUB, ZERO, VSEQINSZ, 4, 0);\n+\t}\n+\n+\tSEQSTORE(p, MATH0, 7, 1, 0);\n+\n+\tif (dir == OP_TYPE_ENCAP_PROTOCOL) {\n+\t\tSEQFIFOSTORE(p, MSG, 0, 0, VLF);\n+\t\tSEQFIFOLOAD(p, MSGINSNOOP, 0, VLF | LAST2);\n+\t} else {\n+\t\tSEQFIFOSTORE(p, MSG, 0, 0, VLF | CONT);\n+\t\tSEQFIFOLOAD(p, MSGOUTSNOOP, 0, VLF | LAST2);\n+\t}\n+\n+\tALG_OPERATION(p, OP_ALG_ALGSEL_SNOW_F9,\n+\t\t      OP_ALG_AAI_F9,\n+\t\t      OP_ALG_AS_INITFINAL,\n+\t\t      dir == OP_TYPE_ENCAP_PROTOCOL ?\n+\t\t\t     ICV_CHECK_DISABLE : ICV_CHECK_ENABLE,\n+\t\t      DIR_DEC);\n+\n+\tALG_OPERATION(p, OP_ALG_ALGSEL_ZUCE,\n+\t\t      OP_ALG_AAI_F8,\n+\t\t      OP_ALG_AS_INITFINAL,\n+\t\t      ICV_CHECK_DISABLE,\n+\t\t      dir == OP_TYPE_ENCAP_PROTOCOL ? DIR_ENC : DIR_DEC);\n+\n+\tif (dir == OP_TYPE_ENCAP_PROTOCOL) {\n+\t\tMOVE(p, CONTEXT2, 0, IFIFOAB1, 0, 4, LAST1 | FLUSH1 | IMMED);\n+\t} else {\n+\t\tSEQFIFOLOAD(p, MSG1, 4, LAST1 | FLUSH1);\n+\t\tJUMP(p, 1, LOCAL_JUMP, ALL_TRUE, CLASS1 | NOP | NIFP);\n+\n+\t\tif (rta_sec_era >= RTA_SEC_ERA_6)\n+\t\t\t/*\n+\t\t\t * For SEC ERA 6, there's a problem with the OFIFO\n+\t\t\t * pointer, and thus it needs to be reset here before\n+\t\t\t * moving to M0.\n+\t\t\t */\n+\t\t\tLOAD(p, 0, DCTRL, 0, LDLEN_RST_CHA_OFIFO_PTR, IMMED);\n+\n+\t\t/* Put ICV to M0 before sending it to C2 for comparison. */\n+\t\tMOVE(p, OFIFO, 0, MATH0, 0, 4, WAITCOMP | IMMED);\n+\n+\t\tLOAD(p, NFIFOENTRY_STYPE_ALTSOURCE |\n+\t\t     NFIFOENTRY_DEST_CLASS2 |\n+\t\t     NFIFOENTRY_DTYPE_ICV |\n+\t\t     NFIFOENTRY_LC2 | 4, NFIFO_SZL, 0, 4, IMMED);\n+\t\tMOVE(p, MATH0, 0, ALTSOURCE, 0, 4, IMMED);\n+\t}\n+\n+\tPATCH_JUMP(p, pkeyjump, keyjump);\n+\treturn 0;\n+}\n+\n+static inline int\n+pdcp_insert_cplane_zuc_aes_op(struct program *p,\n+\t\t\t      bool swap __maybe_unused,\n+\t\t\t      struct alginfo *cipherdata,\n+\t\t\t      struct alginfo *authdata,\n+\t\t\t      unsigned int dir,\n+\t\t\t      unsigned char era_2_sw_hfn_ovrd __maybe_unused)\n+{\n+\tif (rta_sec_era < RTA_SEC_ERA_5) {\n+\t\tpr_err(\"Invalid era for selected algorithm\\n\");\n+\t\treturn -ENOTSUP;\n+\t}\n+\n+\tif (rta_sec_era >= RTA_SEC_ERA_8) {\n+\t\tKEY(p, KEY1, cipherdata->key_enc_flags, cipherdata->key,\n+\t\t\t\tcipherdata->keylen, INLINE_KEY(cipherdata));\n+\t\tKEY(p, KEY2, authdata->key_enc_flags, authdata->key,\n+\t\t\t\tauthdata->keylen, INLINE_KEY(authdata));\n+\n+\t\tPROTOCOL(p, dir, OP_PCLID_LTE_PDCP_CTRL_MIXED,\n+\t\t\t ((uint16_t)cipherdata->algtype << 8) |\n+\t\t\t (uint16_t)authdata->algtype);\n+\t\treturn 0;\n+\t}\n+\n+\tSEQLOAD(p, MATH0, 7, 1, 0);\n+\tJUMP(p, 1, LOCAL_JUMP, ALL_TRUE, CALM);\n+\tif (swap == false)\n+\t\tMATHB(p, MATH0, AND, PDCP_C_PLANE_SN_MASK, MATH1, 8,\n+\t\t\tIFB | IMMED2);\n+\telse\n+\t\tMATHB(p, MATH0, AND, PDCP_C_PLANE_SN_MASK, MATH1, 8,\n+\t\t\tIFB | IMMED2);\n+\n+\tMATHB(p, MATH1, SHLD, MATH1, MATH1, 8, 0);\n+\tMOVE(p, DESCBUF, 4, MATH2, 0, 0x08, WAITCOMP | IMMED);\n+\tMATHB(p, MATH1, OR, MATH2, MATH2, 8, 0);\n+\tSEQSTORE(p, MATH0, 7, 1, 0);\n+\tif (dir == OP_TYPE_ENCAP_PROTOCOL) {\n+\t\tKEY(p, KEY1, authdata->key_enc_flags, authdata->key,\n+\t\t    authdata->keylen, INLINE_KEY(authdata));\n+\t\tMOVE(p, MATH2, 0, IFIFOAB1, 0, 0x08, IMMED);\n+\t\tMOVE(p, MATH0, 7, IFIFOAB1, 0, 1, IMMED);\n+\n+\t\tMATHB(p, SEQINSZ, SUB, ZERO, VSEQINSZ, 4, 0);\n+\t\tMATHB(p, VSEQINSZ, ADD, PDCP_MAC_I_LEN, VSEQOUTSZ, 4, IMMED2);\n+\n+\t\tALG_OPERATION(p, OP_ALG_ALGSEL_AES,\n+\t\t\t      OP_ALG_AAI_CMAC,\n+\t\t\t      OP_ALG_AS_INITFINAL,\n+\t\t\t      ICV_CHECK_DISABLE,\n+\t\t\t      DIR_DEC);\n+\t\tSEQFIFOLOAD(p, MSG1, 0, VLF | LAST1 | FLUSH1);\n+\t\tMOVE(p, CONTEXT1, 0, MATH3, 0, 4, WAITCOMP | IMMED);\n+\t\tLOAD(p, CLRW_RESET_CLS1_CHA |\n+\t\t     CLRW_CLR_C1KEY |\n+\t\t     CLRW_CLR_C1CTX |\n+\t\t     CLRW_CLR_C1ICV |\n+\t\t     CLRW_CLR_C1DATAS |\n+\t\t     CLRW_CLR_C1MODE,\n+\t\t     CLRW, 0, 4, IMMED);\n+\n+\t\tKEY(p, KEY1, cipherdata->key_enc_flags, cipherdata->key,\n+\t\t    cipherdata->keylen, INLINE_KEY(cipherdata));\n+\n+\t\tMOVE(p, MATH2, 0, CONTEXT1, 0, 8, IMMED);\n+\t\tSEQINPTR(p, 0, PDCP_NULL_MAX_FRAME_LEN, RTO);\n+\n+\t\tALG_OPERATION(p, OP_ALG_ALGSEL_ZUCE,\n+\t\t\t      OP_ALG_AAI_F8,\n+\t\t\t      OP_ALG_AS_INITFINAL,\n+\t\t\t      ICV_CHECK_DISABLE,\n+\t\t\t      DIR_ENC);\n+\t\tSEQFIFOSTORE(p, MSG, 0, 0, VLF);\n+\n+\t\tSEQFIFOLOAD(p, SKIP, 1, 0);\n+\n+\t\tSEQFIFOLOAD(p, MSG1, 0, VLF);\n+\t\tMOVE(p, MATH3, 0, IFIFOAB1, 0, 4, LAST1 | FLUSH1 | IMMED);\n+\t} else {\n+\t\tMOVE(p, MATH2, 0, CONTEXT1, 0, 8, IMMED);\n+\n+\t\tMOVE(p, CONTEXT1, 0, CONTEXT2, 0, 8, IMMED);\n+\n+\t\tMATHB(p, SEQINSZ, SUB, ZERO, VSEQINSZ, 4, 0);\n+\n+\t\tMATHB(p, SEQINSZ, SUB, PDCP_MAC_I_LEN, VSEQOUTSZ, 4, IMMED2);\n+\n+\t\tKEY(p, KEY1, cipherdata->key_enc_flags, cipherdata->key,\n+\t\t    cipherdata->keylen, INLINE_KEY(cipherdata));\n+\n+\t\tMOVE(p, CONTEXT1, 0, CONTEXT2, 0, 8, IMMED);\n+\n+\t\tALG_OPERATION(p, OP_ALG_ALGSEL_ZUCE,\n+\t\t\t      OP_ALG_AAI_F8,\n+\t\t\t      OP_ALG_AS_INITFINAL,\n+\t\t\t      ICV_CHECK_DISABLE,\n+\t\t\t      DIR_DEC);\n+\t\tSEQFIFOSTORE(p, MSG, 0, 0, VLF | CONT);\n+\t\tSEQFIFOLOAD(p, MSG1, 0, VLF | LAST1 | FLUSH1);\n+\n+\t\tMOVE(p, OFIFO, 0, MATH3, 0, 4, IMMED);\n+\n+\t\tLOAD(p, CLRW_RESET_CLS1_CHA |\n+\t\t     CLRW_CLR_C1KEY |\n+\t\t     CLRW_CLR_C1CTX |\n+\t\t     CLRW_CLR_C1ICV |\n+\t\t     CLRW_CLR_C1DATAS |\n+\t\t     CLRW_CLR_C1MODE,\n+\t\t     CLRW, 0, 4, IMMED);\n+\n+\t\tKEY(p, KEY1, authdata->key_enc_flags, authdata->key,\n+\t\t    authdata->keylen, INLINE_KEY(authdata));\n+\n+\t\tSEQINPTR(p, 0, 0, SOP);\n+\n+\t\tALG_OPERATION(p, OP_ALG_ALGSEL_AES,\n+\t\t\t      OP_ALG_AAI_CMAC,\n+\t\t\t      OP_ALG_AS_INITFINAL,\n+\t\t\t      ICV_CHECK_ENABLE,\n+\t\t\t      DIR_DEC);\n+\n+\t\tMATHB(p, SEQINSZ, SUB, ZERO, VSEQINSZ, 4, 0);\n+\n+\t\tMOVE(p, CONTEXT2, 0, IFIFOAB1, 0, 8, IMMED);\n+\n+\t\tSEQFIFOLOAD(p, MSG1, 0, VLF | LAST1 | FLUSH1);\n+\n+\t\tLOAD(p, NFIFOENTRY_STYPE_ALTSOURCE |\n+\t\t     NFIFOENTRY_DEST_CLASS1 |\n+\t\t     NFIFOENTRY_DTYPE_ICV |\n+\t\t     NFIFOENTRY_LC1 |\n+\t\t     NFIFOENTRY_FC1 | 4, NFIFO_SZL, 0, 4, IMMED);\n+\t\tMOVE(p, MATH3, 0, ALTSOURCE, 0, 4, IMMED);\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static inline int\n+pdcp_insert_uplane_15bit_op(struct program *p,\n+\t\t\t    bool swap __maybe_unused,\n+\t\t\t    struct alginfo *cipherdata,\n+\t\t\t    unsigned int dir)\n+{\n+\tint op;\n+\t/* Insert Cipher Key */\n+\tKEY(p, KEY1, cipherdata->key_enc_flags, cipherdata->key,\n+\t    cipherdata->keylen, INLINE_KEY(cipherdata));\n+\n+\tif (rta_sec_era >= RTA_SEC_ERA_8) {\n+\t\tPROTOCOL(p, dir, OP_PCLID_LTE_PDCP_USER,\n+\t\t\t (uint16_t)cipherdata->algtype);\n+\t\treturn 0;\n+\t}\n+\n+\tSEQLOAD(p, MATH0, 6, 2, 0);\n+\tJUMP(p, 1, LOCAL_JUMP, ALL_TRUE, CALM);\n+\tif (swap == false)\n+\t\tMATHB(p, MATH0, AND, PDCP_U_PLANE_15BIT_SN_MASK, MATH1, 8,\n+\t\t      IFB | IMMED2);\n+\telse\n+\t\tMATHB(p, MATH0, AND, PDCP_U_PLANE_15BIT_SN_MASK_BE, MATH1, 8,\n+\t\t      IFB | IMMED2);\n+\tSEQSTORE(p, MATH0, 6, 2, 0);\n+\tMATHB(p, MATH1, SHLD, MATH1, MATH1, 8, 0);\n+\tMOVE(p, DESCBUF, 8, MATH2, 0, 8, WAITCOMP | IMMED);\n+\tMATHB(p, MATH1, OR, MATH2, MATH2, 8, 0);\n+\n+\tMATHB(p, SEQINSZ, SUB, MATH3, VSEQINSZ, 4, 0);\n+\tMATHB(p, SEQINSZ, SUB, MATH3, VSEQOUTSZ, 4, 0);\n+\n+\tSEQFIFOSTORE(p, MSG, 0, 0, VLF);\n+\n+\top = dir == OP_TYPE_ENCAP_PROTOCOL ? DIR_ENC : DIR_DEC;\n+\tswitch (cipherdata->algtype) {\n+\tcase PDCP_CIPHER_TYPE_SNOW:\n+\t\tMOVE(p, MATH2, 0, CONTEXT1, 0, 8, WAITCOMP | IMMED);\n+\t\tALG_OPERATION(p, OP_ALG_ALGSEL_SNOW_F8,\n+\t\t\t      OP_ALG_AAI_F8,\n+\t\t\t      OP_ALG_AS_INITFINAL,\n+\t\t\t      ICV_CHECK_DISABLE,\n+\t\t\t      op);\n+\t\tbreak;\n+\n+\tcase PDCP_CIPHER_TYPE_AES:\n+\t\tMOVE(p, MATH2, 0, CONTEXT1, 0x10, 0x10, WAITCOMP | IMMED);\n+\t\tALG_OPERATION(p, OP_ALG_ALGSEL_AES,\n+\t\t\t      OP_ALG_AAI_CTR,\n+\t\t\t      OP_ALG_AS_INITFINAL,\n+\t\t\t      ICV_CHECK_DISABLE,\n+\t\t\t      op);\n+\t\tbreak;\n+\n+\tcase PDCP_CIPHER_TYPE_ZUC:\n+\t\tif (rta_sec_era < RTA_SEC_ERA_5) {\n+\t\t\tpr_err(\"Invalid era for selected algorithm\\n\");\n+\t\t\treturn -ENOTSUP;\n+\t\t}\n+\t\tMOVE(p, MATH2, 0, CONTEXT1, 0, 0x08, IMMED);\n+\t\tMOVE(p, MATH2, 0, CONTEXT1, 0x08, 0x08, WAITCOMP | IMMED);\n+\n+\t\tALG_OPERATION(p, OP_ALG_ALGSEL_ZUCE,\n+\t\t\t      OP_ALG_AAI_F8,\n+\t\t\t      OP_ALG_AS_INITFINAL,\n+\t\t\t      ICV_CHECK_DISABLE,\n+\t\t\t      op);\n+\t\tbreak;\n+\n+\tdefault:\n+\t\tpr_err(\"%s: Invalid encrypt algorithm selected: %d\\n\",\n+\t\t       \"pdcp_insert_uplane_15bit_op\", cipherdata->algtype);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tSEQFIFOLOAD(p, MSG1, 0, VLF | LAST1 | FLUSH1);\n+\n+\treturn 0;\n+}\n+\n+/*\n+ * Function for inserting the snippet of code responsible for creating\n+ * the HFN override code via either DPOVRD or via the input frame.\n+ */\n+static inline int\n+insert_hfn_ov_op(struct program *p,\n+\t\t uint32_t shift,\n+\t\t enum pdb_type_e pdb_type,\n+\t\t unsigned char era_2_sw_hfn_ovrd)\n+{\n+\tuint32_t imm = PDCP_DPOVRD_HFN_OV_EN;\n+\tuint16_t hfn_pdb_offset;\n+\n+\tif (rta_sec_era == RTA_SEC_ERA_2 && !era_2_sw_hfn_ovrd)\n+\t\treturn 0;\n+\n+\tswitch (pdb_type) {\n+\tcase PDCP_PDB_TYPE_NO_PDB:\n+\t\t/*\n+\t\t * If there is no PDB, then HFN override mechanism does not\n+\t\t * make any sense, thus in this case the function will\n+\t\t * return the pointer to the current position in the\n+\t\t * descriptor buffer\n+\t\t */\n+\t\treturn 0;\n+\n+\tcase PDCP_PDB_TYPE_REDUCED_PDB:\n+\t\thfn_pdb_offset = 4;\n+\t\tbreak;\n+\n+\tcase PDCP_PDB_TYPE_FULL_PDB:\n+\t\thfn_pdb_offset = 8;\n+\t\tbreak;\n+\n+\tdefault:\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (rta_sec_era > RTA_SEC_ERA_2) {\n+\t\tMATHB(p, DPOVRD, AND, imm, NONE, 8, IFB | IMMED2);\n+\t} else {\n+\t\tSEQLOAD(p, MATH0, 4, 4, 0);\n+\t\tJUMP(p, 1, LOCAL_JUMP, ALL_TRUE, CALM);\n+\t\tMATHB(p, MATH0, AND, imm, NONE, 8, IFB | IMMED2);\n+\t\tSEQSTORE(p, MATH0, 4, 4, 0);\n+\t}\n+\n+\tif (rta_sec_era >= RTA_SEC_ERA_8)\n+\t\tJUMP(p, 6, LOCAL_JUMP, ALL_TRUE, MATH_Z);\n+\telse\n+\t\tJUMP(p, 5, LOCAL_JUMP, ALL_TRUE, MATH_Z);\n+\n+\tif (rta_sec_era > RTA_SEC_ERA_2)\n+\t\tMATHB(p, DPOVRD, LSHIFT, shift, MATH0, 4, IMMED2);\n+\telse\n+\t\tMATHB(p, MATH0, LSHIFT, shift, MATH0, 4, IMMED2);\n+\n+\tMATHB(p, MATH0, SHLD, MATH0, MATH0, 8, 0);\n+\tMOVE(p, MATH0, 0, DESCBUF, hfn_pdb_offset, 4, IMMED);\n+\n+\tif (rta_sec_era >= RTA_SEC_ERA_8)\n+\t\t/*\n+\t\t * For ERA8, DPOVRD could be handled by the PROTOCOL command\n+\t\t * itself. For now, this is not done. Thus, clear DPOVRD here\n+\t\t * to alleviate any side-effects.\n+\t\t */\n+\t\tMATHB(p, DPOVRD, AND, ZERO, DPOVRD, 4, STL);\n+\n+\treturn 0;\n+}\n+\n+/*\n+ * PDCP Control PDB creation function\n+ */\n+static inline enum pdb_type_e\n+cnstr_pdcp_c_plane_pdb(struct program *p,\n+\t\t       uint32_t hfn,\n+\t\t       unsigned char bearer,\n+\t\t       unsigned char direction,\n+\t\t       uint32_t hfn_threshold,\n+\t\t       struct alginfo *cipherdata,\n+\t\t       struct alginfo *authdata)\n+{\n+\tstruct pdcp_pdb pdb;\n+\tenum pdb_type_e\n+\t\tpdb_mask[PDCP_CIPHER_TYPE_INVALID][PDCP_AUTH_TYPE_INVALID] = {\n+\t\t\t{\t/* NULL */\n+\t\t\t\tPDCP_PDB_TYPE_NO_PDB,\t\t/* NULL */\n+\t\t\t\tPDCP_PDB_TYPE_FULL_PDB,\t\t/* SNOW f9 */\n+\t\t\t\tPDCP_PDB_TYPE_FULL_PDB,\t\t/* AES CMAC */\n+\t\t\t\tPDCP_PDB_TYPE_FULL_PDB\t\t/* ZUC-I */\n+\t\t\t},\n+\t\t\t{\t/* SNOW f8 */\n+\t\t\t\tPDCP_PDB_TYPE_FULL_PDB,\t\t/* NULL */\n+\t\t\t\tPDCP_PDB_TYPE_FULL_PDB,\t\t/* SNOW f9 */\n+\t\t\t\tPDCP_PDB_TYPE_REDUCED_PDB,\t/* AES CMAC */\n+\t\t\t\tPDCP_PDB_TYPE_REDUCED_PDB\t/* ZUC-I */\n+\t\t\t},\n+\t\t\t{\t/* AES CTR */\n+\t\t\t\tPDCP_PDB_TYPE_FULL_PDB,\t\t/* NULL */\n+\t\t\t\tPDCP_PDB_TYPE_REDUCED_PDB,\t/* SNOW f9 */\n+\t\t\t\tPDCP_PDB_TYPE_FULL_PDB,\t\t/* AES CMAC */\n+\t\t\t\tPDCP_PDB_TYPE_REDUCED_PDB\t/* ZUC-I */\n+\t\t\t},\n+\t\t\t{\t/* ZUC-E */\n+\t\t\t\tPDCP_PDB_TYPE_FULL_PDB,\t\t/* NULL */\n+\t\t\t\tPDCP_PDB_TYPE_REDUCED_PDB,\t/* SNOW f9 */\n+\t\t\t\tPDCP_PDB_TYPE_REDUCED_PDB,\t/* AES CMAC */\n+\t\t\t\tPDCP_PDB_TYPE_FULL_PDB\t\t/* ZUC-I */\n+\t\t\t},\n+\t};\n+\n+\tif (rta_sec_era >= RTA_SEC_ERA_8) {\n+\t\tmemset(&pdb, 0x00, sizeof(struct pdcp_pdb));\n+\n+\t\t/* This is a HW issue. Bit 2 should be set to zero,\n+\t\t * but it does not work this way. Override here.\n+\t\t */\n+\t\tpdb.opt_res.rsvd = 0x00000002;\n+\n+\t\t/* Copy relevant information from user to PDB */\n+\t\tpdb.hfn_res = hfn << PDCP_C_PLANE_PDB_HFN_SHIFT;\n+\t\tpdb.bearer_dir_res = (uint32_t)\n+\t\t\t\t((bearer << PDCP_C_PLANE_PDB_BEARER_SHIFT) |\n+\t\t\t\t (direction << PDCP_C_PLANE_PDB_DIR_SHIFT));\n+\t\tpdb.hfn_thr_res =\n+\t\t\t\thfn_threshold << PDCP_C_PLANE_PDB_HFN_THR_SHIFT;\n+\n+\t\t/* copy PDB in descriptor*/\n+\t\t__rta_out32(p, pdb.opt_res.opt);\n+\t\t__rta_out32(p, pdb.hfn_res);\n+\t\t__rta_out32(p, pdb.bearer_dir_res);\n+\t\t__rta_out32(p, pdb.hfn_thr_res);\n+\n+\t\treturn PDCP_PDB_TYPE_FULL_PDB;\n+\t}\n+\n+\tswitch (pdb_mask[cipherdata->algtype][authdata->algtype]) {\n+\tcase PDCP_PDB_TYPE_NO_PDB:\n+\t\tbreak;\n+\n+\tcase PDCP_PDB_TYPE_REDUCED_PDB:\n+\t\t__rta_out32(p, (hfn << PDCP_C_PLANE_PDB_HFN_SHIFT));\n+\t\t__rta_out32(p,\n+\t\t\t    (uint32_t)((bearer <<\n+\t\t\t\t\tPDCP_C_PLANE_PDB_BEARER_SHIFT) |\n+\t\t\t\t\t(direction <<\n+\t\t\t\t\t PDCP_C_PLANE_PDB_DIR_SHIFT)));\n+\t\tbreak;\n+\n+\tcase PDCP_PDB_TYPE_FULL_PDB:\n+\t\tmemset(&pdb, 0x00, sizeof(struct pdcp_pdb));\n+\n+\t\t/* This is a HW issue. Bit 2 should be set to zero,\n+\t\t * but it does not work this way. Override here.\n+\t\t */\n+\t\tpdb.opt_res.rsvd = 0x00000002;\n+\n+\t\t/* Copy relevant information from user to PDB */\n+\t\tpdb.hfn_res = hfn << PDCP_C_PLANE_PDB_HFN_SHIFT;\n+\t\tpdb.bearer_dir_res = (uint32_t)\n+\t\t\t((bearer << PDCP_C_PLANE_PDB_BEARER_SHIFT) |\n+\t\t\t (direction << PDCP_C_PLANE_PDB_DIR_SHIFT));\n+\t\tpdb.hfn_thr_res =\n+\t\t\thfn_threshold << PDCP_C_PLANE_PDB_HFN_THR_SHIFT;\n+\n+\t\t/* copy PDB in descriptor*/\n+\t\t__rta_out32(p, pdb.opt_res.opt);\n+\t\t__rta_out32(p, pdb.hfn_res);\n+\t\t__rta_out32(p, pdb.bearer_dir_res);\n+\t\t__rta_out32(p, pdb.hfn_thr_res);\n+\n+\t\tbreak;\n+\n+\tdefault:\n+\t\treturn PDCP_PDB_TYPE_INVALID;\n+\t}\n+\n+\treturn pdb_mask[cipherdata->algtype][authdata->algtype];\n+}\n+\n+/*\n+ * PDCP UPlane PDB creation function\n+ */\n+static inline int\n+cnstr_pdcp_u_plane_pdb(struct program *p,\n+\t\t       enum pdcp_sn_size sn_size,\n+\t\t       uint32_t hfn, unsigned short bearer,\n+\t\t       unsigned short direction,\n+\t\t       uint32_t hfn_threshold)\n+{\n+\tstruct pdcp_pdb pdb;\n+\t/* Read options from user */\n+\t/* Depending on sequence number length, the HFN and HFN threshold\n+\t * have different lengths.\n+\t */\n+\tmemset(&pdb, 0x00, sizeof(struct pdcp_pdb));\n+\n+\tswitch (sn_size) {\n+\tcase PDCP_SN_SIZE_7:\n+\t\tpdb.opt_res.opt |= PDCP_U_PLANE_PDB_OPT_SHORT_SN;\n+\t\tpdb.hfn_res = hfn << PDCP_U_PLANE_PDB_SHORT_SN_HFN_SHIFT;\n+\t\tpdb.hfn_thr_res =\n+\t\t\thfn_threshold<<PDCP_U_PLANE_PDB_SHORT_SN_HFN_THR_SHIFT;\n+\t\tbreak;\n+\n+\tcase PDCP_SN_SIZE_12:\n+\t\tpdb.opt_res.opt &= (uint32_t)(~PDCP_U_PLANE_PDB_OPT_SHORT_SN);\n+\t\tpdb.hfn_res = hfn << PDCP_U_PLANE_PDB_LONG_SN_HFN_SHIFT;\n+\t\tpdb.hfn_thr_res =\n+\t\t\thfn_threshold<<PDCP_U_PLANE_PDB_LONG_SN_HFN_THR_SHIFT;\n+\t\tbreak;\n+\n+\tcase PDCP_SN_SIZE_15:\n+\t\tpdb.opt_res.opt = (uint32_t)(PDCP_U_PLANE_PDB_OPT_15B_SN);\n+\t\tpdb.hfn_res = hfn << PDCP_U_PLANE_PDB_15BIT_SN_HFN_SHIFT;\n+\t\tpdb.hfn_thr_res =\n+\t\t\thfn_threshold<<PDCP_U_PLANE_PDB_15BIT_SN_HFN_THR_SHIFT;\n+\t\tbreak;\n+\n+\tdefault:\n+\t\tpr_err(\"Invalid Sequence Number Size setting in PDB\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tpdb.bearer_dir_res = (uint32_t)\n+\t\t\t\t((bearer << PDCP_U_PLANE_PDB_BEARER_SHIFT) |\n+\t\t\t\t (direction << PDCP_U_PLANE_PDB_DIR_SHIFT));\n+\n+\t/* copy PDB in descriptor*/\n+\t__rta_out32(p, pdb.opt_res.opt);\n+\t__rta_out32(p, pdb.hfn_res);\n+\t__rta_out32(p, pdb.bearer_dir_res);\n+\t__rta_out32(p, pdb.hfn_thr_res);\n+\n+\treturn 0;\n+}\n+/**\n+ * cnstr_shdsc_pdcp_c_plane_encap - Function for creating a PDCP Control Plane\n+ *                                  encapsulation descriptor.\n+ * @descbuf: pointer to buffer for descriptor construction\n+ * @ps: if 36/40bit addressing is desired, this parameter must be true\n+ * @swap: must be true when core endianness doesn't match SEC endianness\n+ * @hfn: starting Hyper Frame Number to be used together with the SN from the\n+ *       PDCP frames.\n+ * @bearer: radio bearer ID\n+ * @direction: the direction of the PDCP frame (UL/DL)\n+ * @hfn_threshold: HFN value that once reached triggers a warning from SEC that\n+ *                 keys should be renegotiated at the earliest convenience.\n+ * @cipherdata: pointer to block cipher transform definitions\n+ *              Valid algorithm values are those from cipher_type_pdcp enum.\n+ * @authdata: pointer to authentication transform definitions\n+ *            Valid algorithm values are those from auth_type_pdcp enum.\n+ * @era_2_sw_hfn_ovrd: if software HFN override mechanism is desired for\n+ *                     this descriptor. Note: Can only be used for\n+ *                     SEC ERA 2.\n+ * Return: size of descriptor written in words or negative number on error.\n+ *         Once the function returns, the value of this parameter can be used\n+ *         for reclaiming the space that wasn't used for the descriptor.\n+ *\n+ * Note: descbuf must be large enough to contain a full 256 byte long\n+ * descriptor; after the function returns, by subtracting the actual number of\n+ * bytes used, the user can reuse the remaining buffer space for other purposes.\n+ */\n+static inline int\n+cnstr_shdsc_pdcp_c_plane_encap(uint32_t *descbuf,\n+\t\t\t       bool ps,\n+\t\t\t       bool swap,\n+\t\t\t       uint32_t hfn,\n+\t\t\t       unsigned char bearer,\n+\t\t\t       unsigned char direction,\n+\t\t\t       uint32_t hfn_threshold,\n+\t\t\t       struct alginfo *cipherdata,\n+\t\t\t       struct alginfo *authdata,\n+\t\t\t       unsigned char era_2_sw_hfn_ovrd)\n+{\n+\tstatic int\n+\t\t(*pdcp_cp_fp[PDCP_CIPHER_TYPE_INVALID][PDCP_AUTH_TYPE_INVALID])\n+\t\t\t(struct program*, bool swap, struct alginfo *,\n+\t\t\t struct alginfo *, unsigned int,\n+\t\t\tunsigned char __maybe_unused) = {\n+\t\t{\t/* NULL */\n+\t\t\tpdcp_insert_cplane_null_op,\t/* NULL */\n+\t\t\tpdcp_insert_cplane_int_only_op,\t/* SNOW f9 */\n+\t\t\tpdcp_insert_cplane_int_only_op,\t/* AES CMAC */\n+\t\t\tpdcp_insert_cplane_int_only_op\t/* ZUC-I */\n+\t\t},\n+\t\t{\t/* SNOW f8 */\n+\t\t\tpdcp_insert_cplane_enc_only_op,\t/* NULL */\n+\t\t\tpdcp_insert_cplane_acc_op,\t/* SNOW f9 */\n+\t\t\tpdcp_insert_cplane_snow_aes_op,\t/* AES CMAC */\n+\t\t\tpdcp_insert_cplane_snow_zuc_op\t/* ZUC-I */\n+\t\t},\n+\t\t{\t/* AES CTR */\n+\t\t\tpdcp_insert_cplane_enc_only_op,\t/* NULL */\n+\t\t\tpdcp_insert_cplane_aes_snow_op,\t/* SNOW f9 */\n+\t\t\tpdcp_insert_cplane_acc_op,\t/* AES CMAC */\n+\t\t\tpdcp_insert_cplane_aes_zuc_op\t/* ZUC-I */\n+\t\t},\n+\t\t{\t/* ZUC-E */\n+\t\t\tpdcp_insert_cplane_enc_only_op,\t/* NULL */\n+\t\t\tpdcp_insert_cplane_zuc_snow_op,\t/* SNOW f9 */\n+\t\t\tpdcp_insert_cplane_zuc_aes_op,\t/* AES CMAC */\n+\t\t\tpdcp_insert_cplane_acc_op\t/* ZUC-I */\n+\t\t},\n+\t};\n+\tstatic enum rta_share_type\n+\t\tdesc_share[PDCP_CIPHER_TYPE_INVALID][PDCP_AUTH_TYPE_INVALID] = {\n+\t\t{\t/* NULL */\n+\t\t\tSHR_WAIT,\t/* NULL */\n+\t\t\tSHR_ALWAYS,\t/* SNOW f9 */\n+\t\t\tSHR_ALWAYS,\t/* AES CMAC */\n+\t\t\tSHR_ALWAYS\t/* ZUC-I */\n+\t\t},\n+\t\t{\t/* SNOW f8 */\n+\t\t\tSHR_ALWAYS,\t/* NULL */\n+\t\t\tSHR_ALWAYS,\t/* SNOW f9 */\n+\t\t\tSHR_WAIT,\t/* AES CMAC */\n+\t\t\tSHR_WAIT\t/* ZUC-I */\n+\t\t},\n+\t\t{\t/* AES CTR */\n+\t\t\tSHR_ALWAYS,\t/* NULL */\n+\t\t\tSHR_ALWAYS,\t/* SNOW f9 */\n+\t\t\tSHR_ALWAYS,\t/* AES CMAC */\n+\t\t\tSHR_WAIT\t/* ZUC-I */\n+\t\t},\n+\t\t{\t/* ZUC-E */\n+\t\t\tSHR_ALWAYS,\t/* NULL */\n+\t\t\tSHR_WAIT,\t/* SNOW f9 */\n+\t\t\tSHR_WAIT,\t/* AES CMAC */\n+\t\t\tSHR_ALWAYS\t/* ZUC-I */\n+\t\t},\n+\t};\n+\tenum pdb_type_e pdb_type;\n+\tstruct program prg;\n+\tstruct program *p = &prg;\n+\tint err;\n+\tLABEL(pdb_end);\n+\n+\tif (rta_sec_era != RTA_SEC_ERA_2 && era_2_sw_hfn_ovrd) {\n+\t\tpr_err(\"Cannot select SW HFN override for other era than 2\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tPROGRAM_CNTXT_INIT(p, descbuf, 0);\n+\tif (swap)\n+\t\tPROGRAM_SET_BSWAP(p);\n+\tif (ps)\n+\t\tPROGRAM_SET_36BIT_ADDR(p);\n+\n+\tSHR_HDR(p, desc_share[cipherdata->algtype][authdata->algtype], 0, 0);\n+\n+\tpdb_type = cnstr_pdcp_c_plane_pdb(p,\n+\t\t\thfn,\n+\t\t\tbearer,\n+\t\t\tdirection,\n+\t\t\thfn_threshold,\n+\t\t\tcipherdata,\n+\t\t\tauthdata);\n+\n+\tSET_LABEL(p, pdb_end);\n+\n+\terr = insert_hfn_ov_op(p, PDCP_SN_SIZE_5, pdb_type,\n+\t\t\t       era_2_sw_hfn_ovrd);\n+\tif (err)\n+\t\treturn err;\n+\n+\terr = pdcp_cp_fp[cipherdata->algtype][authdata->algtype](p,\n+\t\tswap,\n+\t\tcipherdata,\n+\t\tauthdata,\n+\t\tOP_TYPE_ENCAP_PROTOCOL,\n+\t\tera_2_sw_hfn_ovrd);\n+\tif (err)\n+\t\treturn err;\n+\n+\tPATCH_HDR(p, 0, pdb_end);\n+\n+\treturn PROGRAM_FINALIZE(p);\n+}\n+\n+/**\n+ * cnstr_shdsc_pdcp_c_plane_decap - Function for creating a PDCP Control Plane\n+ *                                  decapsulation descriptor.\n+ * @descbuf: pointer to buffer for descriptor construction\n+ * @ps: if 36/40bit addressing is desired, this parameter must be true\n+ * @swap: must be true when core endianness doesn't match SEC endianness\n+ * @hfn: starting Hyper Frame Number to be used together with the SN from the\n+ *       PDCP frames.\n+ * @bearer: radio bearer ID\n+ * @direction: the direction of the PDCP frame (UL/DL)\n+ * @hfn_threshold: HFN value that once reached triggers a warning from SEC that\n+ *                 keys should be renegotiated at the earliest convenience.\n+ * @cipherdata: pointer to block cipher transform definitions\n+ *              Valid algorithm values are those from cipher_type_pdcp enum.\n+ * @authdata: pointer to authentication transform definitions\n+ *            Valid algorithm values are those from auth_type_pdcp enum.\n+ * @era_2_sw_hfn_ovrd: if software HFN override mechanism is desired for\n+ *                     this descriptor. Note: Can only be used for\n+ *                     SEC ERA 2.\n+ *\n+ * Return: size of descriptor written in words or negative number on error.\n+ *         Once the function returns, the value of this parameter can be used\n+ *         for reclaiming the space that wasn't used for the descriptor.\n+ *\n+ * Note: descbuf must be large enough to contain a full 256 byte long\n+ * descriptor; after the function returns, by subtracting the actual number of\n+ * bytes used, the user can reuse the remaining buffer space for other purposes.\n+ */\n+static inline int\n+cnstr_shdsc_pdcp_c_plane_decap(uint32_t *descbuf,\n+\t\t\t       bool ps,\n+\t\t\t       bool swap,\n+\t\t\t       uint32_t hfn,\n+\t\t\t       unsigned char bearer,\n+\t\t\t       unsigned char direction,\n+\t\t\t       uint32_t hfn_threshold,\n+\t\t\t       struct alginfo *cipherdata,\n+\t\t\t       struct alginfo *authdata,\n+\t\t\t       unsigned char era_2_sw_hfn_ovrd)\n+{\n+\tstatic int\n+\t\t(*pdcp_cp_fp[PDCP_CIPHER_TYPE_INVALID][PDCP_AUTH_TYPE_INVALID])\n+\t\t\t(struct program*, bool swap, struct alginfo *,\n+\t\t\t struct alginfo *, unsigned int, unsigned char) = {\n+\t\t{\t/* NULL */\n+\t\t\tpdcp_insert_cplane_null_op,\t/* NULL */\n+\t\t\tpdcp_insert_cplane_int_only_op,\t/* SNOW f9 */\n+\t\t\tpdcp_insert_cplane_int_only_op,\t/* AES CMAC */\n+\t\t\tpdcp_insert_cplane_int_only_op\t/* ZUC-I */\n+\t\t},\n+\t\t{\t/* SNOW f8 */\n+\t\t\tpdcp_insert_cplane_enc_only_op,\t/* NULL */\n+\t\t\tpdcp_insert_cplane_acc_op,\t/* SNOW f9 */\n+\t\t\tpdcp_insert_cplane_snow_aes_op,\t/* AES CMAC */\n+\t\t\tpdcp_insert_cplane_snow_zuc_op\t/* ZUC-I */\n+\t\t},\n+\t\t{\t/* AES CTR */\n+\t\t\tpdcp_insert_cplane_enc_only_op,\t/* NULL */\n+\t\t\tpdcp_insert_cplane_aes_snow_op,\t/* SNOW f9 */\n+\t\t\tpdcp_insert_cplane_acc_op,\t/* AES CMAC */\n+\t\t\tpdcp_insert_cplane_aes_zuc_op\t/* ZUC-I */\n+\t\t},\n+\t\t{\t/* ZUC-E */\n+\t\t\tpdcp_insert_cplane_enc_only_op,\t/* NULL */\n+\t\t\tpdcp_insert_cplane_zuc_snow_op,\t/* SNOW f9 */\n+\t\t\tpdcp_insert_cplane_zuc_aes_op,\t/* AES CMAC */\n+\t\t\tpdcp_insert_cplane_acc_op\t/* ZUC-I */\n+\t\t},\n+\t};\n+\tstatic enum rta_share_type\n+\t\tdesc_share[PDCP_CIPHER_TYPE_INVALID][PDCP_AUTH_TYPE_INVALID] = {\n+\t\t{\t/* NULL */\n+\t\t\tSHR_WAIT,\t/* NULL */\n+\t\t\tSHR_ALWAYS,\t/* SNOW f9 */\n+\t\t\tSHR_ALWAYS,\t/* AES CMAC */\n+\t\t\tSHR_ALWAYS\t/* ZUC-I */\n+\t\t},\n+\t\t{\t/* SNOW f8 */\n+\t\t\tSHR_ALWAYS,\t/* NULL */\n+\t\t\tSHR_ALWAYS,\t/* SNOW f9 */\n+\t\t\tSHR_WAIT,\t/* AES CMAC */\n+\t\t\tSHR_WAIT\t/* ZUC-I */\n+\t\t},\n+\t\t{\t/* AES CTR */\n+\t\t\tSHR_ALWAYS,\t/* NULL */\n+\t\t\tSHR_ALWAYS,\t/* SNOW f9 */\n+\t\t\tSHR_ALWAYS,\t/* AES CMAC */\n+\t\t\tSHR_WAIT\t/* ZUC-I */\n+\t\t},\n+\t\t{\t/* ZUC-E */\n+\t\t\tSHR_ALWAYS,\t/* NULL */\n+\t\t\tSHR_WAIT,\t/* SNOW f9 */\n+\t\t\tSHR_WAIT,\t/* AES CMAC */\n+\t\t\tSHR_ALWAYS\t/* ZUC-I */\n+\t\t},\n+\t};\n+\tenum pdb_type_e pdb_type;\n+\tstruct program prg;\n+\tstruct program *p = &prg;\n+\tint err;\n+\tLABEL(pdb_end);\n+\n+\tif (rta_sec_era != RTA_SEC_ERA_2 && era_2_sw_hfn_ovrd) {\n+\t\tpr_err(\"Cannot select SW HFN override for other era than 2\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tPROGRAM_CNTXT_INIT(p, descbuf, 0);\n+\tif (swap)\n+\t\tPROGRAM_SET_BSWAP(p);\n+\tif (ps)\n+\t\tPROGRAM_SET_36BIT_ADDR(p);\n+\n+\tSHR_HDR(p, desc_share[cipherdata->algtype][authdata->algtype], 0, 0);\n+\n+\tpdb_type = cnstr_pdcp_c_plane_pdb(p,\n+\t\t\thfn,\n+\t\t\tbearer,\n+\t\t\tdirection,\n+\t\t\thfn_threshold,\n+\t\t\tcipherdata,\n+\t\t\tauthdata);\n+\n+\tSET_LABEL(p, pdb_end);\n+\n+\terr = insert_hfn_ov_op(p, PDCP_SN_SIZE_5, pdb_type,\n+\t\t\t       era_2_sw_hfn_ovrd);\n+\tif (err)\n+\t\treturn err;\n+\n+\terr = pdcp_cp_fp[cipherdata->algtype][authdata->algtype](p,\n+\t\tswap,\n+\t\tcipherdata,\n+\t\tauthdata,\n+\t\tOP_TYPE_DECAP_PROTOCOL,\n+\t\tera_2_sw_hfn_ovrd);\n+\tif (err)\n+\t\treturn err;\n+\n+\tPATCH_HDR(p, 0, pdb_end);\n+\n+\treturn PROGRAM_FINALIZE(p);\n+}\n+\n+/**\n+ * cnstr_shdsc_pdcp_u_plane_encap - Function for creating a PDCP User Plane\n+ *                                  encapsulation descriptor.\n+ * @descbuf: pointer to buffer for descriptor construction\n+ * @ps: if 36/40bit addressing is desired, this parameter must be true\n+ * @swap: must be true when core endianness doesn't match SEC endianness\n+ * @sn_size: selects Sequence Number Size: 7/12/15 bits\n+ * @hfn: starting Hyper Frame Number to be used together with the SN from the\n+ *       PDCP frames.\n+ * @bearer: radio bearer ID\n+ * @direction: the direction of the PDCP frame (UL/DL)\n+ * @hfn_threshold: HFN value that once reached triggers a warning from SEC that\n+ *                 keys should be renegotiated at the earliest convenience.\n+ * @cipherdata: pointer to block cipher transform definitions\n+ *              Valid algorithm values are those from cipher_type_pdcp enum.\n+ * @era_2_sw_hfn_ovrd: if software HFN override mechanism is desired for\n+ *                     this descriptor. Note: Can only be used for\n+ *                     SEC ERA 2.\n+ *\n+ * Return: size of descriptor written in words or negative number on error.\n+ *         Once the function returns, the value of this parameter can be used\n+ *         for reclaiming the space that wasn't used for the descriptor.\n+ *\n+ * Note: descbuf must be large enough to contain a full 256 byte long\n+ * descriptor; after the function returns, by subtracting the actual number of\n+ * bytes used, the user can reuse the remaining buffer space for other purposes.\n+ */\n+static inline int\n+cnstr_shdsc_pdcp_u_plane_encap(uint32_t *descbuf,\n+\t\t\t       bool ps,\n+\t\t\t       bool swap,\n+\t\t\t       enum pdcp_sn_size sn_size,\n+\t\t\t       uint32_t hfn,\n+\t\t\t       unsigned short bearer,\n+\t\t\t       unsigned short direction,\n+\t\t\t       uint32_t hfn_threshold,\n+\t\t\t       struct alginfo *cipherdata,\n+\t\t\t       unsigned char era_2_sw_hfn_ovrd)\n+{\n+\tstruct program prg;\n+\tstruct program *p = &prg;\n+\tint err;\n+\tLABEL(pdb_end);\n+\n+\tif (rta_sec_era != RTA_SEC_ERA_2 && era_2_sw_hfn_ovrd) {\n+\t\tpr_err(\"Cannot select SW HFN ovrd for other era than 2\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tPROGRAM_CNTXT_INIT(p, descbuf, 0);\n+\tif (swap)\n+\t\tPROGRAM_SET_BSWAP(p);\n+\tif (ps)\n+\t\tPROGRAM_SET_36BIT_ADDR(p);\n+\n+\tSHR_HDR(p, SHR_ALWAYS, 0, 0);\n+\tif (cnstr_pdcp_u_plane_pdb(p, sn_size, hfn, bearer, direction,\n+\t\t\t\t   hfn_threshold)) {\n+\t\tpr_err(\"Error creating PDCP UPlane PDB\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\tSET_LABEL(p, pdb_end);\n+\n+\terr = insert_hfn_ov_op(p, sn_size, PDCP_PDB_TYPE_FULL_PDB,\n+\t\t\t       era_2_sw_hfn_ovrd);\n+\tif (err)\n+\t\treturn err;\n+\n+\tswitch (sn_size) {\n+\tcase PDCP_SN_SIZE_7:\n+\tcase PDCP_SN_SIZE_12:\n+\t\tswitch (cipherdata->algtype) {\n+\t\tcase PDCP_CIPHER_TYPE_ZUC:\n+\t\t\tif (rta_sec_era < RTA_SEC_ERA_5) {\n+\t\t\t\tpr_err(\"Invalid era for selected algorithm\\n\");\n+\t\t\t\treturn -ENOTSUP;\n+\t\t\t}\n+\t\tcase PDCP_CIPHER_TYPE_AES:\n+\t\tcase PDCP_CIPHER_TYPE_SNOW:\n+\t\t\t/* Insert Cipher Key */\n+\t\t\tKEY(p, KEY1, cipherdata->key_enc_flags,\n+\t\t\t    (uint64_t)cipherdata->key, cipherdata->keylen,\n+\t\t\t    INLINE_KEY(cipherdata));\n+\t\t\tPROTOCOL(p, OP_TYPE_ENCAP_PROTOCOL,\n+\t\t\t\t OP_PCLID_LTE_PDCP_USER,\n+\t\t\t\t (uint16_t)cipherdata->algtype);\n+\t\t\tbreak;\n+\t\tcase PDCP_CIPHER_TYPE_NULL:\n+\t\t\tinsert_copy_frame_op(p,\n+\t\t\t\t\t     cipherdata,\n+\t\t\t\t\t     OP_TYPE_ENCAP_PROTOCOL);\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\tpr_err(\"%s: Invalid encrypt algorithm selected: %d\\n\",\n+\t\t\t       \"cnstr_pcl_shdsc_pdcp_u_plane_decap\",\n+\t\t\t       cipherdata->algtype);\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\t\tbreak;\n+\n+\tcase PDCP_SN_SIZE_15:\n+\t\tswitch (cipherdata->algtype) {\n+\t\tcase PDCP_CIPHER_TYPE_NULL:\n+\t\t\tinsert_copy_frame_op(p,\n+\t\t\t\t\t     cipherdata,\n+\t\t\t\t\t     OP_TYPE_ENCAP_PROTOCOL);\n+\t\t\tbreak;\n+\n+\t\tdefault:\n+\t\t\terr = pdcp_insert_uplane_15bit_op(p, swap, cipherdata,\n+\t\t\t\tOP_TYPE_ENCAP_PROTOCOL);\n+\t\t\tif (err)\n+\t\t\t\treturn err;\n+\t\t\tbreak;\n+\t\t}\n+\t\tbreak;\n+\n+\tcase PDCP_SN_SIZE_5:\n+\tdefault:\n+\t\tpr_err(\"Invalid SN size selected\\n\");\n+\t\treturn -ENOTSUP;\n+\t}\n+\n+\tPATCH_HDR(p, 0, pdb_end);\n+\treturn PROGRAM_FINALIZE(p);\n+}\n+\n+/**\n+ * cnstr_shdsc_pdcp_u_plane_decap - Function for creating a PDCP User Plane\n+ *                                  decapsulation descriptor.\n+ * @descbuf: pointer to buffer for descriptor construction\n+ * @ps: if 36/40bit addressing is desired, this parameter must be true\n+ * @swap: must be true when core endianness doesn't match SEC endianness\n+ * @sn_size: selects Sequence Number Size: 7/12/15 bits\n+ * @hfn: starting Hyper Frame Number to be used together with the SN from the\n+ *       PDCP frames.\n+ * @bearer: radio bearer ID\n+ * @direction: the direction of the PDCP frame (UL/DL)\n+ * @hfn_threshold: HFN value that once reached triggers a warning from SEC that\n+ *                 keys should be renegotiated at the earliest convenience.\n+ * @cipherdata: pointer to block cipher transform definitions\n+ *              Valid algorithm values are those from cipher_type_pdcp enum.\n+ * @era_2_sw_hfn_ovrd: if software HFN override mechanism is desired for\n+ *                     this descriptor. Note: Can only be used for\n+ *                     SEC ERA 2.\n+ *\n+ * Return: size of descriptor written in words or negative number on error.\n+ *         Once the function returns, the value of this parameter can be used\n+ *         for reclaiming the space that wasn't used for the descriptor.\n+ *\n+ * Note: descbuf must be large enough to contain a full 256 byte long\n+ * descriptor; after the function returns, by subtracting the actual number of\n+ * bytes used, the user can reuse the remaining buffer space for other purposes.\n+ */\n+static inline int\n+cnstr_shdsc_pdcp_u_plane_decap(uint32_t *descbuf,\n+\t\t\t       bool ps,\n+\t\t\t       bool swap,\n+\t\t\t       enum pdcp_sn_size sn_size,\n+\t\t\t       uint32_t hfn,\n+\t\t\t       unsigned short bearer,\n+\t\t\t       unsigned short direction,\n+\t\t\t       uint32_t hfn_threshold,\n+\t\t\t       struct alginfo *cipherdata,\n+\t\t\t       unsigned char era_2_sw_hfn_ovrd)\n+{\n+\tstruct program prg;\n+\tstruct program *p = &prg;\n+\tint err;\n+\tLABEL(pdb_end);\n+\n+\tif (rta_sec_era != RTA_SEC_ERA_2 && era_2_sw_hfn_ovrd) {\n+\t\tpr_err(\"Cannot select SW HFN override for other era than 2\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tPROGRAM_CNTXT_INIT(p, descbuf, 0);\n+\tif (swap)\n+\t\tPROGRAM_SET_BSWAP(p);\n+\tif (ps)\n+\t\tPROGRAM_SET_36BIT_ADDR(p);\n+\n+\tSHR_HDR(p, SHR_ALWAYS, 0, 0);\n+\tif (cnstr_pdcp_u_plane_pdb(p, sn_size, hfn, bearer, direction,\n+\t\t\t\t   hfn_threshold)) {\n+\t\tpr_err(\"Error creating PDCP UPlane PDB\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\tSET_LABEL(p, pdb_end);\n+\n+\terr = insert_hfn_ov_op(p, sn_size, PDCP_PDB_TYPE_FULL_PDB,\n+\t\t\t       era_2_sw_hfn_ovrd);\n+\tif (err)\n+\t\treturn err;\n+\n+\tswitch (sn_size) {\n+\tcase PDCP_SN_SIZE_7:\n+\tcase PDCP_SN_SIZE_12:\n+\t\tswitch (cipherdata->algtype) {\n+\t\tcase PDCP_CIPHER_TYPE_ZUC:\n+\t\t\tif (rta_sec_era < RTA_SEC_ERA_5) {\n+\t\t\t\tpr_err(\"Invalid era for selected algorithm\\n\");\n+\t\t\t\treturn -ENOTSUP;\n+\t\t\t}\n+\t\tcase PDCP_CIPHER_TYPE_AES:\n+\t\tcase PDCP_CIPHER_TYPE_SNOW:\n+\t\t\t/* Insert Cipher Key */\n+\t\t\tKEY(p, KEY1, cipherdata->key_enc_flags,\n+\t\t\t    cipherdata->key, cipherdata->keylen,\n+\t\t\t    INLINE_KEY(cipherdata));\n+\t\t\tPROTOCOL(p, OP_TYPE_DECAP_PROTOCOL,\n+\t\t\t\t OP_PCLID_LTE_PDCP_USER,\n+\t\t\t\t (uint16_t)cipherdata->algtype);\n+\t\t\tbreak;\n+\t\tcase PDCP_CIPHER_TYPE_NULL:\n+\t\t\tinsert_copy_frame_op(p,\n+\t\t\t\t\t     cipherdata,\n+\t\t\t\t\t     OP_TYPE_DECAP_PROTOCOL);\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\tpr_err(\"%s: Invalid encrypt algorithm selected: %d\\n\",\n+\t\t\t       \"cnstr_pcl_shdsc_pdcp_u_plane_decap\",\n+\t\t\t       cipherdata->algtype);\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\t\tbreak;\n+\n+\tcase PDCP_SN_SIZE_15:\n+\t\tswitch (cipherdata->algtype) {\n+\t\tcase PDCP_CIPHER_TYPE_NULL:\n+\t\t\tinsert_copy_frame_op(p,\n+\t\t\t\t\t     cipherdata,\n+\t\t\t\t\t     OP_TYPE_DECAP_PROTOCOL);\n+\t\t\tbreak;\n+\n+\t\tdefault:\n+\t\t\terr = pdcp_insert_uplane_15bit_op(p, swap, cipherdata,\n+\t\t\t\tOP_TYPE_DECAP_PROTOCOL);\n+\t\t\tif (err)\n+\t\t\t\treturn err;\n+\t\t\tbreak;\n+\t\t}\n+\t\tbreak;\n+\n+\tcase PDCP_SN_SIZE_5:\n+\tdefault:\n+\t\tpr_err(\"Invalid SN size selected\\n\");\n+\t\treturn -ENOTSUP;\n+\t}\n+\n+\tPATCH_HDR(p, 0, pdb_end);\n+\treturn PROGRAM_FINALIZE(p);\n+}\n+\n+/**\n+ * cnstr_shdsc_pdcp_short_mac - Function for creating a PDCP Short MAC\n+ *                              descriptor.\n+ * @descbuf: pointer to buffer for descriptor construction\n+ * @ps: if 36/40bit addressing is desired, this parameter must be true\n+ * @swap: must be true when core endianness doesn't match SEC endianness\n+ * @authdata: pointer to authentication transform definitions\n+ *            Valid algorithm values are those from auth_type_pdcp enum.\n+ *\n+ * Return: size of descriptor written in words or negative number on error.\n+ *         Once the function returns, the value of this parameter can be used\n+ *         for reclaiming the space that wasn't used for the descriptor.\n+ *\n+ * Note: descbuf must be large enough to contain a full 256 byte long\n+ * descriptor; after the function returns, by subtracting the actual number of\n+ * bytes used, the user can reuse the remaining buffer space for other purposes.\n+ */\n+static inline int\n+cnstr_shdsc_pdcp_short_mac(uint32_t *descbuf,\n+\t\t\t   bool ps,\n+\t\t\t   bool swap,\n+\t\t\t   struct alginfo *authdata)\n+{\n+\tstruct program prg;\n+\tstruct program *p = &prg;\n+\tuint32_t iv[3] = {0, 0, 0};\n+\tLABEL(local_offset);\n+\tREFERENCE(move_cmd_read_descbuf);\n+\tREFERENCE(move_cmd_write_descbuf);\n+\n+\tPROGRAM_CNTXT_INIT(p, descbuf, 0);\n+\tif (swap)\n+\t\tPROGRAM_SET_BSWAP(p);\n+\tif (ps)\n+\t\tPROGRAM_SET_36BIT_ADDR(p);\n+\n+\tSHR_HDR(p, SHR_ALWAYS, 1, 0);\n+\n+\tif (rta_sec_era > RTA_SEC_ERA_2) {\n+\t\tMATHB(p, SEQINSZ, SUB, ZERO, VSEQINSZ, 4, 0);\n+\t\tMATHB(p, SEQINSZ, SUB, ZERO, MATH1, 4, 0);\n+\t} else {\n+\t\tMATHB(p, SEQINSZ, ADD, ONE, MATH1, 4, 0);\n+\t\tMATHB(p, MATH1, SUB, ONE, MATH1, 4, 0);\n+\t\tMATHB(p, ZERO, ADD, MATH1, VSEQINSZ, 4, 0);\n+\t\tMOVE(p, MATH1, 0, MATH0, 0, 8, IMMED);\n+\n+\t\t/*\n+\t\t * Since MOVELEN is available only starting with\n+\t\t * SEC ERA 3, use poor man's MOVELEN: create a MOVE\n+\t\t * command dynamically by writing the length from M1 by\n+\t\t * OR-ing the command in the M1 register and MOVE the\n+\t\t * result into the descriptor buffer. Care must be taken\n+\t\t * wrt. the location of the command because of SEC\n+\t\t * pipelining. The actual MOVEs are written at the end\n+\t\t * of the descriptor due to calculations needed on the\n+\t\t * offset in the descriptor for the MOVE command.\n+\t\t */\n+\t\tmove_cmd_read_descbuf = MOVE(p, DESCBUF, 0, MATH0, 0, 6,\n+\t\t\t\t\t     IMMED);\n+\t\tmove_cmd_write_descbuf = MOVE(p, MATH0, 0, DESCBUF, 0, 8,\n+\t\t\t\t\t      WAITCOMP | IMMED);\n+\t}\n+\tMATHB(p, ZERO, ADD, MATH1, VSEQOUTSZ, 4, 0);\n+\n+\tswitch (authdata->algtype) {\n+\tcase PDCP_AUTH_TYPE_NULL:\n+\t\tSEQFIFOSTORE(p, MSG, 0, 0, VLF);\n+\t\tif (rta_sec_era > RTA_SEC_ERA_2) {\n+\t\t\tMOVE(p, AB1, 0, OFIFO, 0, MATH1, 0);\n+\t\t} else {\n+\t\t\tSET_LABEL(p, local_offset);\n+\n+\t\t\t/* Shut off automatic Info FIFO entries */\n+\t\t\tLOAD(p, 0, DCTRL, LDOFF_DISABLE_AUTO_NFIFO, 0, IMMED);\n+\n+\t\t\t/* Placeholder for MOVE command with length from M1\n+\t\t\t * register\n+\t\t\t */\n+\t\t\tMOVE(p, IFIFOAB1, 0, OFIFO, 0, 0, IMMED);\n+\n+\t\t\t/* Enable automatic Info FIFO entries */\n+\t\t\tLOAD(p, 0, DCTRL, LDOFF_ENABLE_AUTO_NFIFO, 0, IMMED);\n+\t\t}\n+\n+\t\tLOAD(p, (uintptr_t)iv, MATH0, 0, 8, IMMED | COPY);\n+\t\tSEQFIFOLOAD(p, MSG1, 0, VLF | LAST1 | LAST2 | FLUSH1);\n+\t\tSEQSTORE(p, MATH0, 0, 4, 0);\n+\n+\t\tbreak;\n+\n+\tcase PDCP_AUTH_TYPE_SNOW:\n+\t\tiv[0] = 0xFFFFFFFF;\n+\t\tiv[1] = swap ? swab32(0x04000000) : 0x04000000;\n+\t\tiv[2] = swap ? swab32(0xF8000000) : 0xF8000000;\n+\n+\t\tKEY(p, KEY2, authdata->key_enc_flags, authdata->key,\n+\t\t    authdata->keylen, INLINE_KEY(authdata));\n+\t\tLOAD(p, (uintptr_t)&iv, CONTEXT2, 0, 12, IMMED | COPY);\n+\t\tALG_OPERATION(p, OP_ALG_ALGSEL_SNOW_F9,\n+\t\t\t      OP_ALG_AAI_F9,\n+\t\t\t      OP_ALG_AS_INITFINAL,\n+\t\t\t      ICV_CHECK_DISABLE,\n+\t\t\t      DIR_ENC);\n+\t\tSEQFIFOSTORE(p, MSG, 0, 0, VLF);\n+\n+\t\tif (rta_sec_era > RTA_SEC_ERA_2) {\n+\t\t\tMOVE(p, AB1, 0, OFIFO, 0, MATH1, 0);\n+\t\t} else {\n+\t\t\tSET_LABEL(p, local_offset);\n+\n+\n+\t\t\t/* Shut off automatic Info FIFO entries */\n+\t\t\tLOAD(p, 0, DCTRL, LDOFF_DISABLE_AUTO_NFIFO, 0, IMMED);\n+\n+\t\t\t/* Placeholder for MOVE command with length from M1\n+\t\t\t * register\n+\t\t\t */\n+\t\t\tMOVE(p, IFIFOAB1, 0, OFIFO, 0, 0, IMMED);\n+\n+\t\t\t/* Enable automatic Info FIFO entries */\n+\t\t\tLOAD(p, 0, DCTRL, LDOFF_ENABLE_AUTO_NFIFO, 0, IMMED);\n+\t\t}\n+\t\tSEQFIFOLOAD(p, MSGINSNOOP, 0, VLF | LAST1 | LAST2 | FLUSH1);\n+\t\tSEQSTORE(p, CONTEXT2, 0, 4, 0);\n+\n+\t\tbreak;\n+\n+\tcase PDCP_AUTH_TYPE_AES:\n+\t\tiv[0] = 0xFFFFFFFF;\n+\t\tiv[1] = swap ? swab32(0xFC000000) : 0xFC000000;\n+\t\tiv[2] = 0x00000000; /* unused */\n+\n+\t\tKEY(p, KEY1, authdata->key_enc_flags, authdata->key,\n+\t\t    authdata->keylen, INLINE_KEY(authdata));\n+\t\tLOAD(p, (uintptr_t)&iv, MATH0, 0, 8, IMMED | COPY);\n+\t\tMOVE(p, MATH0, 0, IFIFOAB1, 0, 8, IMMED);\n+\t\tALG_OPERATION(p, OP_ALG_ALGSEL_AES,\n+\t\t\t      OP_ALG_AAI_CMAC,\n+\t\t\t      OP_ALG_AS_INITFINAL,\n+\t\t\t      ICV_CHECK_DISABLE,\n+\t\t\t      DIR_ENC);\n+\t\tSEQFIFOSTORE(p, MSG, 0, 0, VLF);\n+\n+\t\tif (rta_sec_era > RTA_SEC_ERA_2) {\n+\t\t\tMOVE(p, AB2, 0, OFIFO, 0, MATH1, 0);\n+\t\t} else {\n+\t\t\tSET_LABEL(p, local_offset);\n+\n+\t\t\t/* Shut off automatic Info FIFO entries */\n+\t\t\tLOAD(p, 0, DCTRL, LDOFF_DISABLE_AUTO_NFIFO, 0, IMMED);\n+\n+\t\t\t/* Placeholder for MOVE command with length from M1\n+\t\t\t * register\n+\t\t\t */\n+\t\t\tMOVE(p, IFIFOAB2, 0, OFIFO, 0, 0, IMMED);\n+\n+\t\t\t/* Enable automatic Info FIFO entries */\n+\t\t\tLOAD(p, 0, DCTRL, LDOFF_ENABLE_AUTO_NFIFO, 0, IMMED);\n+\t\t}\n+\t\tSEQFIFOLOAD(p, MSGINSNOOP, 0, VLF | LAST1 | LAST2 | FLUSH1);\n+\t\tSEQSTORE(p, CONTEXT1, 0, 4, 0);\n+\n+\t\tbreak;\n+\n+\tcase PDCP_AUTH_TYPE_ZUC:\n+\t\tif (rta_sec_era < RTA_SEC_ERA_5) {\n+\t\t\tpr_err(\"Invalid era for selected algorithm\\n\");\n+\t\t\treturn -ENOTSUP;\n+\t\t}\n+\t\tiv[0] = 0xFFFFFFFF;\n+\t\tiv[1] = swap ? swab32(0xFC000000) : 0xFC000000;\n+\t\tiv[2] = 0x00000000; /* unused */\n+\n+\t\tKEY(p, KEY2, authdata->key_enc_flags, authdata->key,\n+\t\t    authdata->keylen, INLINE_KEY(authdata));\n+\t\tLOAD(p, (uintptr_t)&iv, CONTEXT2, 0, 12, IMMED | COPY);\n+\t\tALG_OPERATION(p, OP_ALG_ALGSEL_ZUCA,\n+\t\t\t      OP_ALG_AAI_F9,\n+\t\t\t      OP_ALG_AS_INITFINAL,\n+\t\t\t      ICV_CHECK_DISABLE,\n+\t\t\t      DIR_ENC);\n+\t\tSEQFIFOSTORE(p, MSG, 0, 0, VLF);\n+\t\tMOVE(p, AB1, 0, OFIFO, 0, MATH1, 0);\n+\t\tSEQFIFOLOAD(p, MSGINSNOOP, 0, VLF | LAST1 | LAST2 | FLUSH1);\n+\t\tSEQSTORE(p, CONTEXT2, 0, 4, 0);\n+\n+\t\tbreak;\n+\n+\tdefault:\n+\t\tpr_err(\"%s: Invalid integrity algorithm selected: %d\\n\",\n+\t\t       \"cnstr_shdsc_pdcp_short_mac\", authdata->algtype);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\n+\tif (rta_sec_era < RTA_SEC_ERA_3) {\n+\t\tPATCH_MOVE(p, move_cmd_read_descbuf, local_offset);\n+\t\tPATCH_MOVE(p, move_cmd_write_descbuf, local_offset);\n+\t}\n+\n+\treturn PROGRAM_FINALIZE(p);\n+}\n+\n+#endif /* __DESC_PDCP_H__ */\n",
    "prefixes": [
        "v5",
        "2/3"
    ]
}