From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0084.outbound.protection.outlook.com [104.47.34.84]) by dpdk.org (Postfix) with ESMTP id 4898F2B9D for ; Fri, 3 Mar 2017 15:11:31 +0100 (CET) Received: from DM5PR03CA0045.namprd03.prod.outlook.com (10.174.189.162) by DM5PR03MB2955.namprd03.prod.outlook.com (10.175.106.141) 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:11:27 +0000 Received: from BN1AFFO11FD035.protection.gbl (2a01:111:f400:7c10::190) by DM5PR03CA0045.outlook.office365.com (2603:10b6:4:3b::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.947.3 via Frontend Transport; Fri, 3 Mar 2017 14:11:27 +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 BN1AFFO11FD035.mail.protection.outlook.com (10.58.52.159) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.933.11 via Frontend Transport; Fri, 3 Mar 2017 14:11:26 +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 v23EB3lX010625; Fri, 3 Mar 2017 07:11:23 -0700 From: Akhil Goyal To: CC: , , , , , Akhil Goyal , Hemant Agrawal Date: Sat, 4 Mar 2017 01:06:36 +0530 Message-ID: <20170303193648.30665-7-akhil.goyal@nxp.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170303193648.30665-1-akhil.goyal@nxp.com> References: <20170120140509.4495-1-akhil.goyal@nxp.com> <20170303193648.30665-1-akhil.goyal@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131330238869270163; (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)(7916002)(336005)(39410400002)(39450400003)(39380400002)(39850400002)(39860400002)(39400400002)(39840400002)(2980300002)(1110001)(1109001)(339900001)(189002)(199003)(9170700003)(305945005)(38730400002)(110136004)(86362001)(106466001)(105606002)(104016004)(53936002)(50986999)(50226002)(356003)(50466002)(1076002)(48376002)(189998001)(2906002)(5003940100001)(33646002)(2351001)(8936002)(8676002)(81166006)(92566002)(36756003)(85426001)(6916009)(6666003)(5890100001)(76176999)(47776003)(2950100002)(5660300001)(626004)(54906002)(77096006)(4326008)(8656002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR03MB2955; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:ovrnspm; MX:1; A:1; PTR:InfoDomainNonexistent; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD035; 1:tuiJg6eS/mtHayGbW0L1UpCHE1bJMTeUECTAXWDND2fErO0VOa5pk7RXDmxkDNIyoneYJl+Rh4PZ1GxIjQ/tQa5pCdhVRVkfC7gudEVKiPN9syHPVnSb8S1NT/zkponwxvGVqFDd6y7DBi7m15VIWjZNZXj0/PCnynsG20sczLX3wLtNv7BbMtzMAHWTcdjPJwEgWkiyYLyOaLS1xPy05OuQCjspuvpkZ5piW8Iwsy/s1Tvqtb4r3DLstFoacA1VIkpeXqIIBVlza2/rdOSIyd5yj77fEc0bojzd7g2fNwlNsvmnLl4fRFa2cdZDM3M6bvdKYDTWtVkMRNP6DHQC/XFH5mK1fLk8pOrITHctNmG1M6Z9R+Re73WYgkLhRuzOcf14zqmUl+X6rFEl7nZqstWe+QXLLVyh1IGFn5njxPMl/LVpBtbRn37+wch3QHTkNmpmv41slm82qnrvUyUDVR3D7lJJkiq5acXaVer6rhaiFb3P/5HB19Q4p/KO+OBmh8doSCW9jJwiN7QR0rbDwJEFCtQjHo1MBVt6TNs63UIlo5WMqiDLml79J+qpyrmUVGSniIH6gQYwe+UrzRfd3+XyQ4cpKRhUEIkpd1yLagRob+pJkonPDIEK92qxk3dIsvn/1M+553Zw1mHf/GW5ogldmg0LfERrTnIUqONI8sddcm0lctjWL375AY7jGZVRwgJ9ZBiO3iGrONHbOoxoTvzGJkh4z1mrEf3IXl8f7ICygHkAxyLDRa4XqTsowJFU MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 66e7c7f1-d0a5-42a8-8d32-08d4623f2e86 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:DM5PR03MB2955; X-Microsoft-Exchange-Diagnostics: 1; DM5PR03MB2955; 3:hH2wYcyplII11+GmnjYVfHexYBT3RdN76Nm3vJ8DmkTRH9zd+vct8JtHmXhHyfqNINsGrJRqSNhz6gkt3uQhwtLEoFm8Jyb9zS/rfsX16GcVf1RQIjtGBoF+dFnRY0m4NlHLf5RpnJCZN24O6Ndnsnnmes2q/hr24M1GE5X3J4/TSbd/rRpnXO3vh2VDuDQ4Ddu/IPtfS1QpjI14phky9E3eCeerDgV4BebMTmSMNuZvXe830k2hBoFeuY7CuRg6Rj/aCIno8WOGcfQ09lvepFjZA3A6Ul6WGCkLHQnKxV0yYPpeL5KDKhH2kIpXahd8HC4c/7ri1jfD1cI5b6t/5ByLxdLOzlwU1YYULxYlKgQJNSi0x6qHqn6BXxm66A1T; 25:/HU2gih2fwbFkCxgUOxpieJtEyxeQbzw4ZhWqxA7P/q8LW+7sKciFgN5XF2yBa8QVFA/KOilt6OysqN9k7tWsejtbA5ih2iFz06mrzaypoLy5lM+QHIdL9ucnwao3S56hM6tLE+fqlJqS9gN71iJIB5ZE4YbegLVV8coo2jYkM0wfsHU8tm/o1AF4ujka85B9R1WJ3LZd7H8PQD/kM1sA+PrEwWqMjjRyMOtbAF5QuTXVIZoBsKqFhAjxQeNKQDWYjmq9coWGgxN6z2wc2QGkqNKNtyTZrfte9nj5JajtnjA03JPWv+snljCYyIXoXe4pGtF6NjHj6CKgRl0x54XlLC8srJisM15fVTpkrDs7AyIGS8mzLvg7jeQIJFBc+m0iJcIlsEvKpQyDX8JiI6NT/bagKelBG9I9xpkJ/WxNtN7/VKQ3D7OlfyfjV30ZCAm5rejdQixnOReG1w3SKVeyQ== X-Microsoft-Exchange-Diagnostics: 1; DM5PR03MB2955; 31:WgpQymEeMxeKCGaoKmAhm5cOTk4KZMYCppfOScouK1i6NHNUK5kPANObkiYkKbWt6bjQ72GKxEMYq+tXt7xLYOLzjNoTY+QMGXoiA/5WasQ5Md9jD3ztO2oWKXW0zmt+AFZxWvHmHieWKacImhFiiZRLkURZQFvHJnZuaCp4aRe5Q+4TsWtqaNXk9N60c5WOix0cwErGHcRb8dK5zqwuBlrMwISD9fOC9LgReByVCU2TnZpdYPH+6ZDtEkl+bnwdBNalNJWFZBsduLjB9fXc5hcwKl7rYqHvMSRaw9Dbo2g= 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)(13017025)(13015025)(13024025)(13023025)(8121501046)(5005006)(13018025)(3002001)(10201501046)(6055026)(6096035)(20161123561025)(20161123556025)(20161123565025)(20161123559025)(20161123563025); SRVR:DM5PR03MB2955; BCL:0; PCL:0; RULEID:(400006); SRVR:DM5PR03MB2955; X-Microsoft-Exchange-Diagnostics: 1; DM5PR03MB2955; 4:jYCv/UKJqxX/4mez9UGgUdmlnJhUVhiZXOnTSAM853ZOnkZLR7DKo+jEDa1mmVSPEluC9ZQwDA1qu/F3ieek41h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XKfak7Xnd0zuoLarXES4E6R70fYA4GpBhANjKqqmmSepD6iFY7o/hEFeb7Kh?= =?us-ascii?Q?yqg3n9oBmyC1ViUS/NWs1Eidvf3uSlEeyN5J9nUfPggaugD6fen+goAFUL9S?= =?us-ascii?Q?aVI1fOeVfw8UIR1PZLuBpKWKKWRLPn4lGZPVnP3Ssb2Mr/4figZmvrwED+YF?= =?us-ascii?Q?USRoSkVfT6igBfks/OfYQ8=3D?= X-Microsoft-Exchange-Diagnostics: 1; DM5PR03MB2955; 6:C5cP/qzDb4y3EBd/5zFHWwFUbTUoknIzCVSTMsPnoLrc1bSltpwNnrwG8cn/Zz5Y5WJBuP1FsEL8VeSqe9/VP0KmjnyIFbWC5HVIjagieF8zAga9A//pNzbHdzv+Lq87HWLliIpm5aS2+N87KI1NksDhSxT0rp/njzbJK0NwPETMJUhN2HqECDpsJF8BcGsO1EBq3smEt3lYFbqtTy37al6aFWcLed9he5hV1YuYqDpTIXVRC4BvSM2mqtHWIdbZVq0rx77SCJ08XfS/owPf28sUyZx63Lk8skLhsdqIa+PK874JkJH5p7ePpLRtb8IvyhB+27PeiWYd1h3R4mp0tbpCD3CgUuDEWnrGUj/+W05HwqZEKtoeUa6H30wFhrbWxAWgBjoGp1T2MeEtR8zwBX8cq4OCBvozzsIN0EvqUpw=; 5:6Any+jfH881KZfl8N7B62QEa20LlT8ybQwXifouFK2FuvRgL+DVTiGHeE6EUewueCgX/WMPDED4aKQ8wQd4cgxWsFffpC1ErgkDlSQhmXNwg0BhAiLXQN5LbcJL28B7bQECElpKmIpX3SCgb2AKbVyGs/TQyrXGT6Y6+LtiEVpkGcIDNFSBq8DB0g0Qt6ull; 24:mvS1Ycl1/OYSLKx071cgf4EVEqX1CLR+3pqmHosxex+mkkSbK3l0n5Pxe2XlNdLAjm78fyONRBlKtEGsgJxf3sgHwbKAXWSOtM6HqHHgR9w= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM5PR03MB2955; 7:DWWBRoOh9mqYB3+4cKfr8LfplHnF4/XvyTB3gb2960C8Pt5M3j8GJ+Y6OIPPRTfYQJmow5nTPULZCiPs9KeB+6YGXwUvf0TELpMAqWbIV4vMBQTnxadHms3SzH00v1LHAnkNjt9MG6u3jmvYqDXUdFDfe0mPvHGHBBX9dXxSdVgVr9G6/2YYYna6+zM6mvYOELFis01O2a+qxLbTNCyn38Szv3ApUFsPPQtBtvJKx4GHRgNz/JVxE5W3l3Q923Vv4ZPJnuSiu/CKNI20XSX1i3kojWSV6EQfPV/DC3ALwkSpbs27UbNHDLHpxO8/lEWxDElE7EqGFX3XWx6L4G8phQ== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2017 14:11:26.7242 (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: DM5PR03MB2955 Subject: [dpdk-dev] [PATCH v4 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:11:31 -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