From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-dm3nam03on0080.outbound.protection.outlook.com [104.47.41.80]) by dpdk.org (Postfix) with ESMTP id 80F4CD1BB for ; Fri, 24 Mar 2017 22:58:48 +0100 (CET) Received: from BN3PR03CA0102.namprd03.prod.outlook.com (10.174.66.20) by MWHPR03MB2797.namprd03.prod.outlook.com (10.168.208.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.991.14; Fri, 24 Mar 2017 21:58:46 +0000 Received: from BN1BFFO11FD006.protection.gbl (2a01:111:f400:7c10::1:184) by BN3PR03CA0102.outlook.office365.com (2603:10b6:400:4::20) 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:46 +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 BN1BFFO11FD006.mail.protection.outlook.com (10.58.144.69) 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:45 +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 v2OLwRmh007000; Fri, 24 Mar 2017 14:58:42 -0700 From: To: CC: , , , , , , Akhil Goyal Date: Sat, 25 Mar 2017 03:27:45 +0530 Message-ID: <20170324215754.21751-5-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: 131348663263539817; (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)(39450400003)(39840400002)(39860400002)(39400400002)(39850400002)(39380400002)(39410400002)(2980300002)(1110001)(1109001)(339900001)(189002)(199003)(9170700003)(53936002)(189998001)(36756003)(2906002)(305945005)(6916009)(2950100002)(85426001)(47776003)(104016004)(86152003)(8656002)(54906002)(77096006)(76176999)(50466002)(33646002)(50986999)(5003940100001)(86362001)(105606002)(2351001)(106466001)(48376002)(1076002)(5890100001)(5660300001)(81166006)(8676002)(356003)(2876002)(50226002)(4326008)(38730400002)(110136004)(8936002); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR03MB2797; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:ovrnspm; MX:1; A:1; PTR:InfoDomainNonexistent; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD006; 1:baq+qkrmlGkK9KFwZmEeuqY27iZzzNz8NRwoIaNDBiW7k24etwHGOVNVMBkn08Rcqnod1BSmTAtdCCypEbJgowZIWxCHZnzy0iTV+FEw6fT3R656Ruc0w5ffWRqejlHeeU/aW+z+aB0W/zZ3QO+odpZSMzgh2W0P1xWlG1dOI+hhs5ASxqQpJUdWwftT94+EvkLiQnH3TFE24l7gaH/nssa2HhVxi3ZuB6L1a+LgH2qXauCxKqNrm3uTEp3793eIYsk4k8KFPUu263BBvkyVvCAXkaLC9GmofJkpGuPacg/78n5wYzMByDHsi32O5rBC4N9RALTpDNcKkhLXce/GXD/GyVvQ0tgJenAAq0/rkIMeInG3BDuMYW4CWXzeqyFTNP2jGBUO6Wz9Tz55jh7u+z/IYMZIA3NSjU2JuasKq107uVFjwoT684AA6hZWuU+oJ4NXCHMC6ELohCzifV8PfQeiKT8FGOajmdJ8AqQgil6+uoSvRnglX4iN5xmENsBeQlzcP+lbCHczklLcMWq9WiRDPv4BrBVQbNa4WpOdBwW46sbF3iwsx/k2XGR/7pIvVYreYc4HzrB0FKX1D5AO0MX4qDCEqUVqeAU+5A6CA7e4rANaJMe8OTSCQ4XNjbk49O+9wxblaASocmu1YDFlGAX8O6wecEsWg4tfuLJtBPT1DHNQHYzcPwtPYNd4t/UWHbBAlJ6M/jEByx4UPj4S3ykwWoXVoA9CNt0gTHHzRobtQVKLMdSWQ/DG8HSwkdVX MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 1fca62be-e070-4a61-e4b3-08d47300f1ea X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:MWHPR03MB2797; X-Microsoft-Exchange-Diagnostics: 1; MWHPR03MB2797; 3:Ao2Ebr3r9CTneYX/uA+535hTXkMLGK3O7rXdWuD3WZBhlKvS5XKiGWv/OQJOwYw9wQGzIL38eio7Sf8jfozOkw+JZ4Qo50TasjYJ7QJ4wvGPbSjiMeo7L+l5si9WgM6wLNSWlTD1FEQVt1qlGpmMBq8nEiSJVhOsS0IWpmrDPA5JaDa5kF+sHJU3pP3i6UsD7o3pxhLWhGqho9bRlVGPlcnQGportaWIuhCTffx9KmcBZz2thfnv3GD2t3IMqYLiG9CDm/N5bvV3yYtE2oNlh8Xm2lJUMz1V+pQ6EHQMjcAH3p3qbakuXtBjlxQIYaws8RWLqdUjXTTy5iaIfbrXcfHwQyq1IQ9LnOOjXp3HZ2HXQrzZokX1cAp+uFZiSDPZ; 25:38nsdTP3YII8opMx9AILclE+67fPaOgMppZZjMR+QfYv50tOrto4UMmlyRIGkLBDrH6tcL9pm5299BlIX6ZY/OFpylFWqhmSmXLmdqPaRsCwii+hvuHl2lTfAZB6QVXxifBAToSh8cK52hCVrzqHEtYNO30SmaZoT3X/Lx1DZcpZWD+YY+LImKCacQGCyJV9oG4AH2iuDPz7GWgV/XS36PBZHXKedAEF4xaI3ii8ALM/q+7k8aLaXlzorJ2dDIEXpQHBZSi5uBU9X0puGHunvRaLVedilyKSIsAmcPZrmSAKEDZ/zDXRBW4O00fyG7ScFMzx7n6Q8DsDDRSZmdkEX9gWZ8ufej0kvNN/QklCuURjsXCd9rVSx7Pr3YyLFVnee5Y1/UIyxttMnxSDQO3XjxIQBGZ78zTplOANqNRDhsS/dtob71LD1OEiYncH/ChrEocgTLaeMCMzhirq2iBJ6Q== X-Microsoft-Exchange-Diagnostics: 1; MWHPR03MB2797; 31:T9pHb4Eqid4Igx5S27XmXuSyInv5EsfrWmMK1YzA9KwcccQKIElPtM+V8RNnnijvd1nzn/85FwnF29j8f8OF2qjIC/okRH6/RsI/gWMuKcTQMnRETS9REzu2MvVbo7gJuwsIQbSbRoXE9djzFz13c20AUmVNIXiRi0mywk1hhp1RpCOaF2Yb52xxA3QtN40XQ7ZcQW6yqKlZGfVWfvqk7cYyk0BtrRAPx0H5OmXb87v3ec6cj48m4MdIgFJtnA3NN4UXZeOOK9HB+X+CK6e+eYPb0Ysa06ZciW8T626c4x0= 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)(8121501046)(13024025)(13018025)(5005006)(13017025)(13023025)(13015025)(3002001)(10201501046)(6055026)(6096035)(20161123565025)(20161123563025)(20161123556025)(20161123561025)(20161123559025); SRVR:MWHPR03MB2797; BCL:0; PCL:0; RULEID:(400006); SRVR:MWHPR03MB2797; X-Microsoft-Exchange-Diagnostics: 1; MWHPR03MB2797; 4:OUyBeyF2zTmWTgInTERIAqriUsFWgnwiq6TddUPPjkOvBV3YmGcA0oy4Sf0W5wdh6/cfcV/U/aiEDdkl8BSQhIA9yQiX+ORdIdDQJyz2aOca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/4tmEWy83xHM9C3rvr8u8pEWGi49kZR/KJ/5sathkrconla/rhfpz2x2y6Ei/3Z97KsSe1Q1LJpC7U58m3S4ebezu4T1qPr6qm6vqXFaf52Hd1ND2qfie6kUPq/wOSjTfax+9P8dDkL7KAd4mziSzma+hFyRoy/UkUj+2P9fQsRzaEWUG/YBiwFDqAElTFSvIO9TL3wEzgcz4WB8fjmX7TcCfXI58s2L26cUMuFKR01LbJn+fyEuWC3XJEG+aUDO5GBUeHtIZJeTLEOfYkYl8F0dIhkCdW1UhncmzMr5PCrbLXFSw8LDk9q1eFZeyw== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Mar 2017 21:58:45.9951 (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: MWHPR03MB2797 Subject: [dpdk-dev] [PATCH v6 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: Fri, 24 Mar 2017 21:58:49 -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 378df4a..aa08922 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,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, @@ -77,6 +217,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 +228,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 +249,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