From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0055.outbound.protection.outlook.com [104.47.40.55]) by dpdk.org (Postfix) with ESMTP id 9B8D856A1 for ; Thu, 20 Apr 2017 07:44:52 +0200 (CEST) Received: from DM2PR03CA0004.namprd03.prod.outlook.com (10.141.96.14) by DM2PR0301MB0607.namprd03.prod.outlook.com (10.160.95.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1034.10; Thu, 20 Apr 2017 05:44:50 +0000 Received: from BY2FFO11FD019.protection.gbl (2a01:111:f400:7c0c::115) by DM2PR03CA0004.outlook.office365.com (2a01:111:e400:2428::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1047.13 via Frontend Transport; Thu, 20 Apr 2017 05:44:50 +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 BY2FFO11FD019.mail.protection.outlook.com (10.1.14.107) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1019.14 via Frontend Transport; Thu, 20 Apr 2017 05:44:50 +0000 Received: from bf-netperf1.ap.freescale.net (bf-netperf1.ap.freescale.net [10.232.134.28]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id v3K5iava015982; Wed, 19 Apr 2017 22:44:47 -0700 From: To: CC: , , , Date: Thu, 20 Apr 2017 11:14:18 +0530 Message-ID: <1492667067-21968-5-git-send-email-akhil.goyal@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1492667067-21968-1-git-send-email-akhil.goyal@nxp.com> References: <1492616268-6307-1-git-send-email-akhil.goyal@nxp.com> <1492667067-21968-1-git-send-email-akhil.goyal@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131371406901224187; (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)(39450400003)(39410400002)(39850400002)(39380400002)(39400400002)(39860400002)(39840400002)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(9170700003)(48376002)(4326008)(86362001)(356003)(33646002)(106466001)(77096006)(105606002)(2351001)(5890100001)(2906002)(2876002)(110136004)(38730400002)(5003940100001)(69596002)(50226002)(50466002)(81166006)(47776003)(8936002)(36756003)(305945005)(104016004)(189998001)(6916009)(6666003)(5660300001)(2950100002)(54906002)(53936002)(8676002)(8656002)(76176999)(85426001)(50986999)(86152003); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR0301MB0607; H:az84smr01.freescale.net; FPR:; SPF:Fail; MLV:ovrnspm; A:1; MX:1; PTR:InfoDomainNonexistent; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD019; 1:AuTLdl5dkFEOBcSIsZgL1/oYwN2UyZ4jpPE4NeC/9ROItu7z6OQ2WX6QOUuf8p6qXLO/8DRyhOEh8oXC0d5jBTREDZBj0JfozkNTNEE2d0nLaMt27UYMXiTdaMa60qRjrl5sg8IF38J0EDaCcjMHjINgngkuMmRGLoHvVfEczr+pqOZ/EDCLGclHAQavcYbFdUs9HEBCSwfvZCgsN57xjIBN+xOk8kgbdoQp8KoSs46AJaI2CFRzzIjZ3sK3oiD9wI5ow5VHt/YDUXgqGhZXolsYMkU63F9VFjvE0/KZlRiwBq0R7gd+XzJSUPgo+holCWQLS9kMaYXi5pjjIVZ5seWEjAomSSpz7LuCh+PUjAp73/fAxtZQJGXlJLZGnmu6nTCk1KmphRpu4u3yNugRqExwB9OO9zIcZK/NMwJxhhfS9fUsRzF+cUhQWSg4XShdDwzBYdbdqoxcv9XN+QoBCho75SrXqLIULUqrR7/PvbqXJZjWpGzwo9fa0+0DepUhaaCoL73jnDULfwDBhWCRXAO4Z0S8q78VwFN1WhBw7k8bqReG4ISvUyqt+Zl1r67Kq1XH/djH++St23IOK/2GGVYTYMlw4NRfkV685+rjLBHy7I2FYe4/Jk3pcvI27de9tB+2HnB14aNgu1RMUOetEewOlAdklUmvZZJUfEnOVDG8I76rP3WzbMcilHA94+pgbwFtLnPMuDGguL3ig1bhQXlIgmnHcgGX6wvIIXfN5cL6x/aIu/8W/KsB5ZGMfO9svkcBpUTInj2lS4YCo+9kFg== MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0a42becc-82a8-4b6e-a2fb-08d487b05c74 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131430075)(201703131517081); SRVR:DM2PR0301MB0607; X-Microsoft-Exchange-Diagnostics: 1; DM2PR0301MB0607; 3:mAknOC51dkad9J8xIlI4UDr8oVZ+rxXkEhg4CyKritYu2nq+PPZYuOo7UDhisDAQRKKImr10gEhude0zG1HWv8onWHTvHuLp/IrvcNLFjPSNasvMfUvA26/Cbjmjh2nnQ8AeCokYDFgvJTtQW0ezs+0nQX6eLa5bmFawWzeiDV+ZDRK7lOG2DmSdyEroPX6rZkEcfWhJG93eKBAQRtALrjhTbrd6zFJyiFR9kulFCFKdcs/X/p6DsDmKnCMHjZ8hlrIoGjiWjKDIu3cNI0G5K/jqbYGOIrs97559LnEYw65xYOxfyxE/YRfu9/8ybbirTgICzUtzZIsq2HhkcPOJ54HqqT6qQ6V5zmfLn0XHj6mJ84ZbZA71kvVo7OiwaOP8/0O+Q+VW021zYn9ITecSKgDL4j81Um/+pY93uj9TolN6R7ZEVIZU1Am7No1SarHj; 25:N+EILVNJeCLdarIsZOC3cv+gmD7vmZHkMFAWW3KB7gjo+7LIAo5GtzPRqURjUU6U4+bkME4ThAAx/uaoTnqM5sGV6SjxM3eBHqo2Jx3k6YoN6laf8ZFMp4NdWBZjPJyXolGxlJSBuNKPTB2oUt+FpSVElu+bLGM2oxiCxd2YBSShbmzbGnAd86qmF1DFqT/xg2Dqzw9PAtybo0KkvIVkVmCGF6wgNY5OB++NOIz1xuP00O/bcGsXsa9gnC7oUZCVP2VfJfuYREvHKUdEDfJdmbmYWkrpqw06/82baxCsXXyBTJKdbmgzj7juoWGLdvyYy/SmCkQ93KBzHg6jRNGYiyz1vbc5IfsQgU7AGB7XypvZdU6kzEe9rvevZRvbOdOw5HNtE3XyGOznK/eHrVGhNHZ81cHGZ7cv1pcQb/SqNEteEisrL3JcifoG9G4SDbeNGfqiV6Wdxi6tHN9Og3rTyw== X-Microsoft-Exchange-Diagnostics: 1; DM2PR0301MB0607; 31:IT4mYM8pHNttO5M3yblEa5/7wDV7iyHioIvXEMgl7B2bF6vxC1j6wKbwOe7L4D3LmT4QYV3Fx+uWVNn7zW8bfxlAEb9vwoxVmfCm4Odb5P0lckKt+cmmt2uVKgv1nP1Nef8AH8WwJszxlESnBxvlxHHlI9siWOn2ufoMriCbK0nvNyxqh7hoAt8myIdydYRdm9bt9EU8SdeHtHPVdrlOqlGiAPPZE81N6zR5GHwR0X6QscjV9tnNjTx89tPZLMjpQRhKGClCI3oTBFppQfIgDqkKlOyVxQJH/3DSiNbYWHw= 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)(13024025)(13023025)(13018025)(13017025)(13015025)(8121501046)(5005006)(93006095)(93001095)(10201501046)(3002001)(6055026)(6096035)(201703131430075)(201703131433075)(201703131448075)(201703161259150)(20161123565025)(20161123556025)(20161123563025)(20161123561025); SRVR:DM2PR0301MB0607; BCL:0; PC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G8OF4fFppPGYsc7umLPnomHmfgxGszr+fSw==; 5:I2qSVgPNCgiLfwv+IRC1Qn01e0/mF8r08qJIepfMwtktSyugQi2y7zuBa6hbAsIYxCconMbqjsXQshwuYOP1KJaJaDmhCjyP+22BoJ5GECX9PGs+efuthgzEMsQAVsK8LdZO7RMcKHqTh87xVb98QKwoBzn6B5QNN/fbKWWAOvPc9UJEUeq8YLQ8kWVSCbfB; 24:n3OULxxSXLTAM1JRwW6bv4rLzjnae9c9l9H+FJt6uJuVwxxPsf9KF5tH1kk9NJmnxxcc60PX1kv31xc5PtkNKIWJfeEJPMw6eO50AvEO3qI= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR0301MB0607; 7:SQVHiqm2OmCBTeiNg0sTeJBczx4XAnTh4CVo3KbfBTLXVeOgEdTFAhfvw6ZNo/GGcZog59yTfZRPzm7AQdDLuHQjSr1VN2KI7rvoCYTmFpyLdwuBSLwxJDt4f/3JcpY0fW/YBqo2NLVGgxfO8uRZr5rHdfDTHfYyPnVeo5fLQ46hXclNlIo5ZztMDz/Kn1+RI6hGdIn0DZ0uyuw2u18wukg8/DNDHAICQYx/jwTDkygqowYM7tyjDX38/3KpH6jMng2SAj7LHahsSHdOYATAhzcCchVwm3G83mEz9rKpuTk6HGpXW5koGq8pYW5Jntqslm/xMqpDj7/EhI+i6Vkqqw== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Apr 2017 05:44:50.0132 (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: DM2PR0301MB0607 Subject: [dpdk-dev] [PATCH v9 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: Thu, 20 Apr 2017 05:44:54 -0000 From: Akhil Goyal Signed-off-by: Hemant Agrawal Signed-off-by: Akhil Goyal --- drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 181 ++++++++++++++++++++++++++++ 1 file changed, 181 insertions(+) diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c index 2e3785c..5d9fbc7 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" @@ -58,6 +60,144 @@ #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(const struct rte_cryptodev_driver *crypto_drv __rte_unused, struct rte_cryptodev *dev) { @@ -73,6 +213,10 @@ 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); @@ -80,8 +224,10 @@ 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 | @@ -99,9 +245,44 @@ 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 -- 1.9.1