From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-CY1-obe.outbound.protection.outlook.com (mail-cys01nam02on0066.outbound.protection.outlook.com [104.47.37.66]) by dpdk.org (Postfix) with ESMTP id 85A1B6787 for ; Fri, 3 Mar 2017 15:24:04 +0100 (CET) Received: from BN6PR03CA0027.namprd03.prod.outlook.com (10.175.124.13) by MWHPR03MB2958.namprd03.prod.outlook.com (10.175.136.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.947.12; Fri, 3 Mar 2017 14:24:02 +0000 Received: from BY2FFO11FD030.protection.gbl (2a01:111:f400:7c0c::116) by BN6PR03CA0027.outlook.office365.com (2603:10b6:404:10c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.947.12 via Frontend Transport; Fri, 3 Mar 2017 14:24:02 +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 BY2FFO11FD030.mail.protection.outlook.com (10.1.14.211) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.947.7 via Frontend Transport; Fri, 3 Mar 2017 14:24:02 +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 v23ENi6X000351; Fri, 3 Mar 2017 07:23:58 -0700 From: Akhil Goyal To: CC: , , , , , , Akhil Goyal Date: Sat, 4 Mar 2017 01:19:27 +0530 Message-ID: <20170303194935.30831-5-akhil.goyal@nxp.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170303194935.30831-1-akhil.goyal@nxp.com> References: <20170303193648.30665-1-akhil.goyal@nxp.com> <20170303194935.30831-1-akhil.goyal@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131330246425083673; (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)(7916002)(39380400002)(39400400002)(39850400002)(39410400002)(39840400002)(39860400002)(39450400003)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(9170700003)(305945005)(36756003)(356003)(8656002)(5003940100001)(2906002)(104016004)(5660300001)(2950100002)(6666003)(6916009)(77096006)(1076002)(110136004)(2351001)(38730400002)(189998001)(53936002)(33646002)(54906002)(5890100001)(105606002)(4326008)(81166006)(86362001)(50466002)(48376002)(626004)(47776003)(85426001)(92566002)(50226002)(8676002)(76176999)(8936002)(50986999)(106466001); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR03MB2958; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:ovrnspm; A:1; MX:1; PTR:InfoDomainNonexistent; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD030; 1:nBKxJCTp5wDR4Hy7fI5nX54mBRdWA++Czf6tVLR9RjtMKqMVnDsirLYk1jkLbCrUfYFHp2z+gYzRi5r+o5QSapx7w2Ceii1MF+PNTssNGST6AX4PAx7cCMY0PoiTz4+qztKU/wSKuupQNN9mEq0QdiKQPGqYqUt5exV78RTib74drXNyUzIA7F54iVisrFOxQPJj6/MeMvPQTvUQbgueieQ1vtdIunOPzjkFJFo3rXnPXpnLf7fapkO+AFoY0vCwgSc/VXizfg+kXWI5N8BVEKSiWd5FEoqiVujoJY7bWg0PmzrZPVJIQ20J/U2MPP3UFV/YRdNFM954ITTUvB+U7kbQmaA0X06SwX0E7Roc4l7rjZgw1QCwQG74YU0muHFpT5Almx6fKhxeE60PnrDKdbMWjidrWlaRzUszArGc73dVJrtVRQ7XbbxABNfn5l0Eqq+LEhkAndgTL55Urn90DGdkficeylEJpAhOO77rwC/pgNZW6knSAiNUh7PWDpSBVOG4SG+garH6w/WlmRJ7oDtRBgezXfrgb8nrpqjArgw/5IhwmzE5lN/vJldCxnZWUEoAcCEFu5KaUiyVPadx0MVLRrAgEpsggw4jJ9ivKWqMAp3Fbj67QYc4LMpjmYCEWyVWbq+2BfZtbEiTudWRfFXUeXkw+Q4B0O1L5BegdKgAAB/geyyVlaZHXZbwq5kSjltVt094YKhiYqhKFuA7WJm5XzCLkNkByXRXFHaS2hemai5OfYJG7T1rzzuLGabi MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 2a446319-4f8f-43dd-12a7-08d46240f0d0 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:MWHPR03MB2958; X-Microsoft-Exchange-Diagnostics: 1; MWHPR03MB2958; 3:pMFQLHII7jNjnbv5YX7uMyR5IwhRZReWEgXJ+J+qx6I/NTyZlGJNcE17p9plrm87X6B4LIWPdjhhKHA9v4GyXphpH61OCpF3ApXFX1o7P23PDPwsIJeoordaG4r7ceuuKW2RvG+jPiPGHnYdQCIQUR+gVKpQvsAFDloHbuRVQljjan11kbSdkjdRjB6JBad41/evmwnCM8KzurLVR1s9yzWLBLpNtcOiFlH5L84bYxG8B7XwKfYyZPgmZ1SGuv1zv5QU/Z3mP6gSNhyAiQgsUFxk0II30lTduDwUZHv31iYFv3L7ulOXzobMJUOToZGRmqEPzaePT5SAE/4w0zwRjHtB61FGGvPBBFoIswXveu0RcnLiAlaqHFKWceHs4Dsk; 25:oXlP92++KJNOkVSBzsh0b1kxAzjmwLgvzGCPdCJ1UseFtL6ECeaqmHxSPPlUYBjvK/yv13qCF46BAG3bH9DWM6ZT7jUhTtlM6AxI5d1Bc3AM1vRK6a4XyyT479BsqDBdB2EZi6TTKRpjXt+cWd4aK9znwJyPjuG8xfFpnDACQtS0wcBFPvufhMpyLxyR7/3ffa8zkGZK0XGKtBPMCDhxgh3jKtJaHpSwHwjk8QU0kI2HBnxhY1xqO/jWAXZp2ftFdwnI3zWNWGJQQAfq8cVqaj7uKzLou1lWOuSAERaBSuc83Fys38bSwd0QY8lF+gX2yt/aaalvZ1xF8Y/IIRwlHM4HPlhWDX1EnTb4SJ+Sf34Gqk000Y2FvCoKnJCszV+6ImkX/0r5GwJJRBRa4tIt1G0TH2EpTKMmVerSPSQxX4BkODC0N01gwdOBzwcebXLUXAshWrZxDizAKlP67DRF/Q== X-Microsoft-Exchange-Diagnostics: 1; MWHPR03MB2958; 31:IuSfIKyJANUcrufwPYgS90F0CQsThdqLQje5jAZr41whELRQsShnNhOGvjHYLUquJrkJynDn83B2oZg6CvcqfrURqdavASNw6WgMhVQEhb1H5mlaOfDp02kQpVwchr3SkCmp7vwdYsk3B8vnKNuAHhH/JegL1C/s1O1Zf7yB6eO2wFpAZbqmzr5XHWqSU2U8x7IVy7zFtiMVQCN4or2uxUQrkrJWxVpcfmw1rbClC5kI25nPBg41MfOmxVwhG1gwQt/3f9aZpVHuCtoeDZ8mXQ== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095060)(601004)(2401047)(5005006)(8121501046)(13015025)(13023025)(13017025)(13024025)(13018025)(3002001)(10201501046)(6055026)(6096035)(20161123563025)(20161123559025)(20161123556025)(20161123561025)(20161123565025); SRVR:MWHPR03MB2958; BCL:0; PCL:0; RULEID:(400006); SRVR:MWHPR03MB2958; X-Microsoft-Exchange-Diagnostics: 1; MWHPR03MB2958; 4:87ZrDzU0kKQx5c8fRRp6A1Hfv+uxUcw3hrKoIRKaKXBZfYEIHtbBFY7Xzua/rB3oDiLbomeYw39IrAiZi8dCAosT4CTOpiBhkgLFYlnxVrJBfSDEh8rHm44iV2Fg2WIZW07uo63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UbJJ43BwipBXenCEfEG/zCr5KDQNgu83U7ImFM9jHzXMmh4alRvcQaaom48?= =?us-ascii?Q?HwkKTXTaRL6bQkuOzjs8pAkTEEI7pLCtlW1mJgH0p8ZnSe9NmPbVLs9Pn9E5?= =?us-ascii?Q?mIQ5jkshdchvUj7q8ZVoQ4=3D?= X-Microsoft-Exchange-Diagnostics: 1; MWHPR03MB2958; 6:76ScV4daz1BZNsCEc4uYWKMg5cnrDlSl4sWI8xNgAEfCIB4NUVJLnuRvIS3/bT/lZlTDZBPGCvTl+Z70MaCCmngubvaiAzrKafOpKdr8fwe79au/+yFNgPpoABV+X2Nv66RimdCHoRxJ2vSUbKXS9EVjEKVLV1k9Ykj6wykl5gO7P7KgLcJqM97eCc7Zcsaq/uQWti2pTNofII+Zi3U9SVj8Te/k66Yi9OW3H3XLCI+ZoMvJdYlV/zMW8w28t5EA3+V1HRLuE6dVd3AGV8QxqjIiBEarz2P4my7jIhSrG77O+YNhBnMR8/hPQsbOcYr85A96b6q8K2tfkb6s1IjRGtSjMbuTcVHFR/1TfHpAdXpY/CceaiVuHWiefFl6oUfnILcUrKZ4pusCtQV5BtiQLTZJOIxvxiGy70UdELPsbxA=; 5:4AkyWB3NM8fHFpJV2WOlMIcnLe75g/Mi21gDwAE4eLxv+fTYz+UzwLTJOPw+Zmo65ZFNAL0q0UoubIFHqUZ9aV8iMS4ewmZaH7Pd1N259iQwCorb8pXH07vKTn5ej7YGc1jfxua0AoaR9UFYg+gG1Wal6iieNO16XBqvyvEYD+fV2lw/GBbXq9K50TJZntCY; 24:WlGJ9O4js1Liitq+IcKaA/eqti457WGqeSXcX3W89juR0poP/X8z2bdkE82uZ6MybJVJOrrjYEb8sIej7VWyGyWl93M144AEABdIXtiXOn0= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; MWHPR03MB2958; 7:m4qGB+hgE72BhRZm4Mig4F9eLn428XSjRugFJImeLL6prK5DCithGeaTWinx1/PpQ4jmCRnWNmZsffeQeW11vHlk7DdObcb743dwIQf3SXfNyalKlfk2Y3hu/VCsiUbU5gXBpwiQvRBjyASRGzZ960ZQCff8Ovi4d+C8KzsEAzD5xKtOG9RRqYmfW+XXgmD3xPOZAz9STryUqVUM4bIGxh8doN3qhMG1mGM8pIl4H5cGB/Oix5EBthm/9NSn3fAuGs00ManBD13BVXMh+/nQAlzQbr2mpAN1+0awqtPdQA/gFZJWYb+ITdpzqJYMDj8JKRwXUUIZqZ4MsqvHLS8T+Q== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2017 14:24:02.1807 (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: MWHPR03MB2958 Subject: [dpdk-dev] [PATCH v5 04/12] 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: Fri, 03 Mar 2017 14:24:05 -0000 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 34ca776..7287c53 100644 --- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c +++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c @@ -47,6 +47,8 @@ #include #include #include +#include +#include #include "dpaa2_sec_priv.h" #include "dpaa2_sec_logs.h" @@ -56,6 +58,144 @@ #define FSL_SUBSYSTEM_SEC 1 #define FSL_MC_DPSECI_DEVID 3 + +static int +dpaa2_sec_dev_configure(struct rte_cryptodev *dev __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, @@ -76,6 +216,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); @@ -83,8 +227,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 | @@ -102,9 +248,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