From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60063.outbound.protection.outlook.com [40.107.6.63]) by dpdk.org (Postfix) with ESMTP id 43A505681 for ; Thu, 13 Sep 2018 08:09:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WktA+qFwfWsz/LvMvcJ7CaFGRpv5X0Y9sKoulN5DWiY=; b=Rz4m22AvgVVS2kzIBii1I+exl1czo1Mr841RCo7QKNn3ctmQV9N/Rh1dwi63qS/7JuYOAkVRActMNyiD200yn9vbTIq5NrKvZMdrdV88CC/CFK+YXhoK60ySbfRLJ75B5y6NE+As/EXdJI1/YZH72l3NCUzsf4hKe8TNOZv+ed0= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=G.Singh@nxp.com; Received: from Tophie.ap.freescale.net (14.142.187.166) by HE1PR04MB1529.eurprd04.prod.outlook.com (2a01:111:e400:59a8::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1143.15; Thu, 13 Sep 2018 06:09:31 +0000 From: Gagandeep Singh To: dev@dpdk.org, akhil.goyal@nxp.com Cc: Hemant Agrawal , Gagandeep Singh Date: Thu, 13 Sep 2018 11:38:42 +0530 Message-Id: <20180913060846.29930-7-g.singh@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180913060846.29930-1-g.singh@nxp.com> References: <20180913060846.29930-1-g.singh@nxp.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [14.142.187.166] X-ClientProxiedBy: BM1PR01CA0095.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00::11) To HE1PR04MB1529.eurprd04.prod.outlook.com (2a01:111:e400:59a8::19) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 172b737e-a3b6-4dfb-6c80-08d6193f7926 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:HE1PR04MB1529; X-Microsoft-Exchange-Diagnostics: 1; HE1PR04MB1529; 3:cIyvDG+FYo7V0T1DmaIwynITcsf28n7IBsCOkyQew2neKwjh2HEtroRSX6y4NvhYAcyw54B3WPeyDF24wDo+Yeb4dZ4MMyLTjq83UiI5HptbS0t3Pv3UruiHVTkvV+aWpyLKHlSpKf8/a17B1tA3ymMsfSf3gk2OyiFhNQlaI/cBB8t6vIVgpfU0KP4ahZsbjezItD3DQB+9cMJFIGDE5qrfce+QVfW7br+8f7jc2E4mVeiGGDy/vYmkdJStuKOZ; 25:bct4H9frblXtkc0B8ZcPFVz7Cln+jxFQ8CokTsmmWwZjNaftPyXARjVNly9m364OYYY0x/dfn7tG2mZbfaUDYwLVtMMIVGJjLg8x/r2Fpaq2uUoGtkvgJOTedcgLHpmPGEf98Jkog+Nv+0YrtfJ3fAXvoaYO78eD8XUr61PEasUoRzUHCKw/9CWCR9MrLHtQTL7HNLaZG6+QrdrIAH1HekKdl/tXmYBu7gnUq84puwW9shjpblOr/qRklprjWriOgJOh5p3UTOVTBmW4yeME/rVujCriLJzUqqdX9MFeo81qctF1wIpTd0WgVC5Fs0Y/Ahojap/DuL3ku/CPvzNBxQ==; 31:MxYCR+b2Os7lt9hEyZv6EVYRZRUGwj9A88kldM/9plzYHU1EYSnN9aQFYxOshcg3qh1d2CDi6rHo1O42OPyfQhmi2bieVTOv5PmvqXdKmpW0AH/U/WKcjNeRd/n9Y+j5DyQ5NPDObN/R/ODhVBDLtkZwrM3i7Nf6Hz4KZ7BU6a12RJ5J5w/N2x2IL0weTUHKcGb5OQiIJPtWFxdMFcQWYEO6jtSKRPWS3zyg6Y4olxc= X-MS-TrafficTypeDiagnostic: HE1PR04MB1529: X-Microsoft-Exchange-Diagnostics: 1; HE1PR04MB1529; 20:ZxkKFqRsUACo0drggcdCXFbL1e3iq3w+rWZubmkhAH3nFCaQh7pWXgxC6srGJbFwkG8A0nAGQmNciKxay6X2sa21N/cRBgzRcLjw87khg5Sb3wVP0P6TE7v+MnD0mQRC+JSrj4ILJroLAZyu6pqjInpOUgEOdBKQcrDki5Zbdi/rwnSMmjA6H6f1fo+c11CUODAblce8cp+LDrK4rrhryBockKmvBksrY8e3NBcVkhDtZiNaq4XDrUHx1SE9PVAU8GWWxP/StIYCWJd9Qw0P56ti6H7Id+KKlYeQP/RVVLiUo5MXs/eCCO/WJOaw504wPnfSeEgr8w/zwRNabEgtxYGVlxeRvFz6A2pAjQmqSkwxq2pM+kuX4MK0IV1HZ5IAtZ1TS2sJQIrH5gDAoF+gqkA78vZWXNf5ZI1OFqXnoQUew9R+MSwbsX5kUbHo6XnxjA2BKE1NswSDhB+icoPqdkKUOS57bcBqL2J84CynMN3NfSpnDHgLy+00rsaljp1N; 4:ssLtTcHZKKjaq44pkJhuUsBPsTr+mnrqCocXgUjXK0fKMz37+bkLP47MVtbT4+ai6eSD6JA+olojYveUdGus6tELt+4Jf4YmTJEcGZKE2pmA8JFwfwkeSneuIP77ByUe9UOLKI9UMqO0ymjDuru2aza4ff8bG4eLN5TuRPhHOpKGBmHUU1JL7BSxTDbmnPTeTigHeaAoMROBDzjj9LurFkGz1g4GHSRamouZtj5+CWylzHKuI+jgQjBKS8GrOb0GBhgSX1znAg5xfmewALKLBbHu6JeOMMr1jO2ar4K9vl2jNS20XTodkS+9wbq0N2YR X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(823301075)(3231311)(944501410)(52105095)(3002001)(93006095)(93001095)(10201501046)(6055026)(149027)(150027)(6041310)(20161123558120)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(201708071742011)(7699050); SRVR:HE1PR04MB1529; BCL:0; PCL:0; RULEID:; SRVR:HE1PR04MB1529; X-Forefront-PRVS: 07943272E1 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(366004)(376002)(39860400002)(136003)(346002)(396003)(189003)(199004)(2906002)(6506007)(386003)(5009440100003)(6486002)(51416003)(6512007)(52116002)(486006)(2616005)(68736007)(956004)(53936002)(476003)(446003)(11346002)(305945005)(26005)(7736002)(55236004)(76176011)(186003)(16526019)(50226002)(478600001)(47776003)(1076002)(3846002)(6116002)(48376002)(105586002)(106356001)(25786009)(50466002)(5660300001)(36756003)(72206003)(66066001)(316002)(97736004)(8936002)(81166006)(4326008)(8676002)(86362001)(6636002)(6666003)(575784001)(54906003)(81156014)(16586007)(110426005); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR04MB1529; H:Tophie.ap.freescale.net; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HE1PR04MB1529; 23:0pZXhIIXwU8fOjWF7uyxs5I/OwcnEqb0Ei1imNht1?= =?us-ascii?Q?PP50TeaA34oywSXQQbx34Q7Q8qxEP4n7nHskZ79BmvBSfWXRJbsFeBVodUK/?= =?us-ascii?Q?JyZnaW7IOC3dV+qV5GaGnI1d4MzAJ1u9z1XTzHValODb2/oCWmDLih1F8swB?= =?us-ascii?Q?toJbUGvLpf4z4rD3dbWBMRjU0Ta5YygPtrnRurdfy1bLrGHRwBMu73nsgqOA?= =?us-ascii?Q?HfkmXj7LExyyVJeAW9yitUg2eOLz37MzBDvmypOqXaQjRIay0DQETue+D7lv?= =?us-ascii?Q?UdLY1A/wqZ3/86IwXS+WGSFT6+jxPA9c4p0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Eyw==; 5:wXBl/mvFM/ex3G1Vp/sxUf9jgLTCBJTDgFi0uwqcM+3Mf+K0EcXzgV/qEnKE6VG8Nj7Slt+vIjz/crr4MBIRvWa78YyH5xQjIKZPCc/qsdQTS4Up0G+ZlAvoWtbVO97jH37XS7gOeyvnzp/lEg+eke2ylYVmBSAyA6KGVkaIlGE=; 7:lmAwJ2tpdIhnO9b78x9KKXZjOy19+dt+ETKIsd1k645yWat24Bip3CwW6cXTaMJbTIyaB560M3gCk8wKOdF11s1wuKUryzricWHPmbXowiuf/749eAquRCF6skNg1thI+tAFSzOLjOXVTCkzx/5etCMGRw3M5f4jICiQjC4Umb8VMY3eE8GuCS3xLnPNZamyygEB6ThkMoJ6n36T0pw8Hr1jpT1FxYlFKSEd5CAIo09tG/m/EdPwRPHCKqfaLPLd SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2018 06:09:31.3979 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 172b737e-a3b6-4dfb-6c80-08d6193f7926 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR04MB1529 Subject: [dpdk-dev] [PATCH 06/10] crypto/caam_jr: add basic session config routines 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, 13 Sep 2018 06:09:35 -0000 From: Hemant Agrawal The current support is limited to crypto only. Signed-off-by: Gagandeep Singh Signed-off-by: Hemant Agrawal --- drivers/crypto/caam_jr/caam_jr.c | 124 +++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) diff --git a/drivers/crypto/caam_jr/caam_jr.c b/drivers/crypto/caam_jr/caam_jr.c index f05e966b0..a0eee3b85 100644 --- a/drivers/crypto/caam_jr/caam_jr.c +++ b/drivers/crypto/caam_jr/caam_jr.c @@ -20,6 +20,7 @@ /* RTA header files */ #include +#include #include #include #include @@ -166,6 +167,126 @@ caam_jr_queue_pair_count(struct rte_cryptodev *dev) return dev->data->nb_queue_pairs; } +/* Returns the size of the aesni gcm session structure */ +static unsigned int +caam_jr_sym_session_get_size(struct rte_cryptodev *dev __rte_unused) +{ + PMD_INIT_FUNC_TRACE(); + + return sizeof(struct caam_jr_session); +} + +static int +caam_jr_cipher_init(struct rte_cryptodev *dev __rte_unused, + struct rte_crypto_sym_xform *xform, + struct caam_jr_session *session) +{ + session->cipher_alg = xform->cipher.algo; + session->iv.length = xform->cipher.iv.length; + session->iv.offset = xform->cipher.iv.offset; + session->cipher_key.data = rte_zmalloc(NULL, xform->cipher.key.length, + RTE_CACHE_LINE_SIZE); + if (session->cipher_key.data == NULL && xform->cipher.key.length > 0) { + CAAM_JR_ERR("No Memory for cipher key\n"); + return -ENOMEM; + } + session->cipher_key.length = xform->cipher.key.length; + + memcpy(session->cipher_key.data, xform->cipher.key.data, + xform->cipher.key.length); + session->dir = (xform->cipher.op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) ? + DIR_ENC : DIR_DEC; + + return 0; +} + + +static int +caam_jr_set_session_parameters(struct rte_cryptodev *dev, + struct rte_crypto_sym_xform *xform, void *sess) +{ + struct sec_job_ring_t *internals = dev->data->dev_private; + struct caam_jr_session *session = sess; + + PMD_INIT_FUNC_TRACE(); + + if (unlikely(sess == NULL)) { + CAAM_JR_ERR("invalid session struct"); + return -EINVAL; + } + + /* Default IV length = 0 */ + session->iv.length = 0; + + /* Cipher Only */ + if (xform->type == RTE_CRYPTO_SYM_XFORM_CIPHER && xform->next == NULL) { + session->auth_alg = RTE_CRYPTO_AUTH_NULL; + caam_jr_cipher_init(dev, xform, session); + + } else { + CAAM_JR_ERR("Invalid crypto type"); + return -EINVAL; + } + session->ctx_pool = internals->ctx_pool; + + return 0; +} + +static int +caam_jr_sym_session_configure(struct rte_cryptodev *dev, + struct rte_crypto_sym_xform *xform, + struct rte_cryptodev_sym_session *sess, + struct rte_mempool *mempool) +{ + void *sess_private_data; + int ret; + + PMD_INIT_FUNC_TRACE(); + + if (rte_mempool_get(mempool, &sess_private_data)) { + CAAM_JR_ERR("Couldn't get object from session mempool"); + return -ENOMEM; + } + + memset(sess_private_data, 0, sizeof(struct caam_jr_session)); + + ret = caam_jr_set_session_parameters(dev, xform, sess_private_data); + if (ret != 0) { + CAAM_JR_ERR("failed to configure session parameters"); + + /* Return session to mempool */ + rte_mempool_put(mempool, sess_private_data); + return ret; + } + + set_sym_session_private_data(sess, dev->driver_id, sess_private_data); + + + return 0; +} + +/* Clear the memory of session so it doesn't leave key material behind */ +static void +caam_jr_sym_session_clear(struct rte_cryptodev *dev, + struct rte_cryptodev_sym_session *sess) +{ + uint8_t index = dev->driver_id; + void *sess_priv = get_sym_session_private_data(sess, index); + struct caam_jr_session *s = (struct caam_jr_session *)sess_priv; + + PMD_INIT_FUNC_TRACE(); + + if (sess_priv) { + struct rte_mempool *sess_mp = rte_mempool_from_obj(sess_priv); + + rte_free(s->cipher_key.data); + rte_free(s->auth_key.data); + memset(s, 0, sizeof(struct caam_jr_session)); + set_sym_session_private_data(sess, index, NULL); + rte_mempool_put(sess_mp, sess_priv); + } +} + static int caam_jr_dev_configure(struct rte_cryptodev *dev, struct rte_cryptodev_config *config __rte_unused) @@ -250,6 +371,9 @@ static struct rte_cryptodev_ops caam_jr_ops = { .queue_pair_setup = caam_jr_queue_pair_setup, .queue_pair_release = caam_jr_queue_pair_release, .queue_pair_count = caam_jr_queue_pair_count, + .sym_session_get_size = caam_jr_sym_session_get_size, + .sym_session_configure = caam_jr_sym_session_configure, + .sym_session_clear = caam_jr_sym_session_clear }; -- 2.17.1