From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0051.outbound.protection.outlook.com [104.47.34.51]) by dpdk.org (Postfix) with ESMTP id 8A41BAADA for ; Fri, 9 Mar 2018 09:36:01 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=tJ8SCqZvpldLckmEj1LjJBO1BD5WlWp3ZVMzVbPnLHU=; b=quu3HRdFFjaLC81ETITms+wgcSwM2DLaF7egSgiNlpAmQPGVfGALyMJ4sUfINZoGDnv6fkY08bGY8ALJIPgVdtQTpxM8/t2R5aqYq0pTL3ceDAI6ufAHC+ODArCDAf2MB/y5fjRBt0+sqNPRPmxYnoRPzHjSLVxaY9FEGkfwYhI= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Ravi1.Kumar@amd.com; Received: from wallaby-smavila.amd.com (202.56.249.162) by MWHPR12MB1518.namprd12.prod.outlook.com (2603:10b6:301:b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.548.14; Fri, 9 Mar 2018 08:35:59 +0000 From: Ravi Kumar To: dev@dpdk.org Cc: pablo.de.lara.guarch@intel.com Date: Fri, 9 Mar 2018 03:35:13 -0500 Message-Id: <1520584520-130522-13-git-send-email-Ravi1.kumar@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1520584520-130522-1-git-send-email-Ravi1.kumar@amd.com> References: <1515577379-18453-1-git-send-email-Ravi1.kumar@amd.com> <1520584520-130522-1-git-send-email-Ravi1.kumar@amd.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [202.56.249.162] X-ClientProxiedBy: MA1PR0101CA0050.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:20::12) To MWHPR12MB1518.namprd12.prod.outlook.com (2603:10b6:301:b::22) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 080fa24a-1478-4f08-8897-08d58598c946 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:MWHPR12MB1518; X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1518; 3:4QN7K487RUUUm+9J6WisYtRZzkNWUaV139W74dPe5u4mDhqSWAI/mc3VEfCT9IDrzCMHAK94GbpROQVdbOGAO/QgRHlOjgZIJMf4OEhLHSbqXPUvPoUXaVeEFhEpIni3TDYj8vQDn5QN7v/6bIdGzDh7bjOopKk3kEoiQ9lRSUxMbLIH65gOzHHfaL138p6YqH2ZctSYzxw4yOW7e+WQ9xaHqN9oB4U9r5N6gKY2KFE/pg+uUwP55M2qqA2xSxgj; 25:Vi9As5EX/GHyKk1PIMCQ7+fF0uyVO5heLCEkw6Sn244J7yY3hNwQm2BkU2Ov0d2Ca9F2h/JVB0On2GXtygnZxr5hEvmcVM+fwyOH/qLi1YhHAgP4qJY818QiacaN2EBnxPF+gnaa2TERIQeXlZH5D9SHC9yTmjpPk1BZIn10QHmjVjbtWSrKWhW2/4Hp9EhcKxhf1V9sK84v4CWyoOGwN/nX7v/zaQo9LWm0+RyrFUKveGwYEv8ZlO/b9TfPsLMGlT12FxFp2Tsqofh6b2UBuaJ+rSO1iel/T2wu3oek/e1rbOzx2H9P10Wj6rroDqWlbIYTo7QJd4LAQoy+gt+ccQ==; 31:EFj80o4AvATZ6WenC4y2LGO0FzTvRW8cJln/WjtF+IpCRn3uoGMzi9OkNjq7zMix5drua3GJ8mSS4oCsSqzXIVF2IH9Z/zP0OyFT0cOtsNjCbXVl4R79MTL7JZKD8oz70IEv90gkc25TBzn1aYBQl3bUbkLvFUZuzysS1zQWbqdvRXM8WwieZW7LAj2Hs+JFe2IrYU3s9r4Wm1LXXMwFt1ElOCN7K3OZ7C/3CAnsi/g= X-MS-TrafficTypeDiagnostic: MWHPR12MB1518: X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1518; 20:7u5YMwcTQKBCuDZn4PCcpch9uf9EPyL0llmRnzbRAChrpFVra71J4c9zvUsJVvpkKn162HNVVGRGxVE+tfGRgktcFwwruIneji1JhaM74vzLcfP33I5qilgUb4QZLNYi93DsX1NPXMjlT0HTVngBomOQ3SmBnGtB3gpo1ctdzLPVFp0kx4/WR9mXfa3IKZSnsGzgnd8DGJBAOiw2rbFqcJVEZG/8WBo0g6O+DKULEiNeu2g115tqknaXobkTZ2DdBGd0aNjp9ITm87LooA1Vc+CEEc12XYq+7YO/h+Qo2GF6aNa5yu8DB1uPWOw9E10MmwcUV6u52rFpsWPKfZPG2PyE8MaIj+zPo4em7Mwl0uFdnqknI4u7GzhBAIyB7q5trEK7Okk5T+mMaiHnifhheB4HHCxSIhuSSDuoVmhhLQCd8lSwxGm3pi0inrpTcpxjySZDTxrHj6qDaUz5QDAd3pENBm7waU4O2P07bbFR6XuPUH+G2Hy7Z0kvzPEdmGpv; 4:UpeHek5fXS55iLBvs0E984pePK9b63yqwHiEPWTw5cQA6z7quL0ykVF5jP14Ph8fAoyqV3rzeAk/i8ahizm/SXjoOkFMVGGzI2Yg4SDvxQql7Az5YvkQHjfcU61r0PZ8/XzgqPHp05mRS+AmX4WeboP3vXeIYYjv/2JongZwEeuTJUsgc14FXNInGh7rQEKFxYQxdKKr5Nd6wtLub1dm8kIGN4q7G9smrFn/rT16nNRLFZ0oymyXFV6doc19WrpnQHlvgtBky7iXo7jAkPkbGH3FFryhCTQjun8HyFmipyBqkNObJ2ZwW3BJES4lnOpQ X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3002001)(3231220)(944501244)(52105095)(10201501046)(93006095)(93001095)(6055026)(6041310)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:MWHPR12MB1518; BCL:0; PCL:0; RULEID:; SRVR:MWHPR12MB1518; X-Forefront-PRVS: 0606BBEB39 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39860400002)(39380400002)(396003)(366004)(376002)(346002)(199004)(189003)(16586007)(26005)(81156014)(16526019)(8676002)(186003)(81166006)(25786009)(7736002)(3846002)(386003)(305945005)(4326008)(6116002)(6666003)(316002)(86362001)(76176011)(52116002)(8936002)(51416003)(50226002)(5660300001)(2906002)(2950100002)(6916009)(59450400001)(7696005)(36756003)(106356001)(105586002)(6486002)(68736007)(48376002)(97736004)(53416004)(2361001)(2351001)(53936002)(50466002)(478600001)(47776003)(66066001)(72206003); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR12MB1518; H:wallaby-smavila.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHPR12MB1518; 23:ZooZzJfE0GgAdmF8Ee7O0q7Rsmeuk9PGigUqHOptu?= =?us-ascii?Q?TzzAVwWvEEH5ZdXBnPVfTxD0acnWUUuASR8ED8I+2/sn1TXKUjlaK8ycFltm?= =?us-ascii?Q?VAzwcUI8Vw7VdZLx2Ti0C2HnhIljQHDzuLfV/mBxe3WBR6WxSDUQFUKC4zwc?= =?us-ascii?Q?H4xJ3WABh08QVIjrY0FCfRggjHqFMcrpP1T0PX5G9VkpP+FWNhVgeXV3g3/8?= =?us-ascii?Q?q0fmi/QYtDHGjpoCvggWvhkGIq6Dj9ar2OIKfpXcJ1XhTC7ECKSAfTaePtgL?= =?us-ascii?Q?dy1db50lQADufayeGGO+izKT4GscG3/MQg/YtUB+h/QTw8XZ+vZ7VCEvq5l1?= =?us-ascii?Q?yolnjS5OxfUtW8ceUdGsEANvqvQwOoyCundJE3/CXojpJo0x9FdQHi4dJpSr?= =?us-ascii?Q?qIfKGHd+32z22Z6212gD7WR5NCck55vpMai8qoNmjA707DI1klmh9ptEGsaS?= =?us-ascii?Q?kznssejXab/BSfOLx423S2D8YKjmQg1Wm3LpwF7yjpycbGVwWxNUWGojSRrJ?= =?us-ascii?Q?A/iWwbx4vuueHCBqaa1IWGglcCGxZHv4O+d4Vq6WbZhBGrEucJmMSzSmlzbN?= =?us-ascii?Q?HZn/u5TWNT9ggw9gnRcY+rOfy6tn2o9JUtTekyf/uD/Bb+atLL5T0D05t5JM?= =?us-ascii?Q?w1v3SF4SGGCP9MnElTtNcSfuLQ0XQ52YWjXcsjYnaYLkG0EqeLfHJHrqTuDf?= =?us-ascii?Q?6F5ShFbqbfBxJQ5wNRnRkLQ6F8CqSftRPtidjyhzG/yN0L6pmR+4u6Yzz7tx?= =?us-ascii?Q?Pac7ec7A2UhMiHZBr4W8PrYbec6E1Xwui0qK5OeWLeK2iM1uV5k0d/NYCSdh?= =?us-ascii?Q?gT1A6jJElWvbvl6UqaFD2chKB5EixI115ftXlcmO2oz+6aosOyy5PZcl8yVI?= =?us-ascii?Q?miXNHEyzkxM0i9Rrf9txozAZRyZPMoYOAxKsMMvCDZBCSPEYZYW+jzfdRqCf?= =?us-ascii?Q?ri6RLSxAinetNt60smfmrS/fuGce5mtSMfRzar0uwd7VjwFI6qT7sr9nGiJS?= =?us-ascii?Q?/4xUIIy8wXPBdh00z+2GRmapGhLFn6HaoO1QRYraqDkIBJ1wZ8C0fBw95DT5?= =?us-ascii?Q?ce+uZJAwBwbIvV7smZniq7BxB/LkR78qJ2lAkOO0zCRoLPpNC33HsqrdRV1g?= =?us-ascii?Q?AOWd0WAcsWXIuHarPnl9YaWAMa7uXpcvzpNogxyXVFM8+D1uzVDRGuPh4Da9?= =?us-ascii?Q?Fd43GuNRcOlE7Y=3D?= X-Microsoft-Antispam-Message-Info: YJKe719L99hbGpb0cFFZAdtChIz+utpvxfh5xJryxX4M2DK3vBq5DFgPAZYIMgin3c+EqrDjpwglbtaksCxFq33dn1OA9v/8O23VKMZDroWVzLlZr9r0FNKeBTVsTUmwXWM/D0NPwJXgMo6Hdgahks0NXrAAx1x2x7+7A8IiRqeGKLAdK+8Rq6vjArtmy3k8 X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1518; 6:dcczz8MHNofApB9pdSN87SZk+78NszeksmhxtO435PkDtc0x++SYxSOGWUC0tXQWdPtvzcX85tAmguig0NOyQlrwFBG9NJOw3pKW6o31vbc48vd7p89qPmOCIjjkZ5J7SvkIpZKdEnTtMPlu0DsuO84sZMq3wxgiwHrUz/9lTl9tvWiojLSZD7sZqkmYVQzevOzLaF4wdQBTtGU5Xc36IByhcowPobR2okIKt4w18xhaB4ERvX0dONrEv3dZRGLkagFMr5kLwVuWoSNE05OtpzIteMj0k6VRJTlmTKW51daPPkJMD2xIhCwKUEN2UANoriragrmFBlQkYeSkGwqTMIgsoKVvgoXHnIzK+gcau3A=; 5:vliQc+eLi9b4kSuVmSWXB/eneJ8m6fOXIaD0jcm8q3yimLcvGSAWdlipL7F7dhqEBHRU6g+eIQ8LlE8qYJm2L+JXq/Erw+I/LXzr9531V6MqzPfgZA3rLJ60GqShBnR5IfgMbXWCrG3kHM490eSxsUcUggSy/va6tlX4kEQbUWA=; 24:vPWdQZeZad8NFsIQfAMWS14hGTeVtT+JGwkKnODJx4Rbgs2hxujczLzHHZXrlekm1maaOKegyRlp0240syqZ4xJ/38RHsiNOwrVPcGz5HU0=; 7:apW+1Xky3EQd8TvYI9XaBX9397VIg5hc6iXTbeAv49fy8WvpN9GwijF8KidXGPN5RPFnndeOhgr50UfPmHj1Ck3uv2sDLE8uvc2JJoQt1tgr9ogdu5F3McfZmWRzQkQWVTzIj9cNMWDUOGWx1uKdyBdDsnOORFpBwHQGDJ8iNuSgRzGj0O8kjXNfFHVRwaYBd7ntZ75JlTiirQausfac26X8fjfIFhBNhLEYwdGWnIjaBVfQ/u/DEU+E8HcobeC8 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1518; 20:ywxnm8rFJ9IVgp5xwReYBlSUL7imBWN58t1spAPc9Rjg2/ZYl2Qw489Pyu/4JQCsRw6X4P/HMS9c0exTjqGpoWyIvFmnHr10rwLKx6cNf11+ybupNy0RD2t38ioblKa5WC3pKruaTe7Ic/YrZf41FPucPZ5c9nxZBYGwRLnbxW6JP7WtpMR0wVEVNGco5AXTaKBtiOQaN8I4J15qPdskhwTPVZbGOfEI+skK0lm0LInXUjL/CGUUEwBvgdhUHN+O X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Mar 2018 08:35:59.2878 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 080fa24a-1478-4f08-8897-08d58598c946 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1518 Subject: [dpdk-dev] [PATCH v4 13/20] crypto/ccp: support aes-gcm aead algo 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, 09 Mar 2018 08:36:02 -0000 Signed-off-by: Ravi Kumar --- drivers/crypto/ccp/ccp_crypto.c | 235 ++++++++++++++++++++++++++++++++++++++- drivers/crypto/ccp/ccp_pmd_ops.c | 30 +++++ 2 files changed, 261 insertions(+), 4 deletions(-) diff --git a/drivers/crypto/ccp/ccp_crypto.c b/drivers/crypto/ccp/ccp_crypto.c index 6e593d8..ad9fa8e 100644 --- a/drivers/crypto/ccp/ccp_crypto.c +++ b/drivers/crypto/ccp/ccp_crypto.c @@ -299,6 +299,7 @@ ccp_configure_session_aead(struct ccp_session *sess, const struct rte_crypto_sym_xform *xform) { const struct rte_crypto_aead_xform *aead_xform = NULL; + size_t i; aead_xform = &xform->aead; @@ -313,6 +314,7 @@ ccp_configure_session_aead(struct ccp_session *sess, sess->cipher.dir = CCP_CIPHER_DIR_DECRYPT; sess->auth.op = CCP_AUTH_OP_VERIFY; } + sess->aead_algo = aead_xform->algo; sess->auth.aad_length = aead_xform->aad_length; sess->auth.digest_length = aead_xform->digest_length; @@ -321,10 +323,37 @@ ccp_configure_session_aead(struct ccp_session *sess, sess->iv.length = aead_xform->iv.length; switch (aead_xform->algo) { + case RTE_CRYPTO_AEAD_AES_GCM: + sess->cipher.algo = CCP_CIPHER_ALGO_AES_GCM; + sess->cipher.um.aes_mode = CCP_AES_MODE_GCTR; + sess->cipher.engine = CCP_ENGINE_AES; + if (sess->cipher.key_length == 16) + sess->cipher.ut.aes_type = CCP_AES_TYPE_128; + else if (sess->cipher.key_length == 24) + sess->cipher.ut.aes_type = CCP_AES_TYPE_192; + else if (sess->cipher.key_length == 32) + sess->cipher.ut.aes_type = CCP_AES_TYPE_256; + else { + CCP_LOG_ERR("Invalid aead key length"); + return -1; + } + for (i = 0; i < sess->cipher.key_length; i++) + sess->cipher.key_ccp[sess->cipher.key_length - i - 1] = + sess->cipher.key[i]; + sess->auth.algo = CCP_AUTH_ALGO_AES_GCM; + sess->auth.engine = CCP_ENGINE_AES; + sess->auth.um.aes_mode = CCP_AES_MODE_GHASH; + sess->auth.ctx_len = CCP_SB_BYTES; + sess->auth.offset = 0; + sess->auth.block_size = AES_BLOCK_SIZE; + sess->cmd_id = CCP_CMD_COMBINED; + break; default: CCP_LOG_ERR("Unsupported aead algo"); return -ENOTSUP; } + sess->cipher.nonce_phys = rte_mem_virt2phy(sess->cipher.nonce); + sess->cipher.key_phys = rte_mem_virt2phy(sess->cipher.key_ccp); return 0; } @@ -447,10 +476,27 @@ ccp_aead_slot(struct ccp_session *session) int count = 0; switch (session->aead_algo) { + case RTE_CRYPTO_AEAD_AES_GCM: + break; default: CCP_LOG_ERR("Unsupported aead algo %d", session->aead_algo); } + switch (session->auth.algo) { + case CCP_AUTH_ALGO_AES_GCM: + count = 5; + /** + * 1. Passthru iv + * 2. Hash AAD + * 3. GCTR + * 4. Reload passthru + * 5. Hash Final tag + */ + break; + default: + CCP_LOG_ERR("Unsupported combined auth ALGO %d", + session->auth.algo); + } return count; } @@ -873,6 +919,179 @@ ccp_perform_3des(struct rte_crypto_op *op, return 0; } +static int +ccp_perform_aes_gcm(struct rte_crypto_op *op, struct ccp_queue *cmd_q) +{ + struct ccp_session *session; + union ccp_function function; + uint8_t *iv; + struct ccp_passthru pst; + struct ccp_desc *desc; + uint32_t tail; + uint64_t *temp; + phys_addr_t src_addr, dest_addr, key_addr, aad_addr; + phys_addr_t digest_dest_addr; + int length, non_align_len; + + session = (struct ccp_session *)get_session_private_data( + op->sym->session, + ccp_cryptodev_driver_id); + iv = rte_crypto_op_ctod_offset(op, uint8_t *, session->iv.offset); + key_addr = session->cipher.key_phys; + + src_addr = rte_pktmbuf_mtophys_offset(op->sym->m_src, + op->sym->aead.data.offset); + if (unlikely(op->sym->m_dst != NULL)) + dest_addr = rte_pktmbuf_mtophys_offset(op->sym->m_dst, + op->sym->aead.data.offset); + else + dest_addr = src_addr; + rte_pktmbuf_append(op->sym->m_src, session->auth.ctx_len); + digest_dest_addr = op->sym->aead.digest.phys_addr; + temp = (uint64_t *)(op->sym->aead.digest.data + AES_BLOCK_SIZE); + *temp++ = rte_bswap64(session->auth.aad_length << 3); + *temp = rte_bswap64(op->sym->aead.data.length << 3); + + non_align_len = op->sym->aead.data.length % AES_BLOCK_SIZE; + length = CCP_ALIGN(op->sym->aead.data.length, AES_BLOCK_SIZE); + + aad_addr = op->sym->aead.aad.phys_addr; + + /* CMD1 IV Passthru */ + rte_memcpy(session->cipher.nonce + AES_BLOCK_SIZE, iv, + session->iv.length); + pst.src_addr = session->cipher.nonce_phys; + pst.dest_addr = (phys_addr_t)(cmd_q->sb_iv * CCP_SB_BYTES); + pst.len = CCP_SB_BYTES; + pst.dir = 1; + pst.bit_mod = CCP_PASSTHRU_BITWISE_NOOP; + pst.byte_swap = CCP_PASSTHRU_BYTESWAP_NOOP; + ccp_perform_passthru(&pst, cmd_q); + + /* CMD2 GHASH-AAD */ + function.raw = 0; + CCP_AES_ENCRYPT(&function) = CCP_AES_MODE_GHASH_AAD; + CCP_AES_MODE(&function) = CCP_AES_MODE_GHASH; + CCP_AES_TYPE(&function) = session->cipher.ut.aes_type; + + desc = &cmd_q->qbase_desc[cmd_q->qidx]; + memset(desc, 0, Q_DESC_SIZE); + + CCP_CMD_ENGINE(desc) = CCP_ENGINE_AES; + CCP_CMD_INIT(desc) = 1; + CCP_CMD_FUNCTION(desc) = function.raw; + + CCP_CMD_LEN(desc) = session->auth.aad_length; + + CCP_CMD_SRC_LO(desc) = ((uint32_t)aad_addr); + CCP_CMD_SRC_HI(desc) = high32_value(aad_addr); + CCP_CMD_SRC_MEM(desc) = CCP_MEMTYPE_SYSTEM; + + CCP_CMD_KEY_LO(desc) = ((uint32_t)key_addr); + CCP_CMD_KEY_HI(desc) = high32_value(key_addr); + CCP_CMD_KEY_MEM(desc) = CCP_MEMTYPE_SYSTEM; + + CCP_CMD_LSB_ID(desc) = cmd_q->sb_iv; + + cmd_q->qidx = (cmd_q->qidx + 1) % COMMANDS_PER_QUEUE; + rte_wmb(); + + tail = (uint32_t)(cmd_q->qbase_phys_addr + cmd_q->qidx * Q_DESC_SIZE); + CCP_WRITE_REG(cmd_q->reg_base, CMD_Q_TAIL_LO_BASE, tail); + CCP_WRITE_REG(cmd_q->reg_base, CMD_Q_CONTROL_BASE, + cmd_q->qcontrol | CMD_Q_RUN); + + /* CMD3 : GCTR Plain text */ + function.raw = 0; + CCP_AES_ENCRYPT(&function) = session->cipher.dir; + CCP_AES_MODE(&function) = CCP_AES_MODE_GCTR; + CCP_AES_TYPE(&function) = session->cipher.ut.aes_type; + if (non_align_len == 0) + CCP_AES_SIZE(&function) = (AES_BLOCK_SIZE << 3) - 1; + else + CCP_AES_SIZE(&function) = (non_align_len << 3) - 1; + + + desc = &cmd_q->qbase_desc[cmd_q->qidx]; + memset(desc, 0, Q_DESC_SIZE); + + CCP_CMD_ENGINE(desc) = CCP_ENGINE_AES; + CCP_CMD_EOM(desc) = 1; + CCP_CMD_FUNCTION(desc) = function.raw; + + CCP_CMD_LEN(desc) = length; + + CCP_CMD_SRC_LO(desc) = ((uint32_t)src_addr); + CCP_CMD_SRC_HI(desc) = high32_value(src_addr); + CCP_CMD_SRC_MEM(desc) = CCP_MEMTYPE_SYSTEM; + + CCP_CMD_DST_LO(desc) = ((uint32_t)dest_addr); + CCP_CMD_DST_HI(desc) = high32_value(dest_addr); + CCP_CMD_SRC_MEM(desc) = CCP_MEMTYPE_SYSTEM; + + CCP_CMD_KEY_LO(desc) = ((uint32_t)key_addr); + CCP_CMD_KEY_HI(desc) = high32_value(key_addr); + CCP_CMD_KEY_MEM(desc) = CCP_MEMTYPE_SYSTEM; + + CCP_CMD_LSB_ID(desc) = cmd_q->sb_iv; + + cmd_q->qidx = (cmd_q->qidx + 1) % COMMANDS_PER_QUEUE; + rte_wmb(); + + tail = (uint32_t)(cmd_q->qbase_phys_addr + cmd_q->qidx * Q_DESC_SIZE); + CCP_WRITE_REG(cmd_q->reg_base, CMD_Q_TAIL_LO_BASE, tail); + CCP_WRITE_REG(cmd_q->reg_base, CMD_Q_CONTROL_BASE, + cmd_q->qcontrol | CMD_Q_RUN); + + /* CMD4 : PT to copy IV */ + pst.src_addr = session->cipher.nonce_phys; + pst.dest_addr = (phys_addr_t)(cmd_q->sb_iv * CCP_SB_BYTES); + pst.len = AES_BLOCK_SIZE; + pst.dir = 1; + pst.bit_mod = CCP_PASSTHRU_BITWISE_NOOP; + pst.byte_swap = CCP_PASSTHRU_BYTESWAP_NOOP; + ccp_perform_passthru(&pst, cmd_q); + + /* CMD5 : GHASH-Final */ + function.raw = 0; + CCP_AES_ENCRYPT(&function) = CCP_AES_MODE_GHASH_FINAL; + CCP_AES_MODE(&function) = CCP_AES_MODE_GHASH; + CCP_AES_TYPE(&function) = session->cipher.ut.aes_type; + + desc = &cmd_q->qbase_desc[cmd_q->qidx]; + memset(desc, 0, Q_DESC_SIZE); + + CCP_CMD_ENGINE(desc) = CCP_ENGINE_AES; + CCP_CMD_FUNCTION(desc) = function.raw; + /* Last block (AAD_len || PT_len)*/ + CCP_CMD_LEN(desc) = AES_BLOCK_SIZE; + + CCP_CMD_SRC_LO(desc) = ((uint32_t)digest_dest_addr + AES_BLOCK_SIZE); + CCP_CMD_SRC_HI(desc) = high32_value(digest_dest_addr + AES_BLOCK_SIZE); + CCP_CMD_SRC_MEM(desc) = CCP_MEMTYPE_SYSTEM; + + CCP_CMD_DST_LO(desc) = ((uint32_t)digest_dest_addr); + CCP_CMD_DST_HI(desc) = high32_value(digest_dest_addr); + CCP_CMD_SRC_MEM(desc) = CCP_MEMTYPE_SYSTEM; + + CCP_CMD_KEY_LO(desc) = ((uint32_t)key_addr); + CCP_CMD_KEY_HI(desc) = high32_value(key_addr); + CCP_CMD_KEY_MEM(desc) = CCP_MEMTYPE_SYSTEM; + + CCP_CMD_LSB_ID(desc) = cmd_q->sb_iv; + + cmd_q->qidx = (cmd_q->qidx + 1) % COMMANDS_PER_QUEUE; + rte_wmb(); + + tail = (uint32_t)(cmd_q->qbase_phys_addr + cmd_q->qidx * Q_DESC_SIZE); + CCP_WRITE_REG(cmd_q->reg_base, CMD_Q_TAIL_LO_BASE, tail); + CCP_WRITE_REG(cmd_q->reg_base, CMD_Q_CONTROL_BASE, + cmd_q->qcontrol | CMD_Q_RUN); + + op->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED; + return 0; +} + static inline int ccp_crypto_cipher(struct rte_crypto_op *op, struct ccp_queue *cmd_q, @@ -939,17 +1158,25 @@ ccp_crypto_auth(struct rte_crypto_op *op, static inline int ccp_crypto_aead(struct rte_crypto_op *op, - struct ccp_queue *cmd_q __rte_unused, - struct ccp_batch_info *b_info __rte_unused) + struct ccp_queue *cmd_q, + struct ccp_batch_info *b_info) { int result = 0; struct ccp_session *session; session = (struct ccp_session *)get_session_private_data( - op->sym->session, + op->sym->session, ccp_cryptodev_driver_id); - switch (session->aead_algo) { + switch (session->auth.algo) { + case CCP_AUTH_ALGO_AES_GCM: + if (session->cipher.algo != CCP_CIPHER_ALGO_AES_GCM) { + CCP_LOG_ERR("Incorrect chain order"); + return -1; + } + result = ccp_perform_aes_gcm(op, cmd_q); + b_info->desccnt += 5; + break; default: CCP_LOG_ERR("Unsupported aead algo %d", session->aead_algo); diff --git a/drivers/crypto/ccp/ccp_pmd_ops.c b/drivers/crypto/ccp/ccp_pmd_ops.c index 1fb6a6d..24f577a 100644 --- a/drivers/crypto/ccp/ccp_pmd_ops.c +++ b/drivers/crypto/ccp/ccp_pmd_ops.c @@ -139,6 +139,36 @@ static const struct rte_cryptodev_capabilities ccp_pmd_capabilities[] = { }, } }, } }, + { /* AES GCM */ + .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, + {.sym = { + .xform_type = RTE_CRYPTO_SYM_XFORM_AEAD, + {.aead = { + .algo = RTE_CRYPTO_AEAD_AES_GCM, + .block_size = 16, + .key_size = { + .min = 16, + .max = 32, + .increment = 8 + }, + .digest_size = { + .min = 16, + .max = 16, + .increment = 0 + }, + .aad_size = { + .min = 0, + .max = 65535, + .increment = 1 + }, + .iv_size = { + .min = 12, + .max = 16, + .increment = 4 + }, + }, } + }, } + }, RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST() }; -- 2.7.4