From patchwork Fri Sep 8 08:45:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 112032 Delivered-To: patch@linaro.org Received: by 10.37.128.210 with SMTP id c18csp1244789ybm; Fri, 8 Sep 2017 01:48:16 -0700 (PDT) X-Google-Smtp-Source: ADKCNb5JXZ6zkMSm0OXzh8ksO+ddRDXT/digmKp5cQr5aAnlTXQnxIE5Ryo3FQ2OXMH0bC91null X-Received: by 10.223.166.99 with SMTP id k90mr1334012wrc.183.1504860496291; Fri, 08 Sep 2017 01:48:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504860496; cv=none; d=google.com; s=arc-20160816; b=M9tmAf4fTJG2Nfl2phoP7NklKO7oqErknPF3jfCYpWWgzPohfV3eBkooCWBjIHXDTD MxWuN1NdyKk8uFy+uV2EFWcvMph8mzmQcx2GUCo+7DKTWAbTz8nuGBKbALl74rSCUvQh /yujRMSPw3ukGJsne6OjU64CrGwH36YlQ84u/e85Y9TnzGNw62TVWBUEY8CEYnPRrL69 sspv5psOFfY1GmjPWuxOZKikUvhLShgJqdmP7lLRByoC7OUlve1q4EPWy1P9Fmj+I7tY 0lSxndw0t5QGW5v6aEyNOCbBOqvgZK7PlFamNMS65/QnthGB0m2FazgpXzIDUYLVU9PD gChQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:spamdiagnosticmetadata :spamdiagnosticoutput:mime-version:references:in-reply-to:message-id :date:cc:to:from:arc-authentication-results; bh=76ItS+z6q1AXM1+3VdSAJ2IN2jYBfPzH7kTzybuU5jc=; b=rPBURB3HRmCyC/QIPvmugsCGJI73ODYuoXUrWxBpRPDhW2923iYG3hbvqGH6rcnfoG WjOKVilEZAjdX508aNoBf3SZefzIAv3Mlve/lDSCtoorP3rZsLJKfwswt2L9K7Yxqcsl zRP7fn4FFPo32Igh6GhS9xochKTD0pLxVnsZM2blw0yL2zxC/rDNFR8Piw3dwDb0JM5y YmFQ7KjPMl65SzcsHOdrw04H1nQoGTNwX8lLGAGUT+IwdF3UIMZDZcTP/YFT5HbyijS4 JwbcbHl+JYpkDYECFNK/9v5q5RFAh9rEmazrYvq72fqA6HojcYiKNX1XRBGi/rotNQrh FHCg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from dpdk.org (dpdk.org. [92.243.14.124]) by mx.google.com with ESMTP id l9si1063112wra.97.2017.09.08.01.48.16; Fri, 08 Sep 2017 01:48:16 -0700 (PDT) Received-SPF: pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) client-ip=92.243.14.124; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 500AF199D3; Fri, 8 Sep 2017 10:46:17 +0200 (CEST) Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-dm3nam03on0062.outbound.protection.outlook.com [104.47.41.62]) by dpdk.org (Postfix) with ESMTP id 20497199EE for ; Fri, 8 Sep 2017 10:46:15 +0200 (CEST) Received: from BN3PR03CA0109.namprd03.prod.outlook.com (10.174.66.27) by CY4PR03MB3317.namprd03.prod.outlook.com (10.171.246.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.13.10; Fri, 8 Sep 2017 08:46:13 +0000 Received: from BY2FFO11FD007.protection.gbl (2a01:111:f400:7c0c::121) by BN3PR03CA0109.outlook.office365.com (2603:10b6:400:4::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.35.12 via Frontend Transport; Fri, 8 Sep 2017 08:46:12 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BY2FFO11FD007.mail.protection.outlook.com (10.1.14.128) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1385.11 via Frontend Transport; Fri, 8 Sep 2017 08:46:12 +0000 Received: from bf-netperf1.ap.freescale.net (bf-netperf1.ap.freescale.net [10.232.134.28]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id v888jmoh023063; Fri, 8 Sep 2017 01:46:10 -0700 From: Hemant Agrawal To: CC: , Date: Fri, 8 Sep 2017 14:15:08 +0530 Message-ID: <1504860327-18451-12-git-send-email-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504860327-18451-1-git-send-email-hemant.agrawal@nxp.com> References: <1503658183-4078-1-git-send-email-hemant.agrawal@nxp.com> <1504860327-18451-1-git-send-email-hemant.agrawal@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131493339724827245; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(336005)(39860400002)(39380400002)(2980300002)(1109001)(1110001)(339900001)(51234002)(189002)(45074003)(199003)(8936002)(81156014)(81166006)(50226002)(105606002)(106466001)(2351001)(8656003)(8676002)(110136004)(85426001)(77096006)(4326008)(33646002)(5660300001)(97736004)(5003940100001)(305945005)(356003)(2950100002)(6916009)(47776003)(50466002)(48376002)(50986999)(76176999)(189998001)(86362001)(575784001)(36756003)(68736007)(2906002)(15650500001)(53946003)(16200700003)(104016004)(498600001)(53936002)(54906002)(579004)(559001)(569006); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR03MB3317; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD007; 1:lCtyCwX3Qjvcolu5PibLCeWa3j9eJxbO4ehpHKaN2FCQtw9TsMwTc6NtguYAiA9d4GrHPd2YErj9JPZSJ3Cg4JMwNkfXhDAqzbNn9Vh7HBHY2+Rwg/gAgkx3j10D4PMK MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3c852f33-dd69-40e6-bf65-08d4f6960f04 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(300000502095)(300135100095)(22001)(300000503095)(300135400095)(2017052603199)(201703131430075)(201703131517081)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:CY4PR03MB3317; X-Microsoft-Exchange-Diagnostics: 1; CY4PR03MB3317; 3:KHxIpGnz21EPKtkg/iUf1Bsao4FTdWZoWEc48IYazXYsxhWiYCIzn+nwic0qJjxETguAhrwinGDDHWAy7YhknYBxcN3ql93Rfo63FbQvMn2ILXHHqTyw1VpH0eLnRr/DuDZMLMMSzuKHUrhCT0oDzcXvzaIgrawPvQh1PnxqEe96zzC3SqDxV3+wUM443um5TbyzumayAitpSOyOyRApPsXFXInwAc9Zvhg78vFlbyb3qvTnGXG+XtnPRa+igv8QhwWAoAcyc6Xqh/rh7GiXeR+sAWlaLx18gAcq4Heb2jLIAUBJ17JzBiWODkpCnAackQBwE4Wfgw55/Bsxy8h+tGqUOOg5NDdssjt6Ux/7HXc=; 25:kN7JYqP0pNqGU6+Ry7H5UL4BWuEYb/Mxrj366kGAUpd0oylYERDFWjXWJP3YnqQk3ayjqxYdzfgh2/4HLFY//r6RT+zOrep7aZb7cbX+td6JgFbZJeK6jw7q7AX7jod3y04jRfMHtiZz20BizdKQl7dFX82PQBGfLbMtXafbb4hgCj0C9yqqVFiB2h7u77PdgHyFQyk7Vq7wqaPmBzSg21lynUOJRFrVh+cmDhnHxb28aq0j5dViQoCrgJJEu9ynyBRSt/Rs9lNKkgQKudZcmD4GdkzekBxjUEj2qDiXkb/IIBOnHRQxZVtiNYheM7M2qTjnGOBCsjh+tW9R6zvCkA== X-MS-TrafficTypeDiagnostic: CY4PR03MB3317: X-Microsoft-Exchange-Diagnostics: 1; CY4PR03MB3317; 31:ghU1XDlhoLoEEqt+jPGTBtnR281UQFzHnnPyEdgKSFPlLOgUnr1zFEo3IGUegP30ePu6LaKavYYlyrfqkVNkx/W6JOljygjxuxhitgrZgVXIh6OAAHt2qmvPJZCjSKRg3sIEJVMbvixETjE3FcqF3cjWsgz8JKwjCJ9dgEZtIyhHbTNA92WPniKQ2XwoBMkJQj6wIPg8LnEaJKmEDzFy7pTSv07mqRP9UEVW9apjDj4=; 4:6bA94fj/oP1uMxR1I1plDgOsfh8k/2q2oqzt4wxgwzjfGBKGVyZDjn97kxRL2m3sSd3Unawu3HHlGdb57zA60TFXCisF8EnVONmz3fxxkV9/ibnDFO1zYEV+4vvNDKvSnTWSsW5IyG8PUsML/2Wyfyx6oZHjh1wzN8D3oKgADiSUxZEAcdzmzpn8WD/d7V6mjDh/SIiV4AbaKeoIqobeAEdE947f/Ph0+kVD9fX6rDhpDbqUjluuZZk2lke1S2KRqFgGpxOIZ1gA2tKvF6hwUgEhNhw7tsDeP47VwNS+PgWe5PDGfEwNne9DyUVJ8PFvSDDDyIcKjvFzupSSU1xPdA== X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(275809806118684); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6095135)(2401047)(8121501046)(5005006)(10201501046)(3002001)(100000703101)(100105400095)(93006095)(93001095)(6055026)(6096035)(20161123556025)(20161123561025)(20161123559100)(201703131430075)(201703131433075)(201703131441075)(201703131448075)(201703161259150)(20161123565025)(20161123563025)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:CY4PR03MB3317; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(400006)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:CY4PR03MB3317; X-Forefront-PRVS: 04244E0DC5 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY4PR03MB3317; 23:bEL6ffpLz2/lF1JQKR9cgXFACmqzZ8r+v7ZjiAkJC?= W/j+WkDkmmW6OKV9ap268muRP6dsHBlEgmEovrtZAkO0Rotj3tGPq8sktB/bsxK/i/RaR/WgZo96Lx4dnLVW27H4d82EvOD6iSZU9vitHrYREd0zaVFAVFYTR+uoLmwkcIY1LK+ICENWT8pyyFK6coz/MaXtKDZbq3bJvvq4qByErLQZjaqHmrgFzQdIk02QAM1hez/q6Va150/XhsX0Vwt8dMaQX1hQGNE+/CRZP4/KKibiAX5xfCXQnV1dTkKQDF+vlUttfAStayZq75FmRV/oNx+h0wxsnUNr3sBqN23XCCmAkeNpB3avzglNfEFQx0RquZpqwkP7x1ScQwU3CdhRXs2BuxDhhhDezGoTXKa2rAy4vVg8K9Tsq6dXzjVJN0Kw3aKaqrVbJYcfdwdfPdvKYk9Hqk7RD0PDz1bPf3+nhxMUV3EuA7P+U3SutgOYhmcwu2hPh63r4jKM3bvoa151RNWqSkS/dwVmbMq9VPLApldQ/O8yhXLUpnM25gdcGr+ZTHDxeumNXKsp0qoYi2i7AUrNmumnFD6cfRZtGdlstw6cVsmj+vYDT9ZsrgqVTMejnKBexIwO4S/0+rfMrUlYGHheOauAedotj1xayYzviXXmup0PMbdoWXWiCYYkaoZTiQjylhvzwGpu+Uzk6jrBuT/583QNIIYkR4ImhXGTz/tcYIeQHsHvzzaDZHMQTkQx/l8bmfVHBEVUQBJnUFEUU1Z5Ri6y3Hlkty2L0DehM7rCEDWvhfGxSk6K9/k+r3b02bxzik/WZ2gD2wXA+OgqEX5PjiAjMdjBz3YAH31CwDoVowgefvCGrZdCcqGfWOn7gt52ElkD+DO5l8gJB2FTnY+9FqoGwNwherUyoMcUGazdSRjI2K22EdD9q877r4xhNaDU0qQcqbLJgTBGT07wUlIV1hMasM/Vnug7dfhszLfs3OsjICCWmqeN5DYacg4tOo1QAHhD5YUHsllNI4HgvxkyiSFgf5P41DYuBvCcmdzQjUADMT0SCP+nqPlWH/R0kHFH1mssoLhZnbMDn04pHll5aA1+m8TnQ3g5gw280ir4odl4jd1L+XywT8yeLgueC+2Hus+aLWMI5a16dRkzIeb5H5BIOzJwuVTdsVI7MoC1Gt/b/wU1Qwf0Q7n+oZWlSGWgHN+ZpjUVNWTiG1yDGEipxV0pRJjxanhcosKdhk3gKNyzxs59YfuvWLXfJrz0dpfwKdi2TbcEcha9uJ6/drLfE/UKDhewuHpDSEzjg== X-Microsoft-Exchange-Diagnostics: 1; CY4PR03MB3317; 6:m9tRiksEmgOEXxiMY+I4ecYYZCHgA7FiaY22rt9NxtRSRSUcEGr38q/VYs9lmSidX3X2/+HWOoacFLeGLiwTHcYTh3djmToAwmeX7AY3XD6smY3zZL82gmr30NFgqM2ts9fmqlzXRZ6WZA3RFuoEdPJ4PUJ1ucnQSii8MZa6IRUQz24wISav1hhOMjYMbe10LW/oXYSm1hXm3FRS3qldRMab1IqPMxepKrMXlWX0i40EotuBmhbKvn3WYyYv7kWshYf4OyYnsWllcgFj9/jxUu4+V85RCLC90m/xV99QaVBohBb5rbsBXjY0NnNqXBEj4jVCTaNHGXQI1SPl4eTydg==; 5:bR6TqRKnoNjcMws4GKhbxubqOvaKqlD+8ztP+m9hLqXydKOyliUVoIjcsUk0YqiVl7EeokDkbF6k/7bLKMrXMtTdlXlx9fi7Buyfxj15sTXvavw19fW1H8XvG/HkQLBE0UbYmpNA26sNzkZgXCvotw==; 24:CfaOHW/vZ71L4P4WSxT4Fpe8nTNb5E0NQ/O7wY2veH2iISIN9mQRXUmIPOwZdVnae4CM9PVm9+S3FaeNZNGvjFCRmGBytP7I2YqZmzJb8b8=; 7:j1B6AxKfDumdL58BCdIfgDUVY1LVOG82FfgvXuQoDlTdLa2xlfqGdPECAU5GgDRbhPFRbj5hXa4WARysDrNFRMJM2kWn/huH/61R66mjRgWqqZAugCTM9zxuqYJxgeI3Jc1mjg6yPZGXpFuk3K3QYWWHb6DMTNHLgxjE+u7bUNh8Yc+c03UM1ko9PYBkU7w/wrg8HfsHRHBg84CPIin9ohuV6sWbaSXfX+yUHLIDqp8= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Sep 2017 08:46:12.1707 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR03MB3317 Subject: [dpdk-dev] [PATCH v2 11/30] crypto/dpaa2_sec: update MC to 10.3.x X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Shreyansh Jain Signed-off-by: Shreyansh Jain --- drivers/crypto/dpaa2_sec/mc/dpseci.c | 676 +++++++++++++---------- drivers/crypto/dpaa2_sec/mc/fsl_dpseci.h | 782 ++++++++------------------- drivers/crypto/dpaa2_sec/mc/fsl_dpseci_cmd.h | 387 ++++++------- 3 files changed, 808 insertions(+), 1037 deletions(-) -- 2.7.4 diff --git a/drivers/crypto/dpaa2_sec/mc/dpseci.c b/drivers/crypto/dpaa2_sec/mc/dpseci.c index 4a10962..2a216af 100644 --- a/drivers/crypto/dpaa2_sec/mc/dpseci.c +++ b/drivers/crypto/dpaa2_sec/mc/dpseci.c @@ -37,18 +37,34 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ - #include #include #include #include -int -dpseci_open(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - int dpseci_id, - uint16_t *token) +/** + * dpseci_open() - Open a control session for the specified object + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @dpseci_id: DPSECI unique ID + * @token: Returned token; use in subsequent API calls + * + * This function can be used to open a control session for an + * already created object; an object may have been declared in + * the DPL or by calling the dpseci_create() function. + * This function returns a unique authentication token, + * associated with the specific object ID and the specific MC + * portal; this token must be used in all subsequent commands for + * this specific object. + * + * Return: '0' on Success; Error code otherwise. + */ +int dpseci_open(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + int dpseci_id, + uint16_t *token) { + struct dpseci_cmd_open *cmd_params; struct mc_command cmd = { 0 }; int err; @@ -56,23 +72,34 @@ dpseci_open(struct fsl_mc_io *mc_io, cmd.header = mc_encode_cmd_header(DPSECI_CMDID_OPEN, cmd_flags, 0); - DPSECI_CMD_OPEN(cmd, dpseci_id); + cmd_params = (struct dpseci_cmd_open *)cmd.params; + cmd_params->dpseci_id = cpu_to_le32(dpseci_id); - /* send command to mc */ + /* send command to mc*/ err = mc_send_command(mc_io, &cmd); if (err) return err; /* retrieve response parameters */ - *token = MC_CMD_HDR_READ_TOKEN(cmd.header); + *token = mc_cmd_hdr_read_token(&cmd); return 0; } -int -dpseci_close(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token) +/** + * dpseci_close() - Close the control session of the object + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPSECI object + * + * After this function is called, no further operations are + * allowed on the object without opening a new control session. + * + * Return: '0' on Success; Error code otherwise. + */ +int dpseci_close(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token) { struct mc_command cmd = { 0 }; @@ -81,478 +108,569 @@ dpseci_close(struct fsl_mc_io *mc_io, cmd_flags, token); - /* send command to mc */ + /* send command to mc*/ return mc_send_command(mc_io, &cmd); } -int -dpseci_create(struct fsl_mc_io *mc_io, - uint16_t dprc_token, - uint32_t cmd_flags, - const struct dpseci_cfg *cfg, - uint32_t *obj_id) +/** + * dpseci_create() - Create the DPSECI object + * @mc_io: Pointer to MC portal's I/O object + * @dprc_token: Parent container token; '0' for default container + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @cfg: Configuration structure + * @obj_id: Returned object id + * + * Create the DPSECI object, allocate required resources and + * perform required initialization. + * + * The object can be created either by declaring it in the + * DPL file, or by calling this function. + * + * The function accepts an authentication token of a parent + * container that this object should be assigned to. The token + * can be '0' so the object will be assigned to the default container. + * The newly created object can be opened with the returned + * object id and using the container's associated tokens and MC portals. + * + * Return: '0' on Success; Error code otherwise. + */ +int dpseci_create(struct fsl_mc_io *mc_io, + uint16_t dprc_token, + uint32_t cmd_flags, + const struct dpseci_cfg *cfg, + uint32_t *obj_id) { + struct dpseci_cmd_create *cmd_params; struct mc_command cmd = { 0 }; - int err; + int err, i; /* prepare command */ cmd.header = mc_encode_cmd_header(DPSECI_CMDID_CREATE, cmd_flags, dprc_token); - DPSECI_CMD_CREATE(cmd, cfg); - - /* send command to mc */ + cmd_params = (struct dpseci_cmd_create *)cmd.params; + for (i = 0; i < DPSECI_PRIO_NUM; i++) + cmd_params->priorities[i] = cfg->priorities[i]; + cmd_params->num_tx_queues = cfg->num_tx_queues; + cmd_params->num_rx_queues = cfg->num_rx_queues; + cmd_params->options = cfg->options; + + /* send command to mc*/ err = mc_send_command(mc_io, &cmd); if (err) return err; /* retrieve response parameters */ - CMD_CREATE_RSP_GET_OBJ_ID_PARAM0(cmd, *obj_id); + *obj_id = mc_cmd_read_object_id(&cmd); return 0; } -int -dpseci_destroy(struct fsl_mc_io *mc_io, - uint16_t dprc_token, - uint32_t cmd_flags, - uint32_t object_id) +/** + * dpseci_destroy() - Destroy the DPSECI object and release all its resources. + * @mc_io: Pointer to MC portal's I/O object + * @dprc_token: Parent container token; '0' for default container + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @object_id: The object id; it must be a valid id within the container that + * created this object; + * + * The function accepts the authentication token of the parent container that + * created the object (not the one that currently owns the object). The object + * is searched within parent using the provided 'object_id'. + * All tokens to the object must be closed before calling destroy. + * + * Return: '0' on Success; error code otherwise. + */ +int dpseci_destroy(struct fsl_mc_io *mc_io, + uint16_t dprc_token, + uint32_t cmd_flags, + uint32_t object_id) { + struct dpseci_cmd_destroy *cmd_params; struct mc_command cmd = { 0 }; /* prepare command */ cmd.header = mc_encode_cmd_header(DPSECI_CMDID_DESTROY, cmd_flags, dprc_token); - /* set object id to destroy */ - CMD_DESTROY_SET_OBJ_ID_PARAM0(cmd, object_id); - /* send command to mc */ - return mc_send_command(mc_io, &cmd); -} - -int -dpseci_enable(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token) -{ - struct mc_command cmd = { 0 }; + cmd_params = (struct dpseci_cmd_destroy *)cmd.params; + cmd_params->dpseci_id = cpu_to_le32(object_id); - /* prepare command */ - cmd.header = mc_encode_cmd_header(DPSECI_CMDID_ENABLE, - cmd_flags, - token); - - /* send command to mc */ + /* send command to mc*/ return mc_send_command(mc_io, &cmd); } -int -dpseci_disable(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token) -{ - struct mc_command cmd = { 0 }; - - /* prepare command */ - cmd.header = mc_encode_cmd_header(DPSECI_CMDID_DISABLE, - cmd_flags, - token); - - /* send command to mc */ - return mc_send_command(mc_io, &cmd); -} - -int -dpseci_is_enabled(struct fsl_mc_io *mc_io, +/** + * dpseci_enable() - Enable the DPSECI, allow sending and receiving frames. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPSECI object + * + * Return: '0' on Success; Error code otherwise. + */ +int dpseci_enable(struct fsl_mc_io *mc_io, uint32_t cmd_flags, - uint16_t token, - int *en) -{ - struct mc_command cmd = { 0 }; - int err; - /* prepare command */ - cmd.header = mc_encode_cmd_header(DPSECI_CMDID_IS_ENABLED, - cmd_flags, - token); - - /* send command to mc */ - err = mc_send_command(mc_io, &cmd); - if (err) - return err; - - /* retrieve response parameters */ - DPSECI_RSP_IS_ENABLED(cmd, *en); - - return 0; -} - -int -dpseci_reset(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token) + uint16_t token) { struct mc_command cmd = { 0 }; /* prepare command */ - cmd.header = mc_encode_cmd_header(DPSECI_CMDID_RESET, + cmd.header = mc_encode_cmd_header(DPSECI_CMDID_ENABLE, cmd_flags, token); - /* send command to mc */ + /* send command to mc*/ return mc_send_command(mc_io, &cmd); } -int -dpseci_get_irq(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - uint8_t irq_index, - int *type, - struct dpseci_irq_cfg *irq_cfg) -{ - struct mc_command cmd = { 0 }; - int err; - - /* prepare command */ - cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_IRQ, - cmd_flags, - token); - DPSECI_CMD_GET_IRQ(cmd, irq_index); - - /* send command to mc */ - err = mc_send_command(mc_io, &cmd); - if (err) - return err; - - /* retrieve response parameters */ - DPSECI_RSP_GET_IRQ(cmd, *type, irq_cfg); - - return 0; -} - -int -dpseci_set_irq(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - uint8_t irq_index, - struct dpseci_irq_cfg *irq_cfg) +/** + * dpseci_disable() - Disable the DPSECI, stop sending and receiving frames. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPSECI object + * + * Return: '0' on Success; Error code otherwise. + */ +int dpseci_disable(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token) { struct mc_command cmd = { 0 }; /* prepare command */ - cmd.header = mc_encode_cmd_header(DPSECI_CMDID_SET_IRQ, + cmd.header = mc_encode_cmd_header(DPSECI_CMDID_DISABLE, cmd_flags, token); - DPSECI_CMD_SET_IRQ(cmd, irq_index, irq_cfg); - /* send command to mc */ + /* send command to mc*/ return mc_send_command(mc_io, &cmd); } -int -dpseci_get_irq_enable(struct fsl_mc_io *mc_io, +/** + * dpseci_is_enabled() - Check if the DPSECI is enabled. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPSECI object + * @en: Returns '1' if object is enabled; '0' otherwise + * + * Return: '0' on Success; Error code otherwise. + */ +int dpseci_is_enabled(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, - uint8_t irq_index, - uint8_t *en) + int *en) { + struct dpseci_rsp_is_enabled *rsp_params; struct mc_command cmd = { 0 }; int err; /* prepare command */ - cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_IRQ_ENABLE, + cmd.header = mc_encode_cmd_header(DPSECI_CMDID_IS_ENABLED, cmd_flags, token); - DPSECI_CMD_GET_IRQ_ENABLE(cmd, irq_index); - /* send command to mc */ + /* send command to mc*/ err = mc_send_command(mc_io, &cmd); if (err) return err; /* retrieve response parameters */ - DPSECI_RSP_GET_IRQ_ENABLE(cmd, *en); + rsp_params = (struct dpseci_rsp_is_enabled *)cmd.params; + *en = dpseci_get_field(rsp_params->en, ENABLE); return 0; } -int -dpseci_set_irq_enable(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - uint8_t irq_index, - uint8_t en) +/** + * dpseci_reset() - Reset the DPSECI, returns the object to initial state. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPSECI object + * + * Return: '0' on Success; Error code otherwise. + */ +int dpseci_reset(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token) { struct mc_command cmd = { 0 }; /* prepare command */ - cmd.header = mc_encode_cmd_header(DPSECI_CMDID_SET_IRQ_ENABLE, + cmd.header = mc_encode_cmd_header(DPSECI_CMDID_RESET, cmd_flags, token); - DPSECI_CMD_SET_IRQ_ENABLE(cmd, irq_index, en); - /* send command to mc */ + /* send command to mc*/ return mc_send_command(mc_io, &cmd); } -int -dpseci_get_irq_mask(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - uint8_t irq_index, - uint32_t *mask) +/** + * dpseci_get_attributes() - Retrieve DPSECI attributes. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPSECI object + * @attr: Returned object's attributes + * + * Return: '0' on Success; Error code otherwise. + */ +int dpseci_get_attributes(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + struct dpseci_attr *attr) { + struct dpseci_rsp_get_attr *rsp_params; struct mc_command cmd = { 0 }; int err; /* prepare command */ - cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_IRQ_MASK, + cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_ATTR, cmd_flags, token); - DPSECI_CMD_GET_IRQ_MASK(cmd, irq_index); - /* send command to mc */ + /* send command to mc*/ err = mc_send_command(mc_io, &cmd); if (err) return err; /* retrieve response parameters */ - DPSECI_RSP_GET_IRQ_MASK(cmd, *mask); + rsp_params = (struct dpseci_rsp_get_attr *)cmd.params; + attr->id = le32_to_cpu(rsp_params->id); + attr->options = rsp_params->options; + attr->num_tx_queues = rsp_params->num_tx_queues; + attr->num_rx_queues = rsp_params->num_rx_queues; return 0; } -int -dpseci_set_irq_mask(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - uint8_t irq_index, - uint32_t mask) +/** + * dpseci_set_rx_queue() - Set Rx queue configuration + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPSECI object + * @queue: Select the queue relative to number of + * priorities configured at DPSECI creation; use + * DPSECI_ALL_QUEUES to configure all Rx queues identically. + * @cfg: Rx queue configuration + * + * Return: '0' on Success; Error code otherwise. + */ +int dpseci_set_rx_queue(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + uint8_t queue, + const struct dpseci_rx_queue_cfg *cfg) { + struct dpseci_cmd_set_rx_queue *cmd_params; struct mc_command cmd = { 0 }; /* prepare command */ - cmd.header = mc_encode_cmd_header(DPSECI_CMDID_SET_IRQ_MASK, + cmd.header = mc_encode_cmd_header(DPSECI_CMDID_SET_RX_QUEUE, cmd_flags, token); - DPSECI_CMD_SET_IRQ_MASK(cmd, irq_index, mask); - - /* send command to mc */ + cmd_params = (struct dpseci_cmd_set_rx_queue *)cmd.params; + cmd_params->dest_id = cpu_to_le32(cfg->dest_cfg.dest_id); + cmd_params->dest_priority = cfg->dest_cfg.priority; + cmd_params->queue = queue; + cmd_params->user_ctx = cpu_to_le64(cfg->user_ctx); + cmd_params->options = cpu_to_le32(cfg->options); + dpseci_set_field(cmd_params->dest_type, + DEST_TYPE, + cfg->dest_cfg.dest_type); + dpseci_set_field(cmd_params->order_preservation_en, + ORDER_PRESERVATION, + cfg->order_preservation_en); + + /* send command to mc*/ return mc_send_command(mc_io, &cmd); } -int -dpseci_get_irq_status(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - uint8_t irq_index, - uint32_t *status) +/** + * dpseci_get_rx_queue() - Retrieve Rx queue attributes. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPSECI object + * @queue: Select the queue relative to number of + * priorities configured at DPSECI creation + * @attr: Returned Rx queue attributes + * + * Return: '0' on Success; Error code otherwise. + */ +int dpseci_get_rx_queue(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + uint8_t queue, + struct dpseci_rx_queue_attr *attr) { + struct dpseci_rsp_get_rx_queue *rsp_params; + struct dpseci_cmd_get_queue *cmd_params; struct mc_command cmd = { 0 }; int err; /* prepare command */ - cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_IRQ_STATUS, + cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_RX_QUEUE, cmd_flags, token); - DPSECI_CMD_GET_IRQ_STATUS(cmd, irq_index, *status); + cmd_params = (struct dpseci_cmd_get_queue *)cmd.params; + cmd_params->queue = queue; - /* send command to mc */ + /* send command to mc*/ err = mc_send_command(mc_io, &cmd); if (err) return err; /* retrieve response parameters */ - DPSECI_RSP_GET_IRQ_STATUS(cmd, *status); + rsp_params = (struct dpseci_rsp_get_rx_queue *)cmd.params; + attr->user_ctx = le64_to_cpu(rsp_params->user_ctx); + attr->fqid = le32_to_cpu(rsp_params->fqid); + attr->dest_cfg.dest_id = le32_to_cpu(rsp_params->dest_id); + attr->dest_cfg.priority = rsp_params->dest_priority; + attr->dest_cfg.dest_type = + dpseci_get_field(rsp_params->dest_type, + DEST_TYPE); + attr->order_preservation_en = + dpseci_get_field(rsp_params->order_preservation_en, + ORDER_PRESERVATION); return 0; } -int -dpseci_clear_irq_status(struct fsl_mc_io *mc_io, +/** + * dpseci_get_tx_queue() - Retrieve Tx queue attributes. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPSECI object + * @queue: Select the queue relative to number of + * priorities configured at DPSECI creation + * @attr: Returned Tx queue attributes + * + * Return: '0' on Success; Error code otherwise. + */ +int dpseci_get_tx_queue(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, - uint8_t irq_index, - uint32_t status) -{ - struct mc_command cmd = { 0 }; - - /* prepare command */ - cmd.header = mc_encode_cmd_header(DPSECI_CMDID_CLEAR_IRQ_STATUS, - cmd_flags, - token); - DPSECI_CMD_CLEAR_IRQ_STATUS(cmd, irq_index, status); - - /* send command to mc */ - return mc_send_command(mc_io, &cmd); -} - -int -dpseci_get_attributes(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - struct dpseci_attr *attr) + uint8_t queue, + struct dpseci_tx_queue_attr *attr) { + struct dpseci_rsp_get_tx_queue *rsp_params; + struct dpseci_cmd_get_queue *cmd_params; struct mc_command cmd = { 0 }; int err; /* prepare command */ - cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_ATTR, + cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_TX_QUEUE, cmd_flags, token); + cmd_params = (struct dpseci_cmd_get_queue *)cmd.params; + cmd_params->queue = queue; - /* send command to mc */ + /* send command to mc*/ err = mc_send_command(mc_io, &cmd); if (err) return err; /* retrieve response parameters */ - DPSECI_RSP_GET_ATTR(cmd, attr); + rsp_params = (struct dpseci_rsp_get_tx_queue *)cmd.params; + attr->fqid = le32_to_cpu(rsp_params->fqid); + attr->priority = rsp_params->priority; return 0; } -int -dpseci_set_rx_queue(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - uint8_t queue, - const struct dpseci_rx_queue_cfg *cfg) -{ - struct mc_command cmd = { 0 }; - - /* prepare command */ - cmd.header = mc_encode_cmd_header(DPSECI_CMDID_SET_RX_QUEUE, - cmd_flags, - token); - DPSECI_CMD_SET_RX_QUEUE(cmd, queue, cfg); - - /* send command to mc */ - return mc_send_command(mc_io, &cmd); -} - -int -dpseci_get_rx_queue(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - uint8_t queue, - struct dpseci_rx_queue_attr *attr) +/** + * dpseci_get_sec_attr() - Retrieve SEC accelerator attributes. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPSECI object + * @attr: Returned SEC attributes + * + * Return: '0' on Success; Error code otherwise. + */ +int dpseci_get_sec_attr(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + struct dpseci_sec_attr *attr) { + struct dpseci_rsp_get_sec_attr *rsp_params; struct mc_command cmd = { 0 }; int err; /* prepare command */ - cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_RX_QUEUE, + cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_SEC_ATTR, cmd_flags, token); - DPSECI_CMD_GET_RX_QUEUE(cmd, queue); - /* send command to mc */ + /* send command to mc*/ err = mc_send_command(mc_io, &cmd); if (err) return err; /* retrieve response parameters */ - DPSECI_RSP_GET_RX_QUEUE(cmd, attr); + rsp_params = (struct dpseci_rsp_get_sec_attr *)cmd.params; + attr->ip_id = le16_to_cpu(rsp_params->ip_id); + attr->major_rev = rsp_params->major_rev; + attr->minor_rev = rsp_params->minor_rev; + attr->era = rsp_params->era; + attr->deco_num = rsp_params->deco_num; + attr->zuc_auth_acc_num = rsp_params->zuc_auth_acc_num; + attr->zuc_enc_acc_num = rsp_params->zuc_enc_acc_num; + attr->snow_f8_acc_num = rsp_params->snow_f8_acc_num; + attr->snow_f9_acc_num = rsp_params->snow_f9_acc_num; + attr->crc_acc_num = rsp_params->crc_acc_num; + attr->pk_acc_num = rsp_params->pk_acc_num; + attr->kasumi_acc_num = rsp_params->kasumi_acc_num; + attr->rng_acc_num = rsp_params->rng_acc_num; + attr->md_acc_num = rsp_params->md_acc_num; + attr->arc4_acc_num = rsp_params->arc4_acc_num; + attr->des_acc_num = rsp_params->des_acc_num; + attr->aes_acc_num = rsp_params->aes_acc_num; return 0; } -int -dpseci_get_tx_queue(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - uint8_t queue, - struct dpseci_tx_queue_attr *attr) +/** + * dpseci_get_sec_counters() - Retrieve SEC accelerator counters. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPSECI object + * @counters: Returned SEC counters + * + * Return: '0' on Success; Error code otherwise. + */ +int dpseci_get_sec_counters(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + struct dpseci_sec_counters *counters) { + struct dpseci_rsp_get_sec_counters *rsp_params; struct mc_command cmd = { 0 }; int err; /* prepare command */ - cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_TX_QUEUE, + cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_SEC_COUNTERS, cmd_flags, token); - DPSECI_CMD_GET_TX_QUEUE(cmd, queue); - /* send command to mc */ + /* send command to mc*/ err = mc_send_command(mc_io, &cmd); if (err) return err; /* retrieve response parameters */ - DPSECI_RSP_GET_TX_QUEUE(cmd, attr); + rsp_params = (struct dpseci_rsp_get_sec_counters *)cmd.params; + counters->dequeued_requests = + le64_to_cpu(rsp_params->dequeued_requests); + counters->ob_enc_requests = le64_to_cpu(rsp_params->ob_enc_requests); + counters->ib_dec_requests = le64_to_cpu(rsp_params->ib_dec_requests); + counters->ob_enc_bytes = le64_to_cpu(rsp_params->ob_enc_bytes); + counters->ob_prot_bytes = le64_to_cpu(rsp_params->ob_prot_bytes); + counters->ib_dec_bytes = le64_to_cpu(rsp_params->ib_dec_bytes); + counters->ib_valid_bytes = le64_to_cpu(rsp_params->ib_valid_bytes); return 0; } -int -dpseci_get_sec_attr(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - struct dpseci_sec_attr *attr) +/** + * dpseci_get_api_version() - Get Data Path SEC Interface API version + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @major_ver: Major version of data path sec API + * @minor_ver: Minor version of data path sec API + * + * Return: '0' on Success; Error code otherwise. + */ +int dpseci_get_api_version(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t *major_ver, + uint16_t *minor_ver) { + struct dpseci_rsp_get_api_version *rsp_params; struct mc_command cmd = { 0 }; int err; - /* prepare command */ - cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_SEC_ATTR, - cmd_flags, - token); + cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_API_VERSION, + cmd_flags, + 0); - /* send command to mc */ err = mc_send_command(mc_io, &cmd); if (err) return err; - /* retrieve response parameters */ - DPSECI_RSP_GET_SEC_ATTR(cmd, attr); + rsp_params = (struct dpseci_rsp_get_api_version *)cmd.params; + *major_ver = le16_to_cpu(rsp_params->major); + *minor_ver = le16_to_cpu(rsp_params->minor); return 0; } -int -dpseci_get_sec_counters(struct fsl_mc_io *mc_io, +int dpseci_set_congestion_notification( + struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, - struct dpseci_sec_counters *counters) + const struct dpseci_congestion_notification_cfg *cfg) { + struct dpseci_cmd_set_congestion_notification *cmd_params; struct mc_command cmd = { 0 }; - int err; /* prepare command */ - cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_SEC_COUNTERS, - cmd_flags, - token); - - /* send command to mc */ - err = mc_send_command(mc_io, &cmd); - if (err) - return err; - - /* retrieve response parameters */ - DPSECI_RSP_GET_SEC_COUNTERS(cmd, counters); - - return 0; + cmd.header = mc_encode_cmd_header( + DPSECI_CMDID_SET_CONGESTION_NOTIFICATION, + cmd_flags, + token); + + cmd_params = + (struct dpseci_cmd_set_congestion_notification *)cmd.params; + cmd_params->dest_id = cfg->dest_cfg.dest_id; + cmd_params->dest_priority = cfg->dest_cfg.priority; + cmd_params->message_ctx = cfg->message_ctx; + cmd_params->message_iova = cfg->message_iova; + cmd_params->notification_mode = cfg->notification_mode; + cmd_params->threshold_entry = cfg->threshold_entry; + cmd_params->threshold_exit = cfg->threshold_exit; + dpseci_set_field(cmd_params->type_units, + DEST_TYPE, + cfg->dest_cfg.dest_type); + dpseci_set_field(cmd_params->type_units, + CG_UNITS, + cfg->units); + + /* send command to mc*/ + return mc_send_command(mc_io, &cmd); } -int -dpseci_get_api_version(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t *major_ver, - uint16_t *minor_ver) +int dpseci_get_congestion_notification( + struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + struct dpseci_congestion_notification_cfg *cfg) { + struct dpseci_cmd_set_congestion_notification *rsp_params; struct mc_command cmd = { 0 }; int err; - cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_API_VERSION, - cmd_flags, - 0); + /* prepare command */ + cmd.header = mc_encode_cmd_header( + DPSECI_CMDID_GET_CONGESTION_NOTIFICATION, + cmd_flags, + token); + /* send command to mc*/ err = mc_send_command(mc_io, &cmd); if (err) return err; - DPSECI_RSP_GET_API_VERSION(cmd, *major_ver, *minor_ver); + rsp_params = + (struct dpseci_cmd_set_congestion_notification *)cmd.params; + + cfg->dest_cfg.dest_id = le32_to_cpu(rsp_params->dest_id); + cfg->dest_cfg.priority = rsp_params->dest_priority; + cfg->notification_mode = le16_to_cpu(rsp_params->notification_mode); + cfg->message_ctx = le64_to_cpu(rsp_params->message_ctx); + cfg->message_iova = le64_to_cpu(rsp_params->message_iova); + cfg->threshold_entry = le32_to_cpu(rsp_params->threshold_entry); + cfg->threshold_exit = le32_to_cpu(rsp_params->threshold_exit); + cfg->units = dpseci_get_field(rsp_params->type_units, CG_UNITS); + cfg->dest_cfg.dest_type = dpseci_get_field(rsp_params->type_units, + DEST_TYPE); return 0; } diff --git a/drivers/crypto/dpaa2_sec/mc/fsl_dpseci.h b/drivers/crypto/dpaa2_sec/mc/fsl_dpseci.h index 6cc14a6..4acb595 100644 --- a/drivers/crypto/dpaa2_sec/mc/fsl_dpseci.h +++ b/drivers/crypto/dpaa2_sec/mc/fsl_dpseci.h @@ -5,7 +5,7 @@ * BSD LICENSE * * Copyright 2013-2016 Freescale Semiconductor Inc. - * Copyright 2016 NXP. + * Copyright 2016-2017 NXP. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -37,7 +37,6 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ - #ifndef __FSL_DPSECI_H #define __FSL_DPSECI_H @@ -61,394 +60,89 @@ struct fsl_mc_io; */ #define DPSECI_ALL_QUEUES (uint8_t)(-1) -/** - * dpseci_open() - Open a control session for the specified object - * This function can be used to open a control session for an - * already created object; an object may have been declared in - * the DPL or by calling the dpseci_create() function. - * This function returns a unique authentication token, - * associated with the specific object ID and the specific MC - * portal; this token must be used in all subsequent commands for - * this specific object. - * - * @param mc_io Pointer to MC portal's I/O object - * @param cmd_flags Command flags; one or more of 'MC_CMD_FLAG_' - * @param dpseci_id DPSECI unique ID - * @param token Returned token; use in subsequent API calls - * - * @return: - * - Return '0' on Success. - * - Return Error code otherwise. - */ -int -dpseci_open(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - int dpseci_id, - uint16_t *token); +int dpseci_open(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + int dpseci_id, + uint16_t *token); + +int dpseci_close(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token); /** - * dpseci_close() - Close the control session of the object - * After this function is called, no further operations are - * allowed on the object without opening a new control session. - * - * @param mc_io Pointer to MC portal's I/O object - * @param cmd_flags Command flags; one or more of 'MC_CMD_FLAG_' - * @param token Token of DPSECI object - * - * @return: - * - Return '0' on Success. - * - Return Error code otherwise. + * Enable the Congestion Group support */ -int -dpseci_close(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token); +#define DPSECI_OPT_HAS_CG 0x000020 /** * struct dpseci_cfg - Structure representing DPSECI configuration + * @options: Any combination of the following options: + * DPSECI_OPT_HAS_CG + * DPSECI_OPT_HAS_OPR + * DPSECI_OPT_OPR_SHARED + * @num_tx_queues: num of queues towards the SEC + * @num_rx_queues: num of queues back from the SEC + * @priorities: Priorities for the SEC hardware processing; + * each place in the array is the priority of the tx queue + * towards the SEC, + * valid priorities are configured with values 1-8; */ struct dpseci_cfg { - uint8_t num_tx_queues; /* num of queues towards the SEC */ - uint8_t num_rx_queues; /* num of queues back from the SEC */ + uint32_t options; + uint8_t num_tx_queues; + uint8_t num_rx_queues; uint8_t priorities[DPSECI_PRIO_NUM]; - /**< Priorities for the SEC hardware processing; - * each place in the array is the priority of the tx queue - * towards the SEC, - * valid priorities are configured with values 1-8; - */ }; -/** - * dpseci_create() - Create the DPSECI object - * Create the DPSECI object, allocate required resources and - * perform required initialization. - * - * The object can be created either by declaring it in the - * DPL file, or by calling this function. - * - * The function accepts an authentication token of a parent - * container that this object should be assigned to. The token - * can be '0' so the object will be assigned to the default container. - * The newly created object can be opened with the returned - * object id and using the container's associated tokens and MC portals. - * - * @param mc_io Pointer to MC portal's I/O object - * @param dprc_token Parent container token; '0' for default container - * @param cmd_flags Command flags; one or more of 'MC_CMD_FLAG_' - * @param cfg Configuration structure - * @param obj_id returned object id - * - * @return: - * - Return '0' on Success. - * - Return Error code otherwise. - */ -int -dpseci_create(struct fsl_mc_io *mc_io, - uint16_t dprc_token, - uint32_t cmd_flags, - const struct dpseci_cfg *cfg, - uint32_t *obj_id); - -/** - * dpseci_destroy() - Destroy the DPSECI object and release all its resources. - * The function accepts the authentication token of the parent container that - * created the object (not the one that currently owns the object). The object - * is searched within parent using the provided 'object_id'. - * All tokens to the object must be closed before calling destroy. - * - * @param mc_io Pointer to MC portal's I/O object - * @param dprc_token Parent container token; '0' for default container - * @param cmd_flags Command flags; one or more of 'MC_CMD_FLAG_' - * @param object_id The object id; it must be a valid id within the - * container that created this object; - * - * @return: - * - Return '0' on Success. - * - Return Error code otherwise. - */ -int -dpseci_destroy(struct fsl_mc_io *mc_io, - uint16_t dprc_token, - uint32_t cmd_flags, - uint32_t object_id); - -/** - * dpseci_enable() - Enable the DPSECI, allow sending and receiving frames. - * @param mc_io Pointer to MC portal's I/O object - * @param cmd_flags Command flags; one or more of 'MC_CMD_FLAG_' - * @param token Token of DPSECI object - * - * @return: - * - Return '0' on Success. - * - Return Error code otherwise. - */ -int -dpseci_enable(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token); - -/** - * dpseci_disable() - Disable the DPSECI, stop sending and receiving frames. - * @param mc_io Pointer to MC portal's I/O object - * @param cmd_flags Command flags; one or more of 'MC_CMD_FLAG_' - * @param token Token of DPSECI object - * - * @return: - * - Return '0' on Success. - * - Return Error code otherwise. - */ -int -dpseci_disable(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token); - -/** - * dpseci_is_enabled() - Check if the DPSECI is enabled. - * @param mc_io Pointer to MC portal's I/O object - * @param cmd_flags Command flags; one or more of 'MC_CMD_FLAG_' - * @param token Token of DPSECI object - * @param en Returns '1' if object is enabled; '0' otherwise - * - * @return: - * - Return '0' on Success. - * - Return Error code otherwise. - */ -int -dpseci_is_enabled(struct fsl_mc_io *mc_io, +int dpseci_create(struct fsl_mc_io *mc_io, + uint16_t dprc_token, uint32_t cmd_flags, - uint16_t token, - int *en); + const struct dpseci_cfg *cfg, + uint32_t *obj_id); -/** - * dpseci_reset() - Reset the DPSECI, returns the object to initial state. - * @param mc_io Pointer to MC portal's I/O object - * @param cmd_flags Command flags; one or more of 'MC_CMD_FLAG_' - * @param token Token of DPSECI object - * - * @return: - * - Return '0' on Success. - * - Return Error code otherwise. - */ -int -dpseci_reset(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token); +int dpseci_destroy(struct fsl_mc_io *mc_io, + uint16_t dprc_token, + uint32_t cmd_flags, + uint32_t object_id); -/** - * struct dpseci_irq_cfg - IRQ configuration - */ -struct dpseci_irq_cfg { - uint64_t addr; - /* Address that must be written to signal a message-based interrupt */ - uint32_t val; - /* Value to write into irq_addr address */ - int irq_num; - /* A user defined number associated with this IRQ */ -}; +int dpseci_enable(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token); -/** - * dpseci_set_irq() - Set IRQ information for the DPSECI to trigger an interrupt - * @param mc_io Pointer to MC portal's I/O object - * @param cmd_flags Command flags; one or more of 'MC_CMD_FLAG_' - * @param token Token of DPSECI object - * @param irq_index Identifies the interrupt index to configure - * @param irq_cfg IRQ configuration - * - * @return: - * - Return '0' on Success. - * - Return Error code otherwise. - */ -int -dpseci_set_irq(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - uint8_t irq_index, - struct dpseci_irq_cfg *irq_cfg); +int dpseci_disable(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token); -/** - * dpseci_get_irq() - Get IRQ information from the DPSECI - * - * @param mc_io Pointer to MC portal's I/O object - * @param cmd_flags Command flags; one or more of 'MC_CMD_FLAG_' - * @param token Token of DPSECI object - * @param irq_index The interrupt index to configure - * @param type Interrupt type: 0 represents message interrupt - * type (both irq_addr and irq_val are valid) - * @param irq_cfg IRQ attributes - * - * @return: - * - Return '0' on Success. - * - Return Error code otherwise. - */ -int -dpseci_get_irq(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - uint8_t irq_index, - int *type, - struct dpseci_irq_cfg *irq_cfg); - -/** - * dpseci_set_irq_enable() - Set overall interrupt state. - * Allows GPP software to control when interrupts are generated. - * Each interrupt can have up to 32 causes. The enable/disable control's the - * overall interrupt state. if the interrupt is disabled no causes will cause - * an interrupt - * - * @param mc_io Pointer to MC portal's I/O object - * @param cmd_flags Command flags; one or more of 'MC_CMD_FLAG_' - * @param token Token of DPSECI object - * @param irq_index The interrupt index to configure - * @param en Interrupt state - enable = 1, disable = 0 - * - * @return: - * - Return '0' on Success. - * - Return Error code otherwise. - */ -int -dpseci_set_irq_enable(struct fsl_mc_io *mc_io, +int dpseci_is_enabled(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, - uint8_t irq_index, - uint8_t en); + int *en); -/** - * dpseci_get_irq_enable() - Get overall interrupt state - * @param mc_io Pointer to MC portal's I/O object - * @param cmd_flags Command flags; one or more of 'MC_CMD_FLAG_' - * @param token Token of DPSECI object - * @param irq_index The interrupt index to configure - * @param en Returned Interrupt state - enable = 1, - * disable = 0 - * - * @return: - * - Return '0' on Success. - * - Return Error code otherwise. - */ -int -dpseci_get_irq_enable(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - uint8_t irq_index, - uint8_t *en); - -/** - * dpseci_set_irq_mask() - Set interrupt mask. - * Every interrupt can have up to 32 causes and the interrupt model supports - * masking/unmasking each cause independently - * - * @param mc_io Pointer to MC portal's I/O object - * @param cmd_flags Command flags; one or more of 'MC_CMD_FLAG_' - * @param token Token of DPSECI object - * @param irq_index The interrupt index to configure - * @param mask event mask to trigger interrupt; - * each bit: - * 0 = ignore event - * 1 = consider event for asserting IRQ - * - * @return: - * - Return '0' on Success. - * - Return Error code otherwise. - */ -int -dpseci_set_irq_mask(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - uint8_t irq_index, - uint32_t mask); - -/** - * dpseci_get_irq_mask() - Get interrupt mask. - * Every interrupt can have up to 32 causes and the interrupt model supports - * masking/unmasking each cause independently - * - * @param mc_io Pointer to MC portal's I/O object - * @param cmd_flags Command flags; one or more of 'MC_CMD_FLAG_' - * @param token Token of DPSECI object - * @param irq_index The interrupt index to configure - * @param mask Returned event mask to trigger interrupt - * - * @return: - * - Return '0' on Success. - * - Return Error code otherwise. - */ -int -dpseci_get_irq_mask(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - uint8_t irq_index, - uint32_t *mask); - -/** - * dpseci_get_irq_status() - Get the current status of any pending interrupts - * @param mc_io Pointer to MC portal's I/O object - * @param cmd_flags Command flags; one or more of 'MC_CMD_FLAG_' - * @param token Token of DPSECI object - * @param irq_index The interrupt index to configure - * @param status Returned interrupts status - one bit per cause: - * 0 = no interrupt pending - * 1 = interrupt pending - * - * @return: - * - Return '0' on Success. - * - Return Error code otherwise. - */ -int -dpseci_get_irq_status(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - uint8_t irq_index, - uint32_t *status); - -/** - * dpseci_clear_irq_status() - Clear a pending interrupt's status - * @param mc_io Pointer to MC portal's I/O object - * @param cmd_flags Command flags; one or more of 'MC_CMD_FLAG_' - * @param token Token of DPSECI object - * @param irq_index The interrupt index to configure - * @param status bits to clear (W1C) - one bit per cause: - * 0 = don't change - * 1 = clear status bit - * - * @return: - * - Return '0' on Success. - * - Return Error code otherwise. - */ -int -dpseci_clear_irq_status(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - uint8_t irq_index, - uint32_t status); +int dpseci_reset(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token); /** * struct dpseci_attr - Structure representing DPSECI attributes - * @param id: DPSECI object ID - * @param num_tx_queues: number of queues towards the SEC - * @param num_rx_queues: number of queues back from the SEC + * @id: DPSECI object ID + * @num_tx_queues: number of queues towards the SEC + * @num_rx_queues: number of queues back from the SEC + * @options: Any combination of the following options: + * DPSECI_OPT_HAS_CG + * DPSECI_OPT_HAS_OPR + * DPSECI_OPT_OPR_SHARED */ struct dpseci_attr { - int id; /* DPSECI object ID */ - uint8_t num_tx_queues; /* number of queues towards the SEC */ - uint8_t num_rx_queues; /* number of queues back from the SEC */ + int id; + uint8_t num_tx_queues; + uint8_t num_rx_queues; + uint32_t options; }; -/** - * dpseci_get_attributes() - Retrieve DPSECI attributes. - * @param mc_io Pointer to MC portal's I/O object - * @param cmd_flags Command flags; one or more of 'MC_CMD_FLAG_' - * @param token Token of DPSECI object - * @param attr Returned object's attributes - * - * @return: - * - Return '0' on Success. - * - Return Error code otherwise. - */ -int -dpseci_get_attributes(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - struct dpseci_attr *attr); +int dpseci_get_attributes(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + struct dpseci_attr *attr); /** * enum dpseci_dest - DPSECI destination types @@ -471,16 +165,16 @@ enum dpseci_dest { /** * struct dpseci_dest_cfg - Structure representing DPSECI destination parameters + * @dest_type: Destination type + * @dest_id: Either DPIO ID or DPCON ID, depending on the destination type + * @priority: Priority selection within the DPIO or DPCON channel; valid values + * are 0-1 or 0-7, depending on the number of priorities in that + * channel; not relevant for 'DPSECI_DEST_NONE' option */ struct dpseci_dest_cfg { - enum dpseci_dest dest_type; /* Destination type */ + enum dpseci_dest dest_type; int dest_id; - /* Either DPIO ID or DPCON ID, depending on the destination type */ uint8_t priority; - /* Priority selection within the DPIO or DPCON channel; valid values - * are 0-1 or 0-7, depending on the number of priorities in that - * channel; not relevant for 'DPSECI_DEST_NONE' option - */ }; /** @@ -504,243 +198,235 @@ struct dpseci_dest_cfg { /** * struct dpseci_rx_queue_cfg - DPSECI RX queue configuration + * @options: Flags representing the suggested modifications to the queue; + * Use any combination of 'DPSECI_QUEUE_OPT_' flags + * @order_preservation_en: order preservation configuration for the rx queue + * valid only if 'DPSECI_QUEUE_OPT_ORDER_PRESERVATION' is contained in 'options' + * @user_ctx: User context value provided in the frame descriptor of each + * dequeued frame; + * valid only if 'DPSECI_QUEUE_OPT_USER_CTX' is contained in 'options' + * @dest_cfg: Queue destination parameters; + * valid only if 'DPSECI_QUEUE_OPT_DEST' is contained in 'options' */ struct dpseci_rx_queue_cfg { uint32_t options; - /* Flags representing the suggested modifications to the queue; - * Use any combination of 'DPSECI_QUEUE_OPT_' flags - */ int order_preservation_en; - /* order preservation configuration for the rx queue - * valid only if 'DPSECI_QUEUE_OPT_ORDER_PRESERVATION' is contained in - * 'options' - */ uint64_t user_ctx; - /* User context value provided in the frame descriptor of each - * dequeued frame; - * valid only if 'DPSECI_QUEUE_OPT_USER_CTX' is contained in 'options' - */ struct dpseci_dest_cfg dest_cfg; - /* Queue destination parameters; - * valid only if 'DPSECI_QUEUE_OPT_DEST' is contained in 'options' - */ }; -/** - * dpseci_set_rx_queue() - Set Rx queue configuration - * @param mc_io Pointer to MC portal's I/O object - * @param cmd_flags Command flags; one or more of 'MC_CMD_FLAG_' - * @param token Token of DPSECI object - * @param queue Select the queue relative to number of - * priorities configured at DPSECI creation; use - * DPSECI_ALL_QUEUES to configure all Rx queues - * identically. - * @param cfg Rx queue configuration - * - * @return: - * - Return '0' on Success. - * - Return Error code otherwise. - */ -int -dpseci_set_rx_queue(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - uint8_t queue, - const struct dpseci_rx_queue_cfg *cfg); +int dpseci_set_rx_queue(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + uint8_t queue, + const struct dpseci_rx_queue_cfg *cfg); /** * struct dpseci_rx_queue_attr - Structure representing attributes of Rx queues + * @user_ctx: User context value provided in the frame descriptor of each + * dequeued frame + * @order_preservation_en: Status of the order preservation configuration + * on the queue + * @dest_cfg: Queue destination configuration + * @fqid: Virtual FQID value to be used for dequeue operations */ struct dpseci_rx_queue_attr { uint64_t user_ctx; - /* User context value provided in the frame descriptor of - * each dequeued frame - */ int order_preservation_en; - /* Status of the order preservation configuration on the queue */ - struct dpseci_dest_cfg dest_cfg; - /* Queue destination configuration */ + struct dpseci_dest_cfg dest_cfg; uint32_t fqid; - /* Virtual FQID value to be used for dequeue operations */ }; -/** - * dpseci_get_rx_queue() - Retrieve Rx queue attributes. - * @param mc_io Pointer to MC portal's I/O object - * @param cmd_flags Command flags; one or more of 'MC_CMD_FLAG_' - * @param token Token of DPSECI object - * @param queue Select the queue relative to number of - * priorities configured at DPSECI creation - * @param attr Returned Rx queue attributes - * - * @return: - * - Return '0' on Success. - * - Return Error code otherwise. - */ -int -dpseci_get_rx_queue(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - uint8_t queue, - struct dpseci_rx_queue_attr *attr); +int dpseci_get_rx_queue(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + uint8_t queue, + struct dpseci_rx_queue_attr *attr); /** * struct dpseci_tx_queue_attr - Structure representing attributes of Tx queues + * @fqid: Virtual FQID to be used for sending frames to SEC hardware + * @priority: SEC hardware processing priority for the queue */ struct dpseci_tx_queue_attr { uint32_t fqid; - /* Virtual FQID to be used for sending frames to SEC hardware */ uint8_t priority; - /* SEC hardware processing priority for the queue */ }; -/** - * dpseci_get_tx_queue() - Retrieve Tx queue attributes. - * @param mc_io Pointer to MC portal's I/O object - * @param cmd_flags Command flags; one or more of 'MC_CMD_FLAG_' - * @param token Token of DPSECI object - * @param queue Select the queue relative to number of - * priorities configured at DPSECI creation - * @param attr Returned Tx queue attributes - * - * @return: - * - Return '0' on Success. - * - Return Error code otherwise. - */ -int -dpseci_get_tx_queue(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - uint8_t queue, - struct dpseci_tx_queue_attr *attr); +int dpseci_get_tx_queue(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + uint8_t queue, + struct dpseci_tx_queue_attr *attr); /** * struct dpseci_sec_attr - Structure representing attributes of the SEC - * hardware accelerator - */ + * hardware accelerator + * @ip_id: ID for SEC. + * @major_rev: Major revision number for SEC. + * @minor_rev: Minor revision number for SEC. + * @era: SEC Era. + * @deco_num: The number of copies of the DECO that are implemented + * in this version of SEC. + * @zuc_auth_acc_num: The number of copies of ZUCA that are implemented + * in this version of SEC. + * @zuc_enc_acc_num: The number of copies of ZUCE that are implemented + * in this version of SEC. + * @snow_f8_acc_num: The number of copies of the SNOW-f8 module that are + * implemented in this version of SEC. + * @snow_f9_acc_num: The number of copies of the SNOW-f9 module that are + * implemented in this version of SEC. + * @crc_acc_num: The number of copies of the CRC module that are + * implemented in this version of SEC. + * @pk_acc_num: The number of copies of the Public Key module that are + * implemented in this version of SEC. + * @kasumi_acc_num: The number of copies of the Kasumi module that are + * implemented in this version of SEC. + * @rng_acc_num: The number of copies of the Random Number Generator that + * are implemented in this version of SEC. + * @md_acc_num: The number of copies of the MDHA (Hashing module) that + * are implemented in this version of SEC. + * @arc4_acc_num: The number of copies of the ARC4 module that are + * implemented in this version of SEC. + * @des_acc_num: The number of copies of the DES module that are + * implemented in this version of SEC. + * @aes_acc_num: The number of copies of the AES module that are + * implemented in this version of SEC. + **/ struct dpseci_sec_attr { - uint16_t ip_id; /* ID for SEC */ - uint8_t major_rev; /* Major revision number for SEC */ - uint8_t minor_rev; /* Minor revision number for SEC */ - uint8_t era; /* SEC Era */ + uint16_t ip_id; + uint8_t major_rev; + uint8_t minor_rev; + uint8_t era; uint8_t deco_num; - /* The number of copies of the DECO that are implemented in - * this version of SEC - */ uint8_t zuc_auth_acc_num; - /* The number of copies of ZUCA that are implemented in this - * version of SEC - */ uint8_t zuc_enc_acc_num; - /* The number of copies of ZUCE that are implemented in this - * version of SEC - */ uint8_t snow_f8_acc_num; - /* The number of copies of the SNOW-f8 module that are - * implemented in this version of SEC - */ uint8_t snow_f9_acc_num; - /* The number of copies of the SNOW-f9 module that are - * implemented in this version of SEC - */ uint8_t crc_acc_num; - /* The number of copies of the CRC module that are implemented - * in this version of SEC - */ uint8_t pk_acc_num; - /* The number of copies of the Public Key module that are - * implemented in this version of SEC - */ uint8_t kasumi_acc_num; - /* The number of copies of the Kasumi module that are - * implemented in this version of SEC - */ uint8_t rng_acc_num; - /* The number of copies of the Random Number Generator that are - * implemented in this version of SEC - */ uint8_t md_acc_num; - /* The number of copies of the MDHA (Hashing module) that are - * implemented in this version of SEC - */ uint8_t arc4_acc_num; - /* The number of copies of the ARC4 module that are implemented - * in this version of SEC - */ uint8_t des_acc_num; - /* The number of copies of the DES module that are implemented - * in this version of SEC - */ uint8_t aes_acc_num; - /* The number of copies of the AES module that are implemented - * in this version of SEC - */ }; -/** - * dpseci_get_sec_attr() - Retrieve SEC accelerator attributes. - * @param mc_io Pointer to MC portal's I/O object - * @param cmd_flags Command flags; one or more of 'MC_CMD_FLAG_' - * @param token Token of DPSECI object - * @param attr Returned SEC attributes - * - * @return: - * - Return '0' on Success. - * - Return Error code otherwise. - */ -int -dpseci_get_sec_attr(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - struct dpseci_sec_attr *attr); +int dpseci_get_sec_attr(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + struct dpseci_sec_attr *attr); /** * struct dpseci_sec_counters - Structure representing global SEC counters and * not per dpseci counters + * @dequeued_requests: Number of Requests Dequeued + * @ob_enc_requests: Number of Outbound Encrypt Requests + * @ib_dec_requests: Number of Inbound Decrypt Requests + * @ob_enc_bytes: Number of Outbound Bytes Encrypted + * @ob_prot_bytes: Number of Outbound Bytes Protected + * @ib_dec_bytes: Number of Inbound Bytes Decrypted + * @ib_valid_bytes: Number of Inbound Bytes Validated */ struct dpseci_sec_counters { - uint64_t dequeued_requests; /* Number of Requests Dequeued */ - uint64_t ob_enc_requests; /* Number of Outbound Encrypt Requests */ - uint64_t ib_dec_requests; /* Number of Inbound Decrypt Requests */ - uint64_t ob_enc_bytes; /* Number of Outbound Bytes Encrypted */ - uint64_t ob_prot_bytes; /* Number of Outbound Bytes Protected */ - uint64_t ib_dec_bytes; /* Number of Inbound Bytes Decrypted */ - uint64_t ib_valid_bytes; /* Number of Inbound Bytes Validated */ + uint64_t dequeued_requests; + uint64_t ob_enc_requests; + uint64_t ib_dec_requests; + uint64_t ob_enc_bytes; + uint64_t ob_prot_bytes; + uint64_t ib_dec_bytes; + uint64_t ib_valid_bytes; }; +int dpseci_get_sec_counters(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + struct dpseci_sec_counters *counters); + +int dpseci_get_api_version(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t *major_ver, + uint16_t *minor_ver); /** - * dpseci_get_sec_counters() - Retrieve SEC accelerator counters. - * @param mc_io Pointer to MC portal's I/O object - * @param cmd_flags Command flags; one or more of 'MC_CMD_FLAG_' - * @param token Token of DPSECI object - * @param counters Returned SEC counters - * - * @return: - * - Return '0' on Success. - * - Return Error code otherwise. + * enum dpseci_congestion_unit - DPSECI congestion units + * @DPSECI_CONGESTION_UNIT_BYTES: bytes units + * @DPSECI_CONGESTION_UNIT_FRAMES: frames units */ -int -dpseci_get_sec_counters(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - struct dpseci_sec_counters *counters); +enum dpseci_congestion_unit { + DPSECI_CONGESTION_UNIT_BYTES = 0, + DPSECI_CONGESTION_UNIT_FRAMES +}; /** - * dpseci_get_api_version() - Get Data Path SEC Interface API version - * @param mc_io Pointer to MC portal's I/O object - * @param cmd_flags Command flags; one or more of 'MC_CMD_FLAG_' - * @param major_ver Major version of data path sec API - * @param minor_ver Minor version of data path sec API - * - * @return: - * - Return '0' on Success. - * - Return Error code otherwise. + * CSCN message is written to message_iova once entering a + * congestion state (see 'threshold_entry') + */ +#define DPSECI_CGN_MODE_WRITE_MEM_ON_ENTER 0x00000001 +/** + * CSCN message is written to message_iova once exiting a + * congestion state (see 'threshold_exit') + */ +#define DPSECI_CGN_MODE_WRITE_MEM_ON_EXIT 0x00000002 +/** + * CSCN write will attempt to allocate into a cache (coherent write); + * valid only if 'DPSECI_CGN_MODE_WRITE_MEM_' is selected */ -int -dpseci_get_api_version(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t *major_ver, - uint16_t *minor_ver); +#define DPSECI_CGN_MODE_COHERENT_WRITE 0x00000004 +/** + * if 'dpseci_dest_cfg.dest_type != DPSECI_DEST_NONE' CSCN message is sent to + * DPIO/DPCON's WQ channel once entering a congestion state + * (see 'threshold_entry') + */ +#define DPSECI_CGN_MODE_NOTIFY_DEST_ON_ENTER 0x00000008 +/** + * if 'dpseci_dest_cfg.dest_type != DPSECI_DEST_NONE' CSCN message is sent to + * DPIO/DPCON's WQ channel once exiting a congestion state + * (see 'threshold_exit') + */ +#define DPSECI_CGN_MODE_NOTIFY_DEST_ON_EXIT 0x00000010 +/** + * if 'dpseci_dest_cfg.dest_type != DPSECI_DEST_NONE' when the CSCN is written + * to the sw-portal's DQRR, the DQRI interrupt is asserted immediately + * (if enabled) + */ +#define DPSECI_CGN_MODE_INTR_COALESCING_DISABLED 0x00000020 + +/** + * struct dpseci_congestion_notification_cfg - congestion notification + * configuration + * @units: units type + * @threshold_entry: above this threshold we enter a congestion state. + * set it to '0' to disable it + * @threshold_exit: below this threshold we exit the congestion state. + * @message_ctx: The context that will be part of the CSCN message + * @message_iova: I/O virtual address (must be in DMA-able memory), + * must be 16B aligned; + * @dest_cfg: CSCN can be send to either DPIO or DPCON WQ channel + * @notification_mode: Mask of available options; use 'DPSECI_CGN_MODE_' + * values + */ +struct dpseci_congestion_notification_cfg { + enum dpseci_congestion_unit units; + uint32_t threshold_entry; + uint32_t threshold_exit; + uint64_t message_ctx; + uint64_t message_iova; + struct dpseci_dest_cfg dest_cfg; + uint16_t notification_mode; +}; + +int dpseci_set_congestion_notification( + struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + const struct dpseci_congestion_notification_cfg *cfg); + +int dpseci_get_congestion_notification( + struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + struct dpseci_congestion_notification_cfg *cfg); #endif /* __FSL_DPSECI_H */ diff --git a/drivers/crypto/dpaa2_sec/mc/fsl_dpseci_cmd.h b/drivers/crypto/dpaa2_sec/mc/fsl_dpseci_cmd.h index 3f9f474..a100a0e 100644 --- a/drivers/crypto/dpaa2_sec/mc/fsl_dpseci_cmd.h +++ b/drivers/crypto/dpaa2_sec/mc/fsl_dpseci_cmd.h @@ -5,7 +5,7 @@ * BSD LICENSE * * Copyright 2013-2016 Freescale Semiconductor Inc. - * Copyright 2016 NXP. + * Copyright 2016-2017 NXP. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -37,220 +37,187 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ - #ifndef _FSL_DPSECI_CMD_H #define _FSL_DPSECI_CMD_H /* DPSECI Version */ -#define DPSECI_VER_MAJOR 5 -#define DPSECI_VER_MINOR 0 - -/* Command IDs */ -#define DPSECI_CMDID_CLOSE ((0x800 << 4) | (0x1)) -#define DPSECI_CMDID_OPEN ((0x809 << 4) | (0x1)) -#define DPSECI_CMDID_CREATE ((0x909 << 4) | (0x1)) -#define DPSECI_CMDID_DESTROY ((0x989 << 4) | (0x1)) -#define DPSECI_CMDID_GET_API_VERSION ((0xa09 << 4) | (0x1)) - -#define DPSECI_CMDID_ENABLE ((0x002 << 4) | (0x1)) -#define DPSECI_CMDID_DISABLE ((0x003 << 4) | (0x1)) -#define DPSECI_CMDID_GET_ATTR ((0x004 << 4) | (0x1)) -#define DPSECI_CMDID_RESET ((0x005 << 4) | (0x1)) -#define DPSECI_CMDID_IS_ENABLED ((0x006 << 4) | (0x1)) - -#define DPSECI_CMDID_SET_IRQ ((0x010 << 4) | (0x1)) -#define DPSECI_CMDID_GET_IRQ ((0x011 << 4) | (0x1)) -#define DPSECI_CMDID_SET_IRQ_ENABLE ((0x012 << 4) | (0x1)) -#define DPSECI_CMDID_GET_IRQ_ENABLE ((0x013 << 4) | (0x1)) -#define DPSECI_CMDID_SET_IRQ_MASK ((0x014 << 4) | (0x1)) -#define DPSECI_CMDID_GET_IRQ_MASK ((0x015 << 4) | (0x1)) -#define DPSECI_CMDID_GET_IRQ_STATUS ((0x016 << 4) | (0x1)) -#define DPSECI_CMDID_CLEAR_IRQ_STATUS ((0x017 << 4) | (0x1)) - -#define DPSECI_CMDID_SET_RX_QUEUE ((0x194 << 4) | (0x1)) -#define DPSECI_CMDID_GET_RX_QUEUE ((0x196 << 4) | (0x1)) -#define DPSECI_CMDID_GET_TX_QUEUE ((0x197 << 4) | (0x1)) -#define DPSECI_CMDID_GET_SEC_ATTR ((0x198 << 4) | (0x1)) -#define DPSECI_CMDID_GET_SEC_COUNTERS ((0x199 << 4) | (0x1)) - -/* cmd, param, offset, width, type, arg_name */ -#define DPSECI_CMD_OPEN(cmd, dpseci_id) \ - MC_CMD_OP(cmd, 0, 0, 32, int, dpseci_id) - -/* cmd, param, offset, width, type, arg_name */ -#define DPSECI_CMD_CREATE(cmd, cfg) \ -do { \ - MC_CMD_OP(cmd, 0, 0, 8, uint8_t, cfg->priorities[0]);\ - MC_CMD_OP(cmd, 0, 8, 8, uint8_t, cfg->priorities[1]);\ - MC_CMD_OP(cmd, 0, 16, 8, uint8_t, cfg->priorities[2]);\ - MC_CMD_OP(cmd, 0, 24, 8, uint8_t, cfg->priorities[3]);\ - MC_CMD_OP(cmd, 0, 32, 8, uint8_t, cfg->priorities[4]);\ - MC_CMD_OP(cmd, 0, 40, 8, uint8_t, cfg->priorities[5]);\ - MC_CMD_OP(cmd, 0, 48, 8, uint8_t, cfg->priorities[6]);\ - MC_CMD_OP(cmd, 0, 56, 8, uint8_t, cfg->priorities[7]);\ - MC_CMD_OP(cmd, 1, 0, 8, uint8_t, cfg->num_tx_queues);\ - MC_CMD_OP(cmd, 1, 8, 8, uint8_t, cfg->num_rx_queues);\ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPSECI_RSP_IS_ENABLED(cmd, en) \ - MC_RSP_OP(cmd, 0, 0, 1, int, en) - -/* cmd, param, offset, width, type, arg_name */ -#define DPSECI_CMD_SET_IRQ(cmd, irq_index, irq_cfg) \ -do { \ - MC_CMD_OP(cmd, 0, 0, 8, uint8_t, irq_index);\ - MC_CMD_OP(cmd, 0, 32, 32, uint32_t, irq_cfg->val);\ - MC_CMD_OP(cmd, 1, 0, 64, uint64_t, irq_cfg->addr);\ - MC_CMD_OP(cmd, 2, 0, 32, int, irq_cfg->irq_num); \ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPSECI_CMD_GET_IRQ(cmd, irq_index) \ - MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index) - -/* cmd, param, offset, width, type, arg_name */ -#define DPSECI_RSP_GET_IRQ(cmd, type, irq_cfg) \ -do { \ - MC_RSP_OP(cmd, 0, 0, 32, uint32_t, irq_cfg->val); \ - MC_RSP_OP(cmd, 1, 0, 64, uint64_t, irq_cfg->addr);\ - MC_RSP_OP(cmd, 2, 0, 32, int, irq_cfg->irq_num); \ - MC_RSP_OP(cmd, 2, 32, 32, int, type); \ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPSECI_CMD_SET_IRQ_ENABLE(cmd, irq_index, enable_state) \ -do { \ - MC_CMD_OP(cmd, 0, 0, 8, uint8_t, enable_state); \ - MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index); \ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPSECI_CMD_GET_IRQ_ENABLE(cmd, irq_index) \ - MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index) - -/* cmd, param, offset, width, type, arg_name */ -#define DPSECI_RSP_GET_IRQ_ENABLE(cmd, enable_state) \ - MC_RSP_OP(cmd, 0, 0, 8, uint8_t, enable_state) +#define DPSECI_VER_MAJOR 5 +#define DPSECI_VER_MINOR 1 -/* cmd, param, offset, width, type, arg_name */ -#define DPSECI_CMD_SET_IRQ_MASK(cmd, irq_index, mask) \ -do { \ - MC_CMD_OP(cmd, 0, 0, 32, uint32_t, mask); \ - MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index); \ -} while (0) +/* Command versioning */ +#define DPSECI_CMD_BASE_VERSION 1 +#define DPSECI_CMD_BASE_VERSION_V2 2 +#define DPSECI_CMD_ID_OFFSET 4 -/* cmd, param, offset, width, type, arg_name */ -#define DPSECI_CMD_GET_IRQ_MASK(cmd, irq_index) \ - MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index) - -/* cmd, param, offset, width, type, arg_name */ -#define DPSECI_RSP_GET_IRQ_MASK(cmd, mask) \ - MC_RSP_OP(cmd, 0, 0, 32, uint32_t, mask) - -/* cmd, param, offset, width, type, arg_name */ -#define DPSECI_CMD_GET_IRQ_STATUS(cmd, irq_index, status) \ -do { \ - MC_CMD_OP(cmd, 0, 0, 32, uint32_t, status);\ - MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPSECI_RSP_GET_IRQ_STATUS(cmd, status) \ - MC_RSP_OP(cmd, 0, 0, 32, uint32_t, status) - -/* cmd, param, offset, width, type, arg_name */ -#define DPSECI_CMD_CLEAR_IRQ_STATUS(cmd, irq_index, status) \ -do { \ - MC_CMD_OP(cmd, 0, 0, 32, uint32_t, status); \ - MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index); \ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPSECI_RSP_GET_ATTR(cmd, attr) \ -do { \ - MC_RSP_OP(cmd, 0, 0, 32, int, attr->id); \ - MC_RSP_OP(cmd, 1, 0, 8, uint8_t, attr->num_tx_queues); \ - MC_RSP_OP(cmd, 1, 8, 8, uint8_t, attr->num_rx_queues); \ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPSECI_CMD_SET_RX_QUEUE(cmd, queue, cfg) \ -do { \ - MC_CMD_OP(cmd, 0, 0, 32, int, cfg->dest_cfg.dest_id); \ - MC_CMD_OP(cmd, 0, 32, 8, uint8_t, cfg->dest_cfg.priority); \ - MC_CMD_OP(cmd, 0, 40, 8, uint8_t, queue); \ - MC_CMD_OP(cmd, 0, 48, 4, enum dpseci_dest, cfg->dest_cfg.dest_type); \ - MC_CMD_OP(cmd, 1, 0, 64, uint64_t, cfg->user_ctx); \ - MC_CMD_OP(cmd, 2, 0, 32, uint32_t, cfg->options);\ - MC_CMD_OP(cmd, 2, 32, 1, int, cfg->order_preservation_en);\ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPSECI_CMD_GET_RX_QUEUE(cmd, queue) \ - MC_CMD_OP(cmd, 0, 40, 8, uint8_t, queue) - -/* cmd, param, offset, width, type, arg_name */ -#define DPSECI_RSP_GET_RX_QUEUE(cmd, attr) \ -do { \ - MC_RSP_OP(cmd, 0, 0, 32, int, attr->dest_cfg.dest_id);\ - MC_RSP_OP(cmd, 0, 32, 8, uint8_t, attr->dest_cfg.priority);\ - MC_RSP_OP(cmd, 0, 48, 4, enum dpseci_dest, attr->dest_cfg.dest_type);\ - MC_RSP_OP(cmd, 1, 0, 8, uint64_t, attr->user_ctx);\ - MC_RSP_OP(cmd, 2, 0, 32, uint32_t, attr->fqid);\ - MC_RSP_OP(cmd, 2, 32, 1, int, attr->order_preservation_en);\ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPSECI_CMD_GET_TX_QUEUE(cmd, queue) \ - MC_CMD_OP(cmd, 0, 40, 8, uint8_t, queue) - -/* cmd, param, offset, width, type, arg_name */ -#define DPSECI_RSP_GET_TX_QUEUE(cmd, attr) \ -do { \ - MC_RSP_OP(cmd, 0, 32, 32, uint32_t, attr->fqid);\ - MC_RSP_OP(cmd, 1, 0, 8, uint8_t, attr->priority);\ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPSECI_RSP_GET_SEC_ATTR(cmd, attr) \ -do { \ - MC_RSP_OP(cmd, 0, 0, 16, uint16_t, attr->ip_id);\ - MC_RSP_OP(cmd, 0, 16, 8, uint8_t, attr->major_rev);\ - MC_RSP_OP(cmd, 0, 24, 8, uint8_t, attr->minor_rev);\ - MC_RSP_OP(cmd, 0, 32, 8, uint8_t, attr->era);\ - MC_RSP_OP(cmd, 1, 0, 8, uint8_t, attr->deco_num);\ - MC_RSP_OP(cmd, 1, 8, 8, uint8_t, attr->zuc_auth_acc_num);\ - MC_RSP_OP(cmd, 1, 16, 8, uint8_t, attr->zuc_enc_acc_num);\ - MC_RSP_OP(cmd, 1, 32, 8, uint8_t, attr->snow_f8_acc_num);\ - MC_RSP_OP(cmd, 1, 40, 8, uint8_t, attr->snow_f9_acc_num);\ - MC_RSP_OP(cmd, 1, 48, 8, uint8_t, attr->crc_acc_num);\ - MC_RSP_OP(cmd, 2, 0, 8, uint8_t, attr->pk_acc_num);\ - MC_RSP_OP(cmd, 2, 8, 8, uint8_t, attr->kasumi_acc_num);\ - MC_RSP_OP(cmd, 2, 16, 8, uint8_t, attr->rng_acc_num);\ - MC_RSP_OP(cmd, 2, 32, 8, uint8_t, attr->md_acc_num);\ - MC_RSP_OP(cmd, 2, 40, 8, uint8_t, attr->arc4_acc_num);\ - MC_RSP_OP(cmd, 2, 48, 8, uint8_t, attr->des_acc_num);\ - MC_RSP_OP(cmd, 2, 56, 8, uint8_t, attr->aes_acc_num);\ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPSECI_RSP_GET_SEC_COUNTERS(cmd, counters) \ -do { \ - MC_RSP_OP(cmd, 0, 0, 64, uint64_t, counters->dequeued_requests);\ - MC_RSP_OP(cmd, 1, 0, 64, uint64_t, counters->ob_enc_requests);\ - MC_RSP_OP(cmd, 2, 0, 64, uint64_t, counters->ib_dec_requests);\ - MC_RSP_OP(cmd, 3, 0, 64, uint64_t, counters->ob_enc_bytes);\ - MC_RSP_OP(cmd, 4, 0, 64, uint64_t, counters->ob_prot_bytes);\ - MC_RSP_OP(cmd, 5, 0, 64, uint64_t, counters->ib_dec_bytes);\ - MC_RSP_OP(cmd, 6, 0, 64, uint64_t, counters->ib_valid_bytes);\ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPSECI_RSP_GET_API_VERSION(cmd, major, minor) \ -do { \ - MC_RSP_OP(cmd, 0, 0, 16, uint16_t, major);\ - MC_RSP_OP(cmd, 0, 16, 16, uint16_t, minor);\ -} while (0) +#define DPSECI_CMD_V1(id) \ + ((id << DPSECI_CMD_ID_OFFSET) | DPSECI_CMD_BASE_VERSION) +#define DPSECI_CMD_V2(id) \ + ((id << DPSECI_CMD_ID_OFFSET) | DPSECI_CMD_BASE_VERSION_V2) +/* Command IDs */ +#define DPSECI_CMDID_CLOSE DPSECI_CMD_V1(0x800) +#define DPSECI_CMDID_OPEN DPSECI_CMD_V1(0x809) +#define DPSECI_CMDID_CREATE DPSECI_CMD_V2(0x909) +#define DPSECI_CMDID_DESTROY DPSECI_CMD_V1(0x989) +#define DPSECI_CMDID_GET_API_VERSION DPSECI_CMD_V1(0xa09) + +#define DPSECI_CMDID_ENABLE DPSECI_CMD_V1(0x002) +#define DPSECI_CMDID_DISABLE DPSECI_CMD_V1(0x003) +#define DPSECI_CMDID_GET_ATTR DPSECI_CMD_V1(0x004) +#define DPSECI_CMDID_RESET DPSECI_CMD_V1(0x005) +#define DPSECI_CMDID_IS_ENABLED DPSECI_CMD_V1(0x006) + +#define DPSECI_CMDID_SET_RX_QUEUE DPSECI_CMD_V1(0x194) +#define DPSECI_CMDID_GET_RX_QUEUE DPSECI_CMD_V1(0x196) +#define DPSECI_CMDID_GET_TX_QUEUE DPSECI_CMD_V1(0x197) +#define DPSECI_CMDID_GET_SEC_ATTR DPSECI_CMD_V1(0x198) +#define DPSECI_CMDID_GET_SEC_COUNTERS DPSECI_CMD_V1(0x199) + +#define DPSECI_CMDID_SET_CONGESTION_NOTIFICATION DPSECI_CMD_V1(0x170) +#define DPSECI_CMDID_GET_CONGESTION_NOTIFICATION DPSECI_CMD_V1(0x171) + +/* Macros for accessing command fields smaller than 1byte */ +#define DPSECI_MASK(field) \ + GENMASK(DPSECI_##field##_SHIFT + DPSECI_##field##_SIZE - 1, \ + DPSECI_##field##_SHIFT) +#define dpseci_set_field(var, field, val) \ + ((var) |= (((val) << DPSECI_##field##_SHIFT) & DPSECI_MASK(field))) +#define dpseci_get_field(var, field) \ + (((var) & DPSECI_MASK(field)) >> DPSECI_##field##_SHIFT) + +#pragma pack(push, 1) +struct dpseci_cmd_open { + uint32_t dpseci_id; +}; + +struct dpseci_cmd_create { + uint8_t priorities[8]; + uint8_t num_tx_queues; + uint8_t num_rx_queues; + uint8_t pad[6]; + uint32_t options; +}; + +struct dpseci_cmd_destroy { + uint32_t dpseci_id; +}; + +#define DPSECI_ENABLE_SHIFT 0 +#define DPSECI_ENABLE_SIZE 1 + +struct dpseci_rsp_is_enabled { + /* only the first LSB */ + uint8_t en; +}; + +struct dpseci_rsp_get_attr { + uint32_t id; + uint32_t pad; + uint8_t num_tx_queues; + uint8_t num_rx_queues; + uint8_t pad1[6]; + uint32_t options; +}; + +#define DPSECI_DEST_TYPE_SHIFT 0 +#define DPSECI_DEST_TYPE_SIZE 4 + +#define DPSECI_ORDER_PRESERVATION_SHIFT 0 +#define DPSECI_ORDER_PRESERVATION_SIZE 1 + +struct dpseci_cmd_set_rx_queue { + uint32_t dest_id; + uint8_t dest_priority; + uint8_t queue; + /* from LSB: dest_type:4 */ + uint8_t dest_type; + uint8_t pad; + uint64_t user_ctx; + uint32_t options; + /* only the LSB */ + uint8_t order_preservation_en; +}; + +struct dpseci_cmd_get_queue { + uint8_t pad[5]; + uint8_t queue; +}; + +struct dpseci_rsp_get_rx_queue { + uint32_t dest_id; + uint8_t dest_priority; + uint8_t pad1; + /* from LSB: dest_type:4 */ + uint8_t dest_type; + uint8_t pad2; + uint64_t user_ctx; + uint32_t fqid; + /* only the LSB */ + uint8_t order_preservation_en; + +}; + +struct dpseci_rsp_get_tx_queue { + uint32_t pad; + uint32_t fqid; + uint8_t priority; +}; + +struct dpseci_rsp_get_sec_attr { + uint16_t ip_id; + uint8_t major_rev; + uint8_t minor_rev; + uint8_t era; + uint8_t pad1[3]; + uint8_t deco_num; + uint8_t zuc_auth_acc_num; + uint8_t zuc_enc_acc_num; + uint8_t pad2; + uint8_t snow_f8_acc_num; + uint8_t snow_f9_acc_num; + uint8_t crc_acc_num; + uint8_t pad3; + uint8_t pk_acc_num; + uint8_t kasumi_acc_num; + uint8_t rng_acc_num; + uint8_t pad4; + uint8_t md_acc_num; + uint8_t arc4_acc_num; + uint8_t des_acc_num; + uint8_t aes_acc_num; +}; + +struct dpseci_rsp_get_sec_counters { + uint64_t dequeued_requests; + uint64_t ob_enc_requests; + uint64_t ib_dec_requests; + uint64_t ob_enc_bytes; + uint64_t ob_prot_bytes; + uint64_t ib_dec_bytes; + uint64_t ib_valid_bytes; +}; + +struct dpseci_rsp_get_api_version { + uint16_t major; + uint16_t minor; +}; + +#define DPSECI_DEST_TYPE_SHIFT 0 +#define DPSECI_DEST_TYPE_SIZE 4 +#define DPSECI_CG_UNITS_SHIFT 4 +#define DPSECI_CG_UNITS_SIZE 2 + +struct dpseci_cmd_set_congestion_notification { + uint32_t dest_id; + uint16_t notification_mode; + uint8_t dest_priority; + /* from LSB: dest_type: 4 units:2 */ + uint8_t type_units; + uint64_t message_iova; + uint64_t message_ctx; + uint32_t threshold_entry; + uint32_t threshold_exit; +}; + +#pragma pack(pop) #endif /* _FSL_DPSECI_CMD_H */