From patchwork Fri Mar 24 21:57:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil Goyal X-Patchwork-Id: 22362 X-Patchwork-Delegate: pablo.de.lara.guarch@intel.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 56D79D29E; Fri, 24 Mar 2017 22:59:31 +0100 (CET) Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0048.outbound.protection.outlook.com [104.47.42.48]) by dpdk.org (Postfix) with ESMTP id 0A0B1D1BB for ; Fri, 24 Mar 2017 22:58:46 +0100 (CET) Received: from BN3PR0301CA0082.namprd03.prod.outlook.com (10.160.152.178) by BN3PR03MB2258.namprd03.prod.outlook.com (10.166.74.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.961.17; Fri, 24 Mar 2017 21:58:43 +0000 Received: from BN1AFFO11FD031.protection.gbl (2a01:111:f400:7c10::154) by BN3PR0301CA0082.outlook.office365.com (2a01:111:e400:401e::50) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.991.14 via Frontend Transport; Fri, 24 Mar 2017 21:58:43 +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 BN1AFFO11FD031.mail.protection.outlook.com (10.58.52.185) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.977.7 via Frontend Transport; Fri, 24 Mar 2017 21:58:42 +0000 Received: from netperf2.ap.freescale.net ([10.232.133.164]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id v2OLwRmg007000; Fri, 24 Mar 2017 14:58:38 -0700 From: To: CC: , , , , , , Akhil Goyal , Cristian Sovaiala Date: Sat, 25 Mar 2017 03:27:44 +0530 Message-ID: <20170324215754.21751-4-akhil.goyal@nxp.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170324215754.21751-1-akhil.goyal@nxp.com> References: <20170303194935.30831-1-akhil.goyal@nxp.com> <20170324215754.21751-1-akhil.goyal@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131348663229761842; (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)(39840400002)(39410400002)(39400400002)(39380400002)(39850400002)(39860400002)(39450400003)(2980300002)(1110001)(1109001)(339900001)(199003)(189002)(45074003)(9170700003)(2906002)(53936002)(48376002)(53946003)(2876002)(86362001)(4326008)(305945005)(5003940100001)(50986999)(110136004)(76176999)(85426001)(81166006)(106466001)(104016004)(50226002)(86152003)(6916009)(8656002)(356003)(54906002)(2351001)(1076002)(6666003)(189998001)(105606002)(8936002)(2950100002)(36756003)(50466002)(5660300001)(8676002)(77096006)(38730400002)(47776003)(33646002)(2004002)(559001)(579004); DIR:OUT; SFP:1101; SCL:1; SRVR:BN3PR03MB2258; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:ovrnspm; A:1; MX:1; PTR:InfoDomainNonexistent; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD031; 1:W0KyM6L2f1pfRWood9mkuoEKqggv3esuaVGZ/cXN35PRvZ6cCVDihSn7AXI+ZmLuFLSYfhVH4bcWhTbzfpZmzgf7Uwu6SA0v3Jv+/E2bLWC81tZ/GfB71G2lzDw8KIuQQiJcoA5GWMe5irXM4UahrNTiM7CUgyMyqqdQ9/GYfw+aQ6QemxN4DtJ+Z6MFtJz1Oz2BZeweHu7lxylKkwZ8FTvrI89vB7bZfmS2D0cPQY2TD67e2j/JQ39RLDwaWwB+x5o/cAS6Q/xufuDlnNh2dZmtBw+cfcvx110hb8BFY06AdrPty+KARQMTtQeUm70zF50wDJKiuH9aBVLWezKlVUNEtwAXvoXcBLaHNQB5omC1QMVPp9op77mL8BRPP1rd4aE1nw26XjEDMdJyP9EC9gRAwoUw0Rnr3sNE7JZlRIUmhUgP0GigL22BaEJVRgl2xh0R0IDSN0C8Gjo2KOMTDd5o8dmwWF3FKQuqRygIGBnNH5UrYtBPDfB0jgtUVioeWI8rBBhAk5o+kj6p8vPY5r95/4HOGB6ZN9XmoC5JPY1KBEWGsv22Bu9xxMIhvXE+288swQL3hlqen4YpGERigcE3sMwRfexQwKJaCpalulBK+zjdpB0fP+n6zqypvMV+3X6Da/4pR2lELWJBivSqTf/BCShYQeWnFNAA6yRa0SOUsR/0uB77U1Ya89lZhzM4jGzTWLCFuVjoE2B2m0uVHX2s3aOZqnYsoMxZ2bXmGE6OQJWQEX57kDy/GIL/1/Ez MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: fc9da98f-7745-4cb3-e7d1-08d47300effc X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:BN3PR03MB2258; X-Microsoft-Exchange-Diagnostics: 1; BN3PR03MB2258; 3:X3KZR0BrtoSVPg8Uyno+HJVMG+QCZunGeuBu2oSGsQtxSg7k0L0iO1i9/U1WXnVVfZcuA0yySIkRC/cxY6oh/sLYDql+a6zhDRhP2Ad6TA3d0l7bsuPAfKkWnEuAgvaV45rCWmY9o24Yggx5N9wx5MYfgWU1zmx8R5Jmw/sLMlVpfMF//akWNljhkq1Su22zlj4DP1KpmaWs5u9p0NgsBobsrNQRTrbSBu5iPDVhqrZvjT77o6bVt+2mvPh5s/lsMXGga3f36UM4V8jCUFc8CwSeGE20fIvu2sqAjpxTYOvm8Hik+smCbwitbTC3+hgrvJMpJ9Y/NdVUTaIOrd+cBGWzcJt64Y6jzEm87vRvVWTvLir742Gbh482cx93mNlt; 25:KtcEG3H4awgYRfvh7u5bM+4ByC2YwSOfUPVnaaFl+ykjtZS9VyKV0NQOQ89ev2XhM/n8+/+3ErsQoB5qYVwL9OWIUAKcde1Z8DlLEpInBo2tSHV1UjS/XkNEcvIRqgkqbnbrqDbsP5ZWMNzUSRggKX1EANabhcI0/tf3/BOwnMg4IH6bwqDXiZ5zeOumEtolr51dlPYmr1Ppio2q2l3k5qFr1qty1sX4WZUFhBRNOYNKPRFclTloNFZKpIYwlsrKr/g9A2SeqM6rcXGCKXa0BHhMEUhCI/rB5zILGOz5OXwbZneeG6kI4Nv21MaxGtadEUHXl8GYYMyl8OfP3uOPETuqUTqW+EMWpA2X/J6z7CIROTcPWw2ad2A4ZiYRLe56iZ+wQEQBfUuNw55NT5EjDZkHKYLP5zY8feA6IWlRQrNl/y1I7j8SQh/oquO+RDgFfhDQ1PgSv4ahZm0LvXTu2w== X-Microsoft-Exchange-Diagnostics: 1; BN3PR03MB2258; 31:BFg5P/hf4w2s1s/eiqSgiNIMD0mWQLFA3OXWbLqm5Dog9DXR17Mpfb0bHr95qVoDWyyczX+0k0QKJ+srBEu+0VYnCSWRLWxzP1ORatWs+UmQhOjifwqnR4nj9ocAq/E1F62+xQd1a8FeYUD03HZl8nqcLUbcKClRzJddCRdB9M6q+XQPshqMh3IKcji3tSkk2azl0SV/H+SYbB3TTZfGwEcZYQ+2YvyL2P/6fXnDcJEIvWtY7Y/vEtAkv9OW7BBWHOPr7my1Kp1XvkZrA0+kfQ== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(275809806118684); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095060)(601004)(2401047)(13023025)(13018025)(13015025)(8121501046)(13024025)(13017025)(5005006)(3002001)(10201501046)(6055026)(6096035)(20161123565025)(20161123561025)(20161123563025)(20161123556025)(20161123559025); SRVR:BN3PR03MB2258; BCL:0; PCL:0; RULEID:(400006); SRVR:BN3PR03MB2258; X-Microsoft-Exchange-Diagnostics: 1; BN3PR03MB2258; 4:io8df2F8USR57yZjeXOltu4AxyLqMEJRUvsYLeVq4H2pFdrb8a6suPPvrdzNlWEK9dxJBeZJTQiQKqJymkGvOqw1Zgjf+wLkFDjsxLz1WwkFd91qkE0h+K+s4Vp6Meg5gR9flGp8oVq+bgozJsp60wwSdo/rsfqDuZ36qlR/kYRwPpm/TObznYbOIbyfITBx8OIcuAjnFdy3FzdhcW9Qb6YuwS4caU4l3ofBK4O44O23EccuXwaO6UE30/AQW89X4lXckO2DcnddFxMKUVf+GVhd6oWh9oFrqIBZ/gdhhigCJR04FLZ3wUybPcY89z5W+YUK2fS8rfYABnu6bo8PZANospYrFlxbsyXW/Kc4hz/Bsq2rEiH9aJu0jNf+bLKTUkw985NU5psAtydAmPZrzp9jLRpOA85uYDUq+rJ8+XhJ0dTCqRwQaWzmlYNHGkbL3Cl8JVNEgxX6uXxfMXbWvPXmmRqXjA6XO5Il2ytXhIlc1/WEmEAxM/7LGNhttcitkiDh+gPSHVW5EiCOoKtxgnGnuM/6aFgHxKQVD8/Z7eLQY7Ri6NiZo2BTu9uZp5EEGDwUn0QSzSLXmXIbDUZOLjjkcPGeErQNxV+yQ8RJ5JfZjZi8HNkN/W/aHwVO+dC535p6s63Yd8PevtL9+AAfZSxEgzuZbMZdkPlAn86fOfY2jyGmCOKL+QzPc7Wu3B7+zMAuK5oEo1vMMk+hFrPfY+icSaCcBc44Mc9huivlq4A7PIe7Y5cO5rAk9/w5Bj4jBU957ggdFbv6IVmTznLG1w== X-Forefront-PRVS: 0256C18696 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN3PR03MB2258; 23:B5Lt1NWI5r/EPNULjR1bytm2byet6RwBq/jXxivqY?= 84M/c8urkr8q5qVUpV9VYFSOksEM+vT7bLyf4ueT3uCpuEbom1SpRsXqWI0eaoOZrUXnQQrqb1Tc0vRYoB/fyfgJ/muWPFaQ4SBfp7KHKBxkxt6P6qDt8rC37FCzWTT4mASBBjDJ4vXkvotsEyxD6MJA+E7ACCU+z60bjVJ04venb6zTuns3NITVEnwMka9ZfZmyuKAcuaIs1wYN9bo9OT+H65Dkw7BhWuRZ+K03lQghIG97h0ZSHpjBf0+w2xKlpb3eYzrG+E3VEwsaGocqQm8hdqoxLSE/tXmplEzbtgtgt6tD9l5/lPWVSZcy62H+1MPdJwdNbNSdv1QHiKLTYcDXvAKGb/64Lwct8yAMw3Db2gW0wc3WnPxIuT2E3DsTAJwO1p5iEi4zyTPUourhaJMhYzICJ4PlBF1jrK1vAYMDblynFb7VkgzYER/v140Dqh1DZJwqvOwndhuLsdHXLaAooBcZ37sT8RVURnBHzzxbIxqFZaUv+qC0v4zwpB5D/rQYtyCNKo5xZeXfZL5Ad27rPVhiMPKb6uGTNkJY7UI56pq5G7JRDxjGxgAEPJJTtuQQqAtu3gqrfptJx4SKlxa7Ya6EXGLEwCqfz9o7d/fQQRvgWPD0nT+qpl+XO0j2tpLcbtw0FWQvmqhmxzp/z8y/8+/IxwPToC5LgHqdp0zaeENkqq9W/+DmdzbDC0qBOdVHNWrWsMsFuuZs1//ELPFPpUFB7jZs1eS+xn4AI8D0lktPRRnDJXiMVW7rQjg3MyfdwJZE56lu2zZM7C+lmyJU5dzw69hBS+24TrxX0hMEVdGnuQ/s5JZ3ylE7YG0PhkUu3poJG6rg665+/bvwdF0lSs/WVa/hfweeTeSMa7KXGiZy1Dfb13LAiAP1tA/k+P2lRYmqlyl0HYtRt6mfIM2sc5lPcXJlnBP6elC9lh0DzGsKVvq02fc6+j/PjFP2jVJG/O4zMC1/mv8uPfL72jLCfSSC/VpZRF5nwRfN2XL7Bl65ipJLvOli0YulHrAzeP6RoY5LyvbEQ1I4JFhT9OH9ob02FTT8P2ojqLnu2tMkxV1oosqyaO0Fhr2InrD4ITrOIeIL0h0MgjT4tI/0ueV6jsJQLe1tHMOrf3PJWtVU5j7a7Iz5Vr2EW1CSfhQOcSa08/tagKzQC0jafNM6m8EEOuVOUJQ/zVxKgmwZ2caDJzWVjXhZ0gBvc2c6xmO+K8e8sZFeS6xCC0OF0wWHlALzKCtFus5e0WvB1pO+iPbAoKlEz58qOkLkJOWBpqQQNP4wBx+rwtoKczDE1lxKo6FFaqU5QUAUzKv6dLljmn1RCFIooN4g2j8pbWuYWrPi8s= X-Microsoft-Exchange-Diagnostics: 1; BN3PR03MB2258; 6:8t47kNSv5Rml+ZX5gh5a9UT/rlzBMWTE7R//mlmEuFQCoabttbWSsTVzHAbnhqC8et6M3J4tsZxYa//M5j5fq0C6Y0KeAO/Y1Za6e4RpD3gpBx3tm43Y2ZpQhaIrchRapdcR+xdyTUU8Q66goCtcKuziS/vlZXHaVH/VqibMyS4aaD52a3Z+7P4lm2yyWrYjBLXlhlGjARDvAFsTIxDCEsLHHnTFjDB2/ISSSFpV/6YFvrsBXockIccBjxgPhoa5TnycrWYS6fVLgFTvPhD8Vc10TC2whMkFEhsTiFfTOQnZ0LE6we+iaSWKaEPb5FXdJAxq7ssxJ4r3TuaygDNBIqWd9S3mdErp9T7jApIbOv893pzJsupDqifLLsvu+RPu2i/3L93PFyYFl4D23WUnlOHglJgEbw1ZrztskL2VGto=; 5:dA19G2NizzP64lVAj+zpwp+cBbzGpfemoYMalZe9qrbD5DXaqqEBg7mhS7SffDFS7MvN6iz8C9/nIa8pcIOq5C5URfyV7qLK0Z4tCVmzR5yxdxNx0bwvM2KNMKx+IqgACYw9JDvwWzVE4tyZjLGoXgKPuZBwA4WoTgxNj6yzVeIDZH6mtv2sBSFrkf4Gpkpm; 24:cKM3H/AOjugw2JH4gqrKjwZvd849n1fJwRAetc7a0Y0e/3mrfMS8yKEpnI7D1dTrw+8VitON+anuy07Nfd3U4huMaO4N/4PSCs3SwkNobXk= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN3PR03MB2258; 7:WWZUR+sFjzoWIIa8z3dICuS9OzDSMNJG0MdPmy1BqG2+X9M8y0vwMXqlegUMFODMMv4FmipPAaE2ejQVOBIxDVrdsw5wrcUAI5Xb2Ru+0k+UMCn1vKGJ+KC230ns0509LndTjm6o1u24L+DLAq5qlRFukN450uASydz5kx8ChB8HXUmc11e17XVWZMYyHxLW21IVbCOI2ccpeJDrqmrD1aMyqYe5FeEikYO20P/4j98i57Ou+y4BTCz8mGDDVvm5zlzD7cVJTw1JLnMryerBpp2V0Q+zAtXaY4cJZCm3SuLmpcv7gNlwNeFkyKcXrS0FFy1MEwF51GF41CiWK8xmqg== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Mar 2017 21:58:42.7889 (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: BN3PR03MB2258 Subject: [dpdk-dev] [PATCH v6 03/13] crypto/dpaa2_sec: add mc dpseci object support 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: Akhil Goyal add support for dpseci object in MC driver. DPSECI represent a crypto object in DPAA2. Signed-off-by: Cristian Sovaiala Signed-off-by: Akhil Goyal --- drivers/crypto/dpaa2_sec/Makefile | 2 + drivers/crypto/dpaa2_sec/mc/dpseci.c | 551 ++++++++++++++++++++ drivers/crypto/dpaa2_sec/mc/fsl_dpseci.h | 738 +++++++++++++++++++++++++++ drivers/crypto/dpaa2_sec/mc/fsl_dpseci_cmd.h | 249 +++++++++ 4 files changed, 1540 insertions(+) create mode 100644 drivers/crypto/dpaa2_sec/mc/dpseci.c create mode 100644 drivers/crypto/dpaa2_sec/mc/fsl_dpseci.h create mode 100644 drivers/crypto/dpaa2_sec/mc/fsl_dpseci_cmd.h diff --git a/drivers/crypto/dpaa2_sec/Makefile b/drivers/crypto/dpaa2_sec/Makefile index 7429401..6b6ce47 100644 --- a/drivers/crypto/dpaa2_sec/Makefile +++ b/drivers/crypto/dpaa2_sec/Makefile @@ -47,6 +47,7 @@ endif CFLAGS += -D _GNU_SOURCE CFLAGS += -I$(RTE_SDK)/drivers/crypto/dpaa2_sec/ +CFLAGS += -I$(RTE_SDK)/drivers/crypto/dpaa2_sec/mc CFLAGS += -I$(RTE_SDK)/drivers/bus/fslmc/ CFLAGS += -I$(RTE_SDK)/drivers/bus/fslmc/qbman/include CFLAGS += -I$(RTE_SDK)/drivers/bus/fslmc/mc @@ -66,6 +67,7 @@ CFLAGS += -Iinclude # library source files SRCS-$(CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC) += dpaa2_sec_dpseci.c +SRCS-$(CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC) += mc/dpseci.c # library dependencies DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC) += lib/librte_eal diff --git a/drivers/crypto/dpaa2_sec/mc/dpseci.c b/drivers/crypto/dpaa2_sec/mc/dpseci.c new file mode 100644 index 0000000..a3eaa26 --- /dev/null +++ b/drivers/crypto/dpaa2_sec/mc/dpseci.c @@ -0,0 +1,551 @@ +/* Copyright 2013-2016 Freescale Semiconductor Inc. + * Copyright (c) 2016 NXP. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the above-listed copyright holders nor the + * names of any contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * + * ALTERNATIVELY, this software may be distributed under the terms of the + * GNU General Public License ("GPL") as published by the Free Software + * Foundation, either version 2 of that License or (at your option) any + * later version. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * 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) +{ + struct mc_command cmd = { 0 }; + int err; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPSECI_CMDID_OPEN, + cmd_flags, + 0); + DPSECI_CMD_OPEN(cmd, dpseci_id); + + /* 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); + + return 0; +} + +int +dpseci_close(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_CLOSE, + cmd_flags, + token); + + /* 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) +{ + struct mc_command cmd = { 0 }; + int err; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPSECI_CMDID_CREATE, + cmd_flags, + dprc_token); + DPSECI_CMD_CREATE(cmd, cfg); + + /* 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); + + return 0; +} + +int +dpseci_destroy(struct fsl_mc_io *mc_io, + uint16_t dprc_token, + uint32_t cmd_flags, + uint32_t object_id) +{ + 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 }; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPSECI_CMDID_ENABLE, + cmd_flags, + token); + + /* 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, + 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) +{ + struct mc_command cmd = { 0 }; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPSECI_CMDID_RESET, + cmd_flags, + token); + + /* 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) +{ + struct mc_command cmd = { 0 }; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPSECI_CMDID_SET_IRQ, + cmd_flags, + token); + DPSECI_CMD_SET_IRQ(cmd, irq_index, irq_cfg); + + /* send command to mc */ + return mc_send_command(mc_io, &cmd); +} + +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) +{ + struct mc_command cmd = { 0 }; + int err; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_IRQ_ENABLE, + cmd_flags, + token); + DPSECI_CMD_GET_IRQ_ENABLE(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_ENABLE(cmd, *en); + + 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) +{ + struct mc_command cmd = { 0 }; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPSECI_CMDID_SET_IRQ_ENABLE, + cmd_flags, + token); + DPSECI_CMD_SET_IRQ_ENABLE(cmd, irq_index, en); + + /* 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) +{ + struct mc_command cmd = { 0 }; + int err; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_IRQ_MASK, + cmd_flags, + token); + DPSECI_CMD_GET_IRQ_MASK(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_MASK(cmd, *mask); + + 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) +{ + struct mc_command cmd = { 0 }; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPSECI_CMDID_SET_IRQ_MASK, + cmd_flags, + token); + DPSECI_CMD_SET_IRQ_MASK(cmd, irq_index, mask); + + /* 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) +{ + struct mc_command cmd = { 0 }; + int err; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_IRQ_STATUS, + cmd_flags, + token); + DPSECI_CMD_GET_IRQ_STATUS(cmd, irq_index, *status); + + /* 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); + + return 0; +} + +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) +{ + 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) +{ + struct mc_command cmd = { 0 }; + int err; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_ATTR, + cmd_flags, + token); + + /* send command to mc */ + err = mc_send_command(mc_io, &cmd); + if (err) + return err; + + /* retrieve response parameters */ + DPSECI_RSP_GET_ATTR(cmd, attr); + + 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) +{ + struct mc_command cmd = { 0 }; + int err; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_RX_QUEUE, + cmd_flags, + token); + DPSECI_CMD_GET_RX_QUEUE(cmd, queue); + + /* 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); + + 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) +{ + struct mc_command cmd = { 0 }; + int err; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_TX_QUEUE, + cmd_flags, + token); + DPSECI_CMD_GET_TX_QUEUE(cmd, queue); + + /* 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); + + 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) +{ + struct mc_command cmd = { 0 }; + int err; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_SEC_ATTR, + 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_ATTR(cmd, attr); + + return 0; +} + +int +dpseci_get_sec_counters(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + struct dpseci_sec_counters *counters) +{ + 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; +} + +int +dpseci_get_api_version(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t *major_ver, + uint16_t *minor_ver) +{ + struct mc_command cmd = { 0 }; + int err; + + cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_API_VERSION, + cmd_flags, + 0); + + err = mc_send_command(mc_io, &cmd); + if (err) + return err; + + DPSECI_RSP_GET_API_VERSION(cmd, *major_ver, *minor_ver); + + return 0; +} diff --git a/drivers/crypto/dpaa2_sec/mc/fsl_dpseci.h b/drivers/crypto/dpaa2_sec/mc/fsl_dpseci.h new file mode 100644 index 0000000..fd09bdb --- /dev/null +++ b/drivers/crypto/dpaa2_sec/mc/fsl_dpseci.h @@ -0,0 +1,738 @@ +/* Copyright 2013-2016 Freescale Semiconductor Inc. + * Copyright (c) 2016 NXP. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the above-listed copyright holders nor the + * names of any contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * + * ALTERNATIVELY, this software may be distributed under the terms of the + * GNU General Public License ("GPL") as published by the Free Software + * Foundation, either version 2 of that License or (at your option) any + * later version. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * 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 + +/* Data Path SEC Interface API + * Contains initialization APIs and runtime control APIs for DPSECI + */ + +struct fsl_mc_io; + +/** + * General DPSECI macros + */ + +/** + * Maximum number of Tx/Rx priorities per DPSECI object + */ +#define DPSECI_PRIO_NUM 8 + +/** + * All queues considered; see dpseci_set_rx_queue() + */ +#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); + +/** + * 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. + */ +int +dpseci_close(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token); + +/** + * struct dpseci_cfg - Structure representing DPSECI configuration + */ +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 */ + 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, + uint32_t cmd_flags, + uint16_t token, + int *en); + +/** + * 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); + +/** + * 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 */ +}; + +/** + * 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); + +/** + * 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, + uint32_t cmd_flags, + uint16_t token, + uint8_t irq_index, + uint8_t 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); + +/** + * 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 + */ +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 */ +}; + +/** + * 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); + +/** + * enum dpseci_dest - DPSECI destination types + * @DPSECI_DEST_NONE: Unassigned destination; The queue is set in parked mode + * and does not generate FQDAN notifications; user is expected to + * dequeue from the queue based on polling or other user-defined + * method + * @DPSECI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN + * notifications to the specified DPIO; user is expected to dequeue + * from the queue only after notification is received + * @DPSECI_DEST_DPCON: The queue is set in schedule mode and does not generate + * FQDAN notifications, but is connected to the specified DPCON + * object; user is expected to dequeue from the DPCON channel + */ +enum dpseci_dest { + DPSECI_DEST_NONE = 0, + DPSECI_DEST_DPIO = 1, + DPSECI_DEST_DPCON = 2 +}; + +/** + * struct dpseci_dest_cfg - Structure representing DPSECI destination parameters + */ +struct dpseci_dest_cfg { + enum dpseci_dest dest_type; /* Destination 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 + */ +}; + +/** + * DPSECI queue modification options + */ + +/** + * Select to modify the user's context associated with the queue + */ +#define DPSECI_QUEUE_OPT_USER_CTX 0x00000001 + +/** + * Select to modify the queue's destination + */ +#define DPSECI_QUEUE_OPT_DEST 0x00000002 + +/** + * Select to modify the queue's order preservation + */ +#define DPSECI_QUEUE_OPT_ORDER_PRESERVATION 0x00000004 + +/** + * struct dpseci_rx_queue_cfg - DPSECI RX queue configuration + */ +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); + +/** + * struct dpseci_rx_queue_attr - Structure representing attributes of Rx queues + */ +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 */ + 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); + +/** + * struct dpseci_tx_queue_attr - Structure representing attributes of Tx queues + */ +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); + +/** + * struct dpseci_sec_attr - Structure representing attributes of the SEC + * hardware accelerator + */ + +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 */ + 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); + +/** + * struct dpseci_sec_counters - Structure representing global SEC counters and + * not per dpseci counters + */ +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 */ +}; + +/** + * 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. + */ +int +dpseci_get_sec_counters(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + struct dpseci_sec_counters *counters); + +/** + * 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. + */ +int +dpseci_get_api_version(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t *major_ver, + uint16_t *minor_ver); + +#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 new file mode 100644 index 0000000..8ee9a5a --- /dev/null +++ b/drivers/crypto/dpaa2_sec/mc/fsl_dpseci_cmd.h @@ -0,0 +1,249 @@ +/* Copyright 2013-2016 Freescale Semiconductor Inc. + * Copyright (c) 2016 NXP. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the above-listed copyright holders nor the + * names of any contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * + * ALTERNATIVELY, this software may be distributed under the terms of the + * GNU General Public License ("GPL") as published by the Free Software + * Foundation, either version 2 of that License or (at your option) any + * later version. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * 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) + +/* 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) + +/* 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) + +#endif /* _FSL_DPSECI_CMD_H */