From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-dm3nam03on0075.outbound.protection.outlook.com [104.47.41.75]) by dpdk.org (Postfix) with ESMTP id 9CE81689E for ; Mon, 10 Apr 2017 14:31:37 +0200 (CEST) Received: from BN3PR0301CA0064.namprd03.prod.outlook.com (10.160.152.160) by BY2PR03MB394.namprd03.prod.outlook.com (10.141.141.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1019.17; Mon, 10 Apr 2017 12:31:33 +0000 Received: from BN1BFFO11FD003.protection.gbl (2a01:111:f400:7c10::1:163) by BN3PR0301CA0064.outlook.office365.com (2a01:111:e400:401e::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1019.17 via Frontend Transport; Mon, 10 Apr 2017 12:31:33 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) 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.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Received: from az84smr01.freescale.net (192.88.158.2) by BN1BFFO11FD003.mail.protection.outlook.com (10.58.144.66) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1019.14 via Frontend Transport; Mon, 10 Apr 2017 12:31:32 +0000 Received: from netperf2.ap.freescale.net ([10.232.133.164]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id v3ACVCIP014402; Mon, 10 Apr 2017 05:31:29 -0700 From: To: CC: , , , , , , Akhil Goyal Date: Mon, 10 Apr 2017 18:00:59 +0530 Message-ID: <20170410123108.26305-5-akhil.goyal@nxp.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170410123108.26305-1-akhil.goyal@nxp.com> References: <20170324215754.21751-1-akhil.goyal@nxp.com> <20170410123108.26305-1-akhil.goyal@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131363010932476735; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.158.2; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(336005)(39400400002)(39850400002)(39380400002)(39410400002)(39860400002)(39840400002)(39450400003)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(9170700003)(53936002)(33646002)(86152003)(54906002)(8656002)(189998001)(77096006)(5003940100001)(81166006)(81156014)(38730400002)(8676002)(76176999)(50986999)(4326008)(110136004)(47776003)(69596002)(5890100001)(106466001)(2351001)(105606002)(5660300001)(50466002)(36756003)(48376002)(6666003)(356003)(86362001)(85426001)(2876002)(2950100002)(50226002)(305945005)(104016004)(6916009)(8936002)(2906002)(1076002); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR03MB394; H:az84smr01.freescale.net; FPR:; SPF:Fail; MLV:ovrnspm; A:1; MX:1; PTR:InfoDomainNonexistent; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD003; 1:CEW7zfo4hh0i7BhAcs8VnJQn4Xuns8EuFqyeqlI+PkVccx04IHIC4hrhVga5yeyYNVnZHvba4gguCXkl3oYJBtVPv13eGQ/TsJ69yVyp9flMwfkf2grwjxhw7ylLzLQ0QmYvptfkKKScJID1mjE7hwgVDsgh1gnTe1aX1OKrczaMSVas//7Ma7MCHw9zHv7lGvICQGZw0QfcfaWXHvVgnkEWRSQud5xu9UD1b28qEUeyuojNj3i0V7rzo8evBl3T1eC3AV5Cg/h4YaahbgLfbbG6wCwj3ioRRGt2CQ9FyuRI9j4m0E2xmU3UbhAPEOV994E50UwC2QFoGvMSK+C+Fl/p2qXplj70rgR0aCMl7ipsom1WD9kiNYI7/IS5DE5uw3J1PpnfOGRLbap9suKK1vov1XwxCpnMHJhGPXH5pl0Iw5ni0/mwOiIcwWnZB+a2bI4/MMuKmFMtgLQvzOG5smBOm/3UYQuvHS+kAImGXDnQnkhkJKG7hp22A3hPBF4hrKyaog5HD3WIv3eMje+lx0lyuC1Bmp9zt+PJYWbOfmHoXg2EeNo9vBYus5T7srPJbMbPawlwrY6+G4ey+Gg2ZjWttpR0CMBp8GWRUv5xpsp95kREs9yZUVwRdDQNkpDtCfUGqR+yLRtu0Pa64VJ+VlS87phK+2J2dLZ7yeD33TNNcfLmTgKcJACxsaKk7KD8hVe7/dSdDNes8alQRLUnWAcd9+YU6tpQzXrJrX0h5Y3MP6mzG7JTAX+C1hFpcvS0yWR1A1ljyTsCu0+kb07Tig== MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 04493e8f-a0a6-4fb4-803f-08d4800d85a5 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131430075)(201703131517081); SRVR:BY2PR03MB394; X-Microsoft-Exchange-Diagnostics: 1; BY2PR03MB394; 3:Blfl/eyu2h4OapRzT4JONsrLPbz/9sMn8I+NoyBWMN2U+KJyZmBcCJH9CtdAgQeypkJWrflVa3LA9oycc1Xybpo+SspqTlCXKEGNsTq85FYFKEwzpdqnmC0iiGF0RvbiI01vyEQs5Y9YlTNspZL6Z7x4ZWfUD8EwCB7nuXfYYlgghKtfqjYr7HN5ZFw5XucL52OJnVY+IHfYcAcaRhWOZI5XWJZ/gn+RXmeGQ0ZnYVBDyeDE72ks+mBwCv4QKb5d94vAIEQaLtCs5fEDT1OQnfsjfTtRueqWP9SDTXP4o11Lv65InStOMvFPq4qdAtKbkHf3q0ayvpRKniPV4iBloT0YyxPs+Mv3N7wBSyulB/VjuIy4YnpVLFv8SWSx/4MhWuAkxgCZbTAsqxM40x2iceERNSR7bwE+Xufv4Mmgd/oRT5FJFvjV/xM04IY4uMeR; 25:T5ARmb7erhe5ohm+51AQw+v5phoHsq2JwY2XQ7yEWZ5I0jWD1lg9ZHfY11n0zPAHrUw8XQjR0EaFvZUtAgjN81PPF0sDYQ2WC/u5ngl8kE9U8CxdH1ZBt34efeh2r7vEprc0iEhFhON3BBerF1koAJGhSyyHmiP3sPdb4gerIinPLt2p3oj0xibjISsMpMzWCMbU7R9OTtP9HEIr26yb0lt2ZfS7dLxt+pS31cB9UMadl/R7Q5ZdJCHdF7wPSLaVawT4wY59eqBU0Jcq0+0xn/fsXYLuIhCDa8KvItCM5P08Zbxyi2fPyvxYMfOz63mCWCxyhupVsLlRkUuCNuMkufyFM9zDLsP0u7hkxg2kF0sT63qN+f0EPqhWfWS9REoGx+SHutIrcLGQJb08R/AzEMtzYeKb6GOHDX6FbB0lVeeKuKYEIHWM4QDbm5RTbyL8dgri2aw+Dkn0FHNNREWwog== X-Microsoft-Exchange-Diagnostics: 1; BY2PR03MB394; 31:aGgTDtJa+OEbzweE+s5Thnfyg/FHCdVvIy6lJqlmtOg7RMtlrOynSbLxfzUkEaWQwRC8c7f43HHCUb0ULrZkvB5Df+YadmijKTwJN0uJlRe7t8zwn6PqNxRqJoJnjntjMOK1t2OibuRBqMc4OmJjg7zuftiDgtllY6c9dcjDbm6ZLQLmhp+OpMocx2ZkX5X9DTL0vz2cY7x12aokvPuzU6t4vJzNAKxjuHSgQjYzXKryb22klUk3QFkIqcjyxJDWpvtrLkMga6UAtfORXGeuS0zmuf4708LkwT6fgJyuExs= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095135)(601004)(2401047)(13015025)(8121501046)(5005006)(13018025)(13017025)(13024025)(13023025)(93006095)(93001095)(10201501046)(3002001)(6055026)(6096035)(20161123563025)(20161123565025)(20161123561025)(201703131430075)(201703131448075)(201703131433075)(201703161259075)(20161123556025); SRVR:BY2PR03MB394; BCL:0; PCL:0; RULEID:(400006); SRVR:BY2PR03MB394; X-Microsoft-Exchange-Diagnostics: 1; BY2PR03MB394; 4:uKHRa99Bnkbx2WaSl3BvtKP8VTBCZx5A0xa11GZPbykm6AUUIx26QxEW7sqbimM15auLgiR8U+Q6KghyW3a66jx5JWM+4/JcequnwztxgCnUGOQ0XsxYaYNSzeUEC5k5Ho2uxImNyNWAGQQhrb9aJh+yTL6g6P+EnrIU4TaDcLLUDkOsB26Ak2tA0dRrMPLiI5l+0UGBYRUmyo8ZJ2MCyb3dhpM4NG9446FXCdO4jo+eRDkZSS3W8qml3WyjK7hcnVjopcRd9SVnuhizACOfT7LZN/vNrWdAKDuI5YCVLRPn0bw1buLa+ycUS0Sq1Sy6p8ZvPu+UEaXxbzEUtCxMMRmtHN1ejlhusRSi37qLzaekO8AdIgcPNQzdpNbArR6dELp0TRLazawGtFP6/ctD0RPoUS12VVgb98pujsMhdytqC/+qVdc/ss/T5a3AOrGQRn79zrIlOz2JjR8jtajl91orniKRFPgaLDKFtZifq/jUftURVrmFKl/U4grKSLwFp571M5bqx0UTFzW/dJh7OcweBofCABIix/WjTvRhfY+0YFy0DN3C2FjxC4RsGEU59cVEFlVYmdGAFMVDIja9Qei7P4wyDt0I5TmhW9Yl8QjpOFKnGoRj6T7ZF/dfDbdHCmkx5Ff/EG16FlNaaam8UzhvvzOTcXo8BjE42ytuznvR1nK4TQizuRdIRP2iTcfSkSv5WEWq9PbzXAgB87S9uayM+ePydnzwCxoDE0D9wlUppEanpXrA8A0kaeL75JFai6gN4/j54zEy1wbKxHuRxBLrG5cHh8WcPIELI09k4HczadLQlszU1EeDJeudlqaG+pYH53PKrEBYjsHbGQe0X1cIO4xJOaCPxwwz+J/lHG9EBlYuceoJAGVFKCHXguyPWGFIEL/Chdnx7n8t1I3Afg== X-Forefront-PRVS: 027367F73D X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR03MB394; 23:B1yRmilCVaCEwFRgLFoHoQ4XfeH7VjW5svIXOy6KOV?= =?us-ascii?Q?TAwtYSLvi24X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VKz4Qisb6juRnvyb2dpauzn0mWYy4/v987gFwZnFmkO4cHZLU0+IGz4ywyLz6PkYFZlMrqBWOM/zNGZmw7F9moIeMkcJ5l+WIcRZEWQFKB0JWCKAKR5sWEI34uv4LSt9d66eAAEos0Aper8B2q8dJLFK; 24:w5UdqIla8AYQTBW6+5fOd/U5M/KeyTOTjESTSiu4pIEYHY4i1HN3XDc1zq0omHr9rHRFbxU18CK5ZHBxrEfDDWdBBiyQGTXDYXpIKUuWNts= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BY2PR03MB394; 7:oVz8WdspEppaguF8UPEhTkjDR0v34XPWecBU28zWuxHyaXbdkYXZdcnybfTMVjtvyK1ew7j1d2mjA2J9YjQxl1+EHnklZQg7S7ogIAxxYgzUNLCUdO7XVYicd/hDMsyIQ0agAjKrRCYYbFG/s2G7EywXYTHLXQBKeKMprpNp8+m0nlcEmhOMtFcMPWmbVmMzup0P3GExmCYIw4aES1IRDm6KS75BZ5RP5qYOrpgtxR3BkjIT9J618AASHf2cBvTjGooYzCts+jQDzbTcmdJVV43fPXjH79Q2mOYvVcKx3Vd5tiwcwGF7z/3ZLaJxHRDnQEaNtvGHZtmfolgfe3EHfA== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Apr 2017 12:31:32.8888 (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.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR03MB394 Subject: [dpdk-dev] [PATCH v7 04/13] crypto/dpaa2_sec: add basic crypto operations 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: , X-List-Received-Date: Mon, 10 Apr 2017 12:31:38 -0000 From: Akhil Goyal Signed-off-by: Hemant Agrawal Signed-off-by: Akhil Goyal --- drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 182 ++++++++++++++++++++++++++++ 1 file changed, 182 insertions(+) diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c index 378df4a..bb56af1 100644 --- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c +++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c @@ -48,6 +48,8 @@ #include #include #include +#include +#include #include "dpaa2_sec_priv.h" #include "dpaa2_sec_logs.h" @@ -57,6 +59,145 @@ #define FSL_SUBSYSTEM_SEC 1 #define FSL_MC_DPSECI_DEVID 3 + +static int +dpaa2_sec_dev_configure(struct rte_cryptodev *dev __rte_unused, + struct rte_cryptodev_config *config __rte_unused) +{ + PMD_INIT_FUNC_TRACE(); + + return -ENOTSUP; +} + +static int +dpaa2_sec_dev_start(struct rte_cryptodev *dev) +{ + struct dpaa2_sec_dev_private *priv = dev->data->dev_private; + struct fsl_mc_io *dpseci = (struct fsl_mc_io *)priv->hw; + struct dpseci_attr attr; + struct dpaa2_queue *dpaa2_q; + struct dpaa2_sec_qp **qp = (struct dpaa2_sec_qp **) + dev->data->queue_pairs; + struct dpseci_rx_queue_attr rx_attr; + struct dpseci_tx_queue_attr tx_attr; + int ret, i; + + PMD_INIT_FUNC_TRACE(); + + memset(&attr, 0, sizeof(struct dpseci_attr)); + + ret = dpseci_enable(dpseci, CMD_PRI_LOW, priv->token); + if (ret) { + PMD_INIT_LOG(ERR, "DPSECI with HW_ID = %d ENABLE FAILED\n", + priv->hw_id); + goto get_attr_failure; + } + ret = dpseci_get_attributes(dpseci, CMD_PRI_LOW, priv->token, &attr); + if (ret) { + PMD_INIT_LOG(ERR, + "DPSEC ATTRIBUTE READ FAILED, disabling DPSEC\n"); + goto get_attr_failure; + } + for (i = 0; i < attr.num_rx_queues && qp[i]; i++) { + dpaa2_q = &qp[i]->rx_vq; + dpseci_get_rx_queue(dpseci, CMD_PRI_LOW, priv->token, i, + &rx_attr); + dpaa2_q->fqid = rx_attr.fqid; + PMD_INIT_LOG(DEBUG, "rx_fqid: %d", dpaa2_q->fqid); + } + for (i = 0; i < attr.num_tx_queues && qp[i]; i++) { + dpaa2_q = &qp[i]->tx_vq; + dpseci_get_tx_queue(dpseci, CMD_PRI_LOW, priv->token, i, + &tx_attr); + dpaa2_q->fqid = tx_attr.fqid; + PMD_INIT_LOG(DEBUG, "tx_fqid: %d", dpaa2_q->fqid); + } + + return 0; +get_attr_failure: + dpseci_disable(dpseci, CMD_PRI_LOW, priv->token); + return -1; +} + +static void +dpaa2_sec_dev_stop(struct rte_cryptodev *dev) +{ + struct dpaa2_sec_dev_private *priv = dev->data->dev_private; + struct fsl_mc_io *dpseci = (struct fsl_mc_io *)priv->hw; + int ret; + + PMD_INIT_FUNC_TRACE(); + + ret = dpseci_disable(dpseci, CMD_PRI_LOW, priv->token); + if (ret) { + PMD_INIT_LOG(ERR, "Failure in disabling dpseci %d device", + priv->hw_id); + return; + } + + ret = dpseci_reset(dpseci, CMD_PRI_LOW, priv->token); + if (ret < 0) { + PMD_INIT_LOG(ERR, "SEC Device cannot be reset:Error = %0x\n", + ret); + return; + } +} + +static int +dpaa2_sec_dev_close(struct rte_cryptodev *dev) +{ + struct dpaa2_sec_dev_private *priv = dev->data->dev_private; + struct fsl_mc_io *dpseci = (struct fsl_mc_io *)priv->hw; + int ret; + + PMD_INIT_FUNC_TRACE(); + + /* Function is reverse of dpaa2_sec_dev_init. + * It does the following: + * 1. Detach a DPSECI from attached resources i.e. buffer pools, dpbp_id + * 2. Close the DPSECI device + * 3. Free the allocated resources. + */ + + /*Close the device at underlying layer*/ + ret = dpseci_close(dpseci, CMD_PRI_LOW, priv->token); + if (ret) { + PMD_INIT_LOG(ERR, "Failure closing dpseci device with" + " error code %d\n", ret); + return -1; + } + + /*Free the allocated memory for ethernet private data and dpseci*/ + priv->hw = NULL; + free(dpseci); + + return 0; +} + +static void +dpaa2_sec_dev_infos_get(struct rte_cryptodev *dev, + struct rte_cryptodev_info *info) +{ + struct dpaa2_sec_dev_private *internals = dev->data->dev_private; + + PMD_INIT_FUNC_TRACE(); + if (info != NULL) { + info->max_nb_queue_pairs = internals->max_nb_queue_pairs; + info->feature_flags = dev->feature_flags; + info->capabilities = dpaa2_sec_capabilities; + info->sym.max_nb_sessions = internals->max_nb_sessions; + info->dev_type = RTE_CRYPTODEV_DPAA2_SEC_PMD; + } +} + +static struct rte_cryptodev_ops crypto_ops = { + .dev_configure = dpaa2_sec_dev_configure, + .dev_start = dpaa2_sec_dev_start, + .dev_stop = dpaa2_sec_dev_stop, + .dev_close = dpaa2_sec_dev_close, + .dev_infos_get = dpaa2_sec_dev_infos_get, +}; + static int dpaa2_sec_uninit(__attribute__((unused)) const struct rte_cryptodev_driver *crypto_drv, @@ -77,6 +218,10 @@ dpaa2_sec_dev_init(struct rte_cryptodev *cryptodev) struct dpaa2_sec_dev_private *internals; struct rte_device *dev = cryptodev->device; struct rte_dpaa2_device *dpaa2_dev; + struct fsl_mc_io *dpseci; + uint16_t token; + struct dpseci_attr attr; + int retcode, hw_id; PMD_INIT_FUNC_TRACE(); dpaa2_dev = container_of(dev, struct rte_dpaa2_device, device); @@ -84,8 +229,10 @@ dpaa2_sec_dev_init(struct rte_cryptodev *cryptodev) PMD_INIT_LOG(ERR, "dpaa2_device not found\n"); return -1; } + hw_id = dpaa2_dev->object_id; cryptodev->dev_type = RTE_CRYPTODEV_DPAA2_SEC_PMD; + cryptodev->dev_ops = &crypto_ops; cryptodev->feature_flags = RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO | RTE_CRYPTODEV_FF_HW_ACCELERATED | @@ -103,9 +250,44 @@ dpaa2_sec_dev_init(struct rte_cryptodev *cryptodev) PMD_INIT_LOG(DEBUG, "Device already init by primary process"); return 0; } + /*Open the rte device via MC and save the handle for further use*/ + dpseci = (struct fsl_mc_io *)rte_calloc(NULL, 1, + sizeof(struct fsl_mc_io), 0); + if (!dpseci) { + PMD_INIT_LOG(ERR, + "Error in allocating the memory for dpsec object"); + return -1; + } + dpseci->regs = rte_mcp_ptr_list[0]; + + retcode = dpseci_open(dpseci, CMD_PRI_LOW, hw_id, &token); + if (retcode != 0) { + PMD_INIT_LOG(ERR, "Cannot open the dpsec device: Error = %x", + retcode); + goto init_error; + } + retcode = dpseci_get_attributes(dpseci, CMD_PRI_LOW, token, &attr); + if (retcode != 0) { + PMD_INIT_LOG(ERR, + "Cannot get dpsec device attributed: Error = %x", + retcode); + goto init_error; + } + sprintf(cryptodev->data->name, "dpsec-%u", hw_id); + + internals->max_nb_queue_pairs = attr.num_tx_queues; + cryptodev->data->nb_queue_pairs = internals->max_nb_queue_pairs; + internals->hw = dpseci; + internals->token = token; PMD_INIT_LOG(DEBUG, "driver %s: created\n", cryptodev->data->name); return 0; + +init_error: + PMD_INIT_LOG(ERR, "driver %s: create failed\n", cryptodev->data->name); + + /* dpaa2_sec_uninit(crypto_dev_name); */ + return -EFAULT; } static int -- 2.9.3