From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-sn1nam01on0070.outbound.protection.outlook.com [104.47.32.70]) by dpdk.org (Postfix) with ESMTP id A22BA58EC for ; Wed, 19 Apr 2017 17:38:17 +0200 (CEST) Received: from BN6PR03CA0070.namprd03.prod.outlook.com (10.173.137.32) by BN1PR03MB251.namprd03.prod.outlook.com (10.255.200.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1034.10; Wed, 19 Apr 2017 15:38:17 +0000 Received: from BY2FFO11FD025.protection.gbl (2a01:111:f400:7c0c::147) by BN6PR03CA0070.outlook.office365.com (2603:10b6:404:4c::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1034.10 via Frontend Transport; Wed, 19 Apr 2017 15:38:16 +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 BY2FFO11FD025.mail.protection.outlook.com (10.1.15.214) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1019.14 via Frontend Transport; Wed, 19 Apr 2017 15:38:15 +0000 Received: from bf-netperf1.ap.freescale.net (bf-netperf1.ap.freescale.net [10.232.134.28]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id v3JFbvDU023764; Wed, 19 Apr 2017 08:38:13 -0700 From: To: CC: , , Date: Wed, 19 Apr 2017 21:07:42 +0530 Message-ID: <1492616268-6307-8-git-send-email-akhil.goyal@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1492616268-6307-1-git-send-email-akhil.goyal@nxp.com> References: <20170410123108.26305-1-akhil.goyal@nxp.com> <1492616268-6307-1-git-send-email-akhil.goyal@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131370898961101505; (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)(39850400002)(39410400002)(39400400002)(39380400002)(39860400002)(39840400002)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(9170700003)(54906002)(2906002)(77096006)(50986999)(76176999)(104016004)(105606002)(2876002)(53936002)(2950100002)(2351001)(6916009)(6666003)(86152003)(81166006)(8676002)(8656002)(106466001)(8936002)(33646002)(48376002)(4326008)(189998001)(47776003)(50466002)(5890100001)(50226002)(85426001)(356003)(38730400002)(305945005)(110136004)(36756003)(5660300001)(575784001)(86362001)(5003940100001); DIR:OUT; SFP:1101; SCL:1; SRVR:BN1PR03MB251; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:ovrnspm; A:1; MX:1; PTR:InfoDomainNonexistent; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD025; 1:s5Ubw42s4celzpunfBYRzb5VPRrn7MaQ7i+ldjJQ21aEaSkcUG9HRcZpIiOnBvTtEyVrbj8wV0zaxU8LgB4WGjSRioDTSy2k6/b/Mx5OGawwf5slNr/u7DVLbuDU7Db2XzzWZUDe7cRJf+pRoxXDFXUGyTbktJewGHfejkDtUFYbT4sRUrpdP2a2ibEtHqA+XglZSBHQ2ozKZ+wxNNrlrmgBzwv6kDhNsrlGkXGySZ78JPBlUxNwN0PV9SohmoilH7C1R54z7DYUbCjp+Dp+uosvbnomFUDkC4teE5uaKtRg2/f53FCeJev9BT+0DPDYLmFDVAl07VSFhsHt4MYz170xwIHrvh7shz0CPQLRK9kLOFjbb+j6JUHlRe7qGAriQjjfaw0nv2eKQ3ld2feNPUeDhxkMIPZkKlH0AXyRUKyMqZEvBM3BfuVDbeY+2PM+pknJV9L9k5DW5gXw34l0HSHwZLiBxPE3TTJCtPySHDDaY7trNfyjJGRvLzG1HN5ITBZra9XHSrVvfSk88BASgUB1VHpXUpPSWgxrpeOC7Hi9fhla+okOJEmoIQtMQfAV/Edfwo2CcMQy0lwi5jkbF35Af2iwBAn01UKk4Nch/BlpMUuU4o4Umb3cvxGTAi4nYPpny7ogisLyLjGYAegmT+CXm+9b6X9Js9rLCC05ond6Qae+15kQvZ9wYYerOxMLxPd0nJhVPulFJ5S60B5A/tFQX5YD0Q0+aiDduG+RkxZHkdj0SEdevgTOD8rLHemB+9tU/CV382HOWV5KD0DWHQ== MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6d75f579-35f3-4d2d-67c1-08d4873a18ca X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131430075)(201703131517081); SRVR:BN1PR03MB251; X-Microsoft-Exchange-Diagnostics: 1; BN1PR03MB251; 3:6okSLGnZM+JsNLke3Tmjs4Clsz3HNsKWyV34X0yCJwVMPsOmZ5UACn+i1ED2fNppIDPbEzBC/ASwpVejVLSDKf91Suj9sI3t+Pe32+ZQQyoWjeHetPzLA/uJSYDsdzwzlWb5C1+vaU9bhfNSRREA82eYI1GcJmbgBxz6WcDjzNAx3s1O3uaUuD/eT4x3soMJaEw+JQzVp/RxJI0iETxTUqGILwsmGOYbAHWsVEVjQtjyAdbtFJR6tYqpJqVQbmcHv36rT9dPadFQaSG8OwnwPk+X7pUEOwJyTF6o6fo1nL5eweMdtfpprgl/vK7BYIzVXpbnNmHIiZRD+9ZsQcsy6EYtloXSmNC+4WitjmUkJ5LXBsHUJYXFjd5wT3iiAIPvD6fFNO5IePJo6lYeeGO3e3a0WFFgdewiPu6ReDYayGyP8bQ+NGuIRgJmnnXfO5sz; 25:c3mOTpasp/T/4t8O+gbinPfXMxB+MJrrz0/aRdpxYw6DQp9tAX7vtfIAmBb6+wUotiB8QZDXJy/jBcXK1QQYtOHms3pUHJ/PA1NiKWFdJyHmtm9FfSpUZ6uxz9b0HmFZZWZ9Hv2Ul5JZZRecht8Vz6P5MlGRohT6qBEk56Qc0TwD6X3QZu0R09hu4Kp1ihEG8+m4bpOdhjsq7ewqjc8ugELWqJ7ZcuiP3iY6gxmAYnhxgHkw+KQ8ssP5WR01/xUnKaWa1nXOHjh3NfvEnkleM+YWHJ9PNREfNjg9WoBVzaLjLFGxrnl5DrUao+zCTQ5oL4epHRdHIIkLRgSIA6XrfxKvNm40Fj78C7q5xTqC10U5ib2pcMqJrxJ4Zdv87Q/R1ZfSMxXQKEUm8Zv0Yc+zIIlbsQUeAftFrWJgvwkkfy2Us2Eo67Wz/pzc1DiW6UF7wMbnzxuf77vboQA6rb8Avg== X-Microsoft-Exchange-Diagnostics: 1; BN1PR03MB251; 31:dy+bsVvww/KjHTI7ivthBnG8Ysajs6iNnnBCBoHQrcRamAXYvFGCgtW51iKwnJXcDJE9IYi3TaJ0ON2IoZRNCZ1d39c4zBjdApAPtMOlaDuyw6uwfexlQslx1oR5nf+gm+mxE9j8NCZkKSr+dFvi/cAwUQb2meAeEXdqd0XLyl3P8VdQ7NwrmfXpc4biDBlxkg/4LLrno+cEcxUavKGhzJ+PGq+va6cXrDAXqDkI7jG/UuWqrDw+Yf/dYlrRm6rDcvdIqfxDA8I/TNXx1ZFgcQ== 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)(13017025)(5005006)(8121501046)(13023025)(13024025)(13015025)(13018025)(93006095)(93001095)(3002001)(10201501046)(6055026)(6096035)(20161123561025)(20161123565025)(20161123556025)(20161123563025)(201703131430075)(201703131433075)(201703131448075)(201703161259150); SRVR:BN1PR03MB251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m5Z0buz7H8zr1SXdU5tSXEY9xJyz9mL6hckLlycgqipdvS0xQ==; 5:ci0dj9OaBukcBdJzjGAZCmBUk4Vgx5h6itBYJ0Xze0w+xbTX2ksIAuFsfw6S15VF4bLfas0a1Eo3NUTuffxYZzyG/JA7J/C3SXVqW8scEDiUu0geblD4Fn0Dqhwu0OypfHxFU+AI3yzQw9tcbM6HQG63MvpxmgLixrnhSDaiKwRjeWikua1d9TDGKh7VFFhW; 24:B9SHys6KRcpIw9SmVa0SRAae/y8gVreCrJONDuU9362MWbRN0lG77OyT2bNzWkO/Ob3LbELwgcnJc4P3AaoxQMwxv6R3m6cTdciXAB5H23U= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN1PR03MB251; 7:BV+UEDzcLH4yG1+cPYYr1zDg12B71AlS5krOEn6QbdPUK1upjKwOKOGGoRxK07uWL4/EskihkUrD4pqayitR4EXxcV2x+lpggZJ1ybMLJWWa7+AV0cOnr8ON1cXuZS91Lw3YkjAHLOU0yAg7+deUnMHj8TJka3brFOAvDZMoPyZsu2UTwUkqSVeqdf+Lg4xEt1JgEMTZqqcjxifvREzU4q+QzKXD70RIbs/jwvdiMb0OeQ+3Fir+8cfxYDeEGnXtrnbizrfpVGbsoH2SI+1LFc4hIM63OX9r/NKf2CnC4cmJztQJZ9zrdp1nq+rGNOSSO5pq8rKlnSpLvgfQGtCXTQ== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Apr 2017 15:38:15.7981 (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: BN1PR03MB251 Subject: [dpdk-dev] [PATCH v8 07/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: Wed, 19 Apr 2017 15:38:18 -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..e0e8cfb 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(__attribute__((unused)) const struct rte_cryptodev_driver *crypto_drv, struct rte_cryptodev *dev) @@ -77,6 +217,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); @@ -84,8 +228,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 | @@ -103,9 +249,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