From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0050.outbound.protection.outlook.com [104.47.42.50]) by dpdk.org (Postfix) with ESMTP id 213CC1B219 for ; Wed, 10 Jan 2018 10:43:42 +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=iGrJKx3RdnbwsOblofGUoqvir2UyocqoLzE0qxTYI7w=; b=Bp7KdAfu+l1UcjIMvQfWvxbBVV6KS6Fci3SwzaN977xyOMBbqIEMwHX+mdNAsDEl7BDFefsQaN1UUJ92chvRJ4yOn68W2ZQzyYSVvEhOR2+b14vTqRchwa2Ea9xD0D2uwTPXkBmaJftGssSXnhBpOA7lBzbvJX8teCW0IbcXUYU= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Ravi1.Kumar@amd.com; Received: from wallaby-smavila.amd.com (202.56.249.162) by CY4PR12MB1509.namprd12.prod.outlook.com (10.172.68.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.386.5; Wed, 10 Jan 2018 09:43:39 +0000 From: Ravi Kumar To: dev@dpdk.org Cc: pablo.de.lara.guarch@intel.com Date: Wed, 10 Jan 2018 04:42:53 -0500 Message-Id: <1515577379-18453-13-git-send-email-Ravi1.kumar@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515577379-18453-1-git-send-email-Ravi1.kumar@amd.com> References: <1515145198-97367-1-git-send-email-Ravi1.kumar@amd.com> <1515577379-18453-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: MAXPR0101CA0024.INDPRD01.PROD.OUTLOOK.COM (10.174.62.34) To CY4PR12MB1509.namprd12.prod.outlook.com (10.172.68.22) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 5b469f8e-6e3f-4a31-42b9-08d5580ea159 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020049)(4652020)(48565401081)(5600026)(4604075)(2017052603307)(7153060)(7193020); SRVR:CY4PR12MB1509; X-Microsoft-Exchange-Diagnostics: 1; CY4PR12MB1509; 3:cs0XCK4Lq0msHJ0dDF7OTngzdzcbnHnDoZZ4y80qg61AVsA86mPHI4szCKqpGgWqtDQFUNgwfJf/THNwOSxcWInod2XX5YrzLs2fgdnDFcwW2P96ub7u8JSH8sfOw/Ltp21IiZrGw8SMO6iQ/A30jsaS2w5gZXWtj5mBsU2kkzKV1dD2pFDixuo5WsWTOIaMFx4+x0N8SbIo+rLElIC+Os2YWs/TSXXDRD2RoyXsp3/YteFmjDBNODkDIEu/k1rM; 25:kL4IbICDoO3nbWKiKhBx69CWW7itvbWDW0fTt8XaJvaCXWnqQ4EcaA12qXwYO49GpWVuf1c+I8leXI+sy0S7JINQbUhftLTk9QsQJv02bAJzIbdAacUjKlAz3N0l+6C0ii47SAhr1lKOHcOmdLQOZ9CEMVfgSZEmVRyZr3oeOtO0hoanKo4lqniM/UKAtYN8mAhvEP1NN/FI4G5kH97dpqR2XdjqfMuExtmn0BSWn6F/1s6t4gMDERud3P2Rz2+0d0Plv2cSLcrk9kLGKAxbUJzZy7DL3vhadNZ8r+syGdcJSCgxHPimw5EsN5T9g0t+CBKXJpA1B0Thje/23NIjCA==; 31:urhDH2pLQVbO98faewvEhKM672eXsO/0hCICQvs7gkOtN9Cnh5fiiDXXYsQHegrAstE0VdMSlpKEmOq5p7IxMknhmUeO8XONbgbr5IumfM77d0kVJbmaDRIj1BnuGGBEMdyIkvAIuST7mAnrEObB7z2ocrGI8LLXLmkBpUu/58YGz4QSTQtOS/xtn0ERQAykZka68jucmC5GD3O5HZnRx6kBST3IKXBXUpU/owf4TnM= X-MS-TrafficTypeDiagnostic: CY4PR12MB1509: X-Microsoft-Exchange-Diagnostics: 1; CY4PR12MB1509; 20:0dPLZ2moi5rhG9yefRxIYX39VoVt57QTzQPV+Ct00hVFLTkViD3zcZQcLnWpQzGRnZQaJOC6dKPMBvNauTrydMc2UZVU6d2u8YV9oriI6gH60Njc4aOJGiimZ8aN4iNuZyYQEikVcC3AtXzawd2rSo4dh1v5Vv5A4AGUlSC02uJAuQidZyuYTowb94tGCW10kQlY39WRG7uvaFG0/AMebE1a1nXjT/6wiE9YrGihdCl1zWVyZQ6GmJvx43BPYj+ud1yzh5IjxmiID5+QowoZvYiZpUvoC04kpp14eQY1I2+uIA+ph7/qY6/mXIAXAcd2P0BY6x4al4pfJy1RgWkjsSq8c+sgGX4ndzvYK+CstTmDYJ24g3X4dn69IBSsibu3PSSFpFjTAhidYTUUA4TDGqxV8nMPD44FLrB4pkJ2C9UczjMaIfrSgNTNUhmfZAtbcyPV0IDzbP2fk49dnDAO9tu4ggntn6QjhRpufQPNgaTDJpIrIdK2DPs5EL8/D3wA; 4:0TSSXAMqKSX9/Md+ckTzvXqK1BmdowvElS8ffbKedIk3CzbmEEU31W5bz8kEKTuzD8Ai2hSPPJ3HoiY1M7EfFfAQ8KABo6c58bnpHfhQFx7mmOmeRLnQzb4I2pwk1LIEVuJ2TZnXKliYXIWOgDxiY8CM52cmXodCE/m2/OagU/TnOaMssVTRpvrXVLUSSLBsnDN2achB3vOnq+aDMHyxV7+3pfeuE2XnTqUOfhRvU4DOIMdFBj14va5nLhPlrZf3iIm16DhRSQvFYhe3RLVATaC2csALaLW5mcOZ59dwOJ8En6sNYfxjySVjhGju81pI X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(8121501046)(5005006)(93006095)(93001095)(3002001)(10201501046)(3231023)(944501119)(6055026)(6041268)(20161123562045)(20161123558120)(20161123560045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:CY4PR12MB1509; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:CY4PR12MB1509; X-Forefront-PRVS: 0548586081 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(366004)(39860400002)(396003)(346002)(376002)(39380400002)(189003)(199004)(25786009)(8676002)(81166006)(47776003)(48376002)(6666003)(2950100002)(81156014)(6916009)(66066001)(50226002)(68736007)(36756003)(8936002)(16586007)(72206003)(50466002)(16526018)(316002)(53936002)(478600001)(5660300001)(86362001)(4326008)(386003)(2361001)(2351001)(6486002)(53416004)(97736004)(51416003)(76176011)(106356001)(105586002)(7736002)(6116002)(3846002)(2906002)(59450400001)(305945005)(7696005)(52116002); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR12MB1509; H:wallaby-smavila.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A: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; CY4PR12MB1509; 23:rXRGGCySBY3mU5EVUUeTKjzTDpPgJtFy5Kg1FhgHK?= =?us-ascii?Q?a+L4msZAtKFCkUjctvrpEA0q5LzAy5i+IUmDbnRsLKn1B11BlLGyGx05T1bs?= =?us-ascii?Q?oWSipx0iKI/Uo3gR49z90h/yHQiu4iaHldqDGL4pi4ww4dOF36ZRw2VjsjeQ?= =?us-ascii?Q?yXLwYucIF88+wisVI1kh/abtSVrAloNZyC9wIjHZRbMtfbs2OPY0r2xqql42?= =?us-ascii?Q?vsh64BjPGm2s2hQswUPzQ8iZA9K6B8dZ7Ub8wRlEwsYe+9esyFYcR3CQekPN?= =?us-ascii?Q?ratkOTQXmC+4XITclD1GRqGhPRc0kt9lA3TY3n6xV8NXWjrdkykvE60THSXW?= =?us-ascii?Q?r0A3uMvUBwC1d0zMJuRoEi6dSAaV68lKEV/ztRA6EpnA2P0G+W9cQEahlhsD?= =?us-ascii?Q?Uk/aCiuCJbuVG6UmirZmfJpPbsKw5WwuiSGunKfSP3vtZTFm9gT22AD1KD/0?= =?us-ascii?Q?WXnoiIpVBB3050azAsq0e3hbe3dP/Y0676N3eSa/kLO8wXJzLe5Chp/QwtSX?= =?us-ascii?Q?n9V8Hn5norgRE2jiFSS//N6oOJCKfePioK7KrI+VNqoatsFuFPjDNTL9BbGD?= =?us-ascii?Q?ygdG74wGnf59v06OolGsK78NmYpJqgqMZmu+eBUJB/YQlbviAEOQ+yxgI5yn?= =?us-ascii?Q?ZpL87KLZE3DiT8PnovqvdWlgP0sib/f+Da1pRRG3Oi1RN8yYrzr2ks5xuq24?= =?us-ascii?Q?XCKSEdF5peBZh8Fkxas3E7/aa3uv4nNriEZxjmWzQRrI2wAE7m6/7J5YbSxC?= =?us-ascii?Q?ezSXouwUCZkE7RvTdXj72xLe7UCvQmA5S38d6/7p8h+RYJ1RLSVs4EW5XiTk?= =?us-ascii?Q?brbfWdvDYWvzAXnnl6Mq+6nUTTR+iIqm/Dj0MXK+sVpdakFKal3YnpBdCijg?= =?us-ascii?Q?AckhtisQ6UqeeD0zeXBUW6abi5IcPGyRielGqxUtxBRLzllESRzOiJrPFUo2?= =?us-ascii?Q?XR2VFZh/eE1qlWPPsolCyHTk/vzWUVrtaWptiInmtwWvm9ZWJtP34TdXOBOk?= =?us-ascii?Q?zTmfCcQsewHG7TE5EfgPlMNNn0XwNm3khHLOMNLMA6e+nhfXBdp/ZCR114tW?= =?us-ascii?Q?gucvyA8npnAq3eBh3+qHB/wJUZuioTG/oAKNgVp5whgUK2rundEdCGBsh2AR?= =?us-ascii?Q?f1a2pvxBhdltOs5P1Ia0izabWnwLYarvdd/qm0uiZGd77jWsexl1A=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; CY4PR12MB1509; 6:7Hl0OJRBGWy69IeNhtaoL9QeIIr6gcn53tfErNNTsDNI/htTy4TBOCFln3wKaqSUbUKvTmtsorJXtleO5rg7lzRF4d7tKvVTtImMc+pEO8SielHOi6ZgIdoADTB0oElRh/zHUcNrQz+3adQwdWf4S11GU+DMNtJUHcxlIWKpctnsSL7jzdV57gQizIDfCylIMo+G+qg4GFUVXqRYwWM/0HSr71+5hg8Yd/X3b7yM6blqHyGe0zYhlC/7mpQDpmph1wDfbxUZ+4pfxeOKObQWY+imEzAAENnsOtOP/dKZcmPJR7FUWWYU6Sz1JhUFV32tesB3UeKQK5QbcWQg9UXi+9rtQkiLF/sFCWaKXsDP5OA=; 5:+x4q3cfkJlC9bE50FQUtzMY2h3uNZwcYAhES79yZ3yjhiBOZ9Te6q+Mn0yw1aLujk3Nelzdmlno7fzKtojRSLhEPWjDPxOh1TGmb3WqN+anfB+5OUWlCvtf+KBFa9AYMdJapACrbn3ujUu7n29yNlBDYRv/GMpR474qSH/JyWwU=; 24:nk5zKCxAdXDskVvLBQSKF0LSaypvtyLGV4hjjIdH0PE1F68FuGoIOIv6SwG/b+snB4rHvydOw7AvF3rnRaZ5ZxTA8/kXExP0gqgjMP178eo=; 7:CziXfEx6CO5f1C4+jo6RvbOvKHPTjMz+jBJK/iQKvRAkIL8PfmrG9x5a6Sv8WVVPSBWlsiBLBllTI7YY06X2mygSk09VIdPMImpRxLPOsXlnd/0NC4/PMHGEBoub61d/gqMiH8lwm/tb2kn3NeqrAPCTniSFEeznJGZzStvo2CQ/sWdk/YjG9QHrXbapjYvE3GHpA8DgKJHa89Bx+DFIkd/1RG4FwXl85QH3b3m8mQ70l6CLyv4ANUKDkBUFLKm1 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY4PR12MB1509; 20:CaenmRFu6uqeXIPRSgLZz9CmniC+5dOb0RO+FB/gpPD+tFPWQx2GA7kD+PVZwr3o1JMW5+aByRkwnfJdSbJMstp3Fp2dZt5BQ+W7FGoly4cDvnRGLT9JT56H6MQBxvQ6bJF/p6nNk6dD1XgCPoc+5mRRgBxOLDf88sW90WrnmP+q6QNDauaWA2UMXulci4bzxdwEuqJRnTk69CcfeIW8XO8m8el2UV10jOsZ4D7HhN7mhxIN67wOrzMH0dcftoM3 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jan 2018 09:43:39.3342 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5b469f8e-6e3f-4a31-42b9-08d5580ea159 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1509 Subject: [dpdk-dev] [PATCH v3 13/19] 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: Wed, 10 Jan 2018 09:43:42 -0000 Signed-off-by: Ravi Kumar --- drivers/crypto/ccp/ccp_crypto.c | 240 ++++++++++++++++++++++++++++++++++++++- drivers/crypto/ccp/ccp_pmd_ops.c | 30 +++++ 2 files changed, 266 insertions(+), 4 deletions(-) diff --git a/drivers/crypto/ccp/ccp_crypto.c b/drivers/crypto/ccp/ccp_crypto.c index 6e593d8..4ced193 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,184 @@ 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 *lsb_buf, *append_ptr, *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, i; + + 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 = rte_mem_virt2phy(session->cipher.key_ccp); + + src_addr = rte_pktmbuf_mtophys_offset(op->sym->m_src, + op->sym->cipher.data.offset); + if (unlikely(op->sym->m_dst != NULL)) + dest_addr = rte_pktmbuf_mtophys_offset(op->sym->m_dst, + op->sym->cipher.data.offset); + else + dest_addr = src_addr; + append_ptr = (uint8_t *)rte_pktmbuf_append(op->sym->m_src, + session->auth.ctx_len); + digest_dest_addr = (phys_addr_t)rte_mem_virt2phy((void *)append_ptr); + append_ptr += AES_BLOCK_SIZE; + temp = (uint64_t *)append_ptr; + *temp++ = rte_bswap64(session->auth.aad_length << 3); + *temp = rte_bswap64(op->sym->cipher.data.length << 3); + + non_align_len = op->sym->cipher.data.length % AES_BLOCK_SIZE; + length = CCP_ALIGN(op->sym->cipher.data.length, AES_BLOCK_SIZE); + + aad_addr = rte_mem_virt2phy((void *)op->sym->aead.aad.data); + + /* CMD1 IV Passthru */ + for (i = 0; i < CTR_IV_SIZE; i++) + session->cipher.nonce[CTR_NONCE_SIZE + CTR_IV_SIZE - 1 - i] = + iv[i]; + lsb_buf = session->cipher.nonce; + + pst.src_addr = (phys_addr_t)rte_mem_virt2phy((void *) lsb_buf); + 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 = (phys_addr_t)rte_mem_virt2phy((void *) lsb_buf); + 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 +1163,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