From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8257BA0547; Sun, 17 Oct 2021 18:22:52 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CA50340DF7; Sun, 17 Oct 2021 18:21:53 +0200 (CEST) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60081.outbound.protection.outlook.com [40.107.6.81]) by mails.dpdk.org (Postfix) with ESMTP id 12C914114D for ; Sun, 17 Oct 2021 18:21:51 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BPuep8zf3F+7XHw7ftkCZIBmZSvS1sJrRJCGdEqEFmK9dwxnQA7eSavjyjcK5P4nZZ6DiVhpO1k+fUCt2EaaJL2BKQVP5VSF9Uue/mTTOS1letOEtnNuYkwf4HgT2diRqIk1W7EXcEbqEyY9wFum4gHcDjrc+qbdCqZHWT20V8McIEo4TAKMy7cv5Eb/5ts3TBwMR4cuAcQGW11/JUU+9nH2PIbTgWtTglFEhrcmRK0CH+YoWI0VDPrj8NR29Ck746B0DnwBMPl0vPgIEyreNL+HN9JF7+FNi9RgvMM2fe/UqzIDz+jlfv0S5vs4Hy/UyHZNYaXy4PDUqlO3A6G7Dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=gZF9HvvJlmtT/G/a1as9QOFYMcXCFjtfKaHS1PryomE=; b=WYdLGpHC33UfwtnJKwe4OGW4BnMt7HfNTGlR0h1tqrk9+y29sx2E5bi9VDbMtxYm8TuemE/etdvPn3UbAbYDcum2P2L0JPif9CDSa23s7UNWrzzc5PVSCAd7YdjhpjwiF5NSM28I/RK8WNe42KUT2GCsgiYIAsHMgwLeCJUgnbVjyhgwK2DHeLG6ddvflz9bePtFd47vrUq5TaKRhfHI4K8FBSAbB0xHqmoDYmplZ5077MncTzmcNJO5ruttVf8FwSeCZS790SUA/1+hhlcGFKFQwuENhuiEY2g4kzYATcPXynOlVBFoh8Vkv1fCE+ZOVGiDtw2G9fuySgeOZ07fxQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gZF9HvvJlmtT/G/a1as9QOFYMcXCFjtfKaHS1PryomE=; b=lK20fpBexSWIRbE2Q/kqD/wSjT0udZJdWdVD02KlabYl6jNgu3XaChzxZaq2SOH++Usw3izjMcYHIRht96bHo7xJnNKnrmJNBKt6IHwjSqUjkqCyrpXPAcPYl6mOJ5bAxT00WDazmgemgVwsMb7WWVjTiF/0zdeMxLjy8J41WHg= Authentication-Results: dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=none action=none header.from=nxp.com; Received: from DU2PR04MB8630.eurprd04.prod.outlook.com (2603:10a6:10:2dd::15) by DU2PR04MB8615.eurprd04.prod.outlook.com (2603:10a6:10:2da::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.15; Sun, 17 Oct 2021 16:21:50 +0000 Received: from DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::945d:e362:712d:1b80]) by DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::945d:e362:712d:1b80%3]) with mapi id 15.20.4608.018; Sun, 17 Oct 2021 16:21:50 +0000 From: Hemant Agrawal To: dev@dpdk.org, gakhil@marvell.com Cc: konstantin.ananyev@intel.com, roy.fan.zhang@intel.com, Gagandeep Singh Date: Sun, 17 Oct 2021 21:46:48 +0530 Message-Id: <20211017161651.9220-13-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211017161651.9220-1-hemant.agrawal@nxp.com> References: <20211013190032.2308-1-hemant.agrawal@nxp.com> <20211017161651.9220-1-hemant.agrawal@nxp.com> Content-Type: text/plain X-ClientProxiedBy: SI2PR01CA0053.apcprd01.prod.exchangelabs.com (2603:1096:4:193::7) To DU2PR04MB8630.eurprd04.prod.outlook.com (2603:10a6:10:2dd::15) MIME-Version: 1.0 Received: from dpdk-xeon.ap.freescale.net (92.120.0.67) by SI2PR01CA0053.apcprd01.prod.exchangelabs.com (2603:1096:4:193::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.15 via Frontend Transport; Sun, 17 Oct 2021 16:21:48 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f620b167-c428-44af-b51b-08d9918a392c X-MS-TrafficTypeDiagnostic: DU2PR04MB8615: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1443; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5djg6JGdEUaVKgbRYEdI2B4sT8YaUE72X2smH9T3TD9JTXgTMBFKb2ht5eL6TsZWCCiDshRgZYtlEhIMpnttuF6Rv7bhJ165eGfWmYo3sJoGMzrUtIP4Fi8bJsrp9YjQQ8JyhqaKNVTFQ1lvzOner0LmQCkqq4xCW1LN27aB9Xyljra7WcZHI7yrl5FmpVHHoXt9AG9SaWml0pAJxQysMgDdNS8zCZRgqGefSifQsGVw3TIwVfCGQ91PTIEo75MxWcbfvB5D+gscgQL1MXyqaXbnGutq1IDd3fecwIqjOz0J8c2ynQWtKzjj2+n85HqB93uCykBHjkHVh6z+akD3rVmhlydFmONvlujjjBluijZJ6g54HNdNDojW03tgwZcLib0VQPlebxzymYWEWPRiU4m+olRd6Uf6COh8nW6x57AK7ZQRPl83AZ/a4JbQ55pXLCoEnI3ctLLfdKHgZMFOg2Kt7iU9Bh1ibaByN+wnGdaQpSUb6Gs4C+TerIdG4Ds5PZLX/l1thwUzEHeNBlZU9hbVIk3lkPzbb362VnhAjRkCjJFFSCWXNkc3bTemLk07kz7CrYTjszZk4PFoQ78GRrbNix/7gOoc0dBSYbxdgrpK3o5+U4vfBTEtxy3GhYzsNGh0qQFX1KCoX/pf1qZQnn8RBdJJztmeBMO0c9SuTDJe0K3u9ON/QFn4tn7B9C7qGFe9avaaoCPi45WaWQxW2w== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DU2PR04MB8630.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(6486002)(66476007)(8936002)(66556008)(66946007)(86362001)(52116002)(36756003)(5660300002)(38350700002)(8676002)(38100700002)(508600001)(6506007)(26005)(44832011)(4326008)(6512007)(2616005)(83380400001)(1076003)(2906002)(316002)(186003)(956004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?46wajNb/vTC7ZigjNjP54QUrfZXRrTGEBkowsmDJZLVwR4Xlqz/hYnGUgx1t?= =?us-ascii?Q?ovdY09BOVsYZyDNjkn5GjR7AGyjGZB3CedJdBiQfrBvVUMSoGZLLyaqg4F2d?= =?us-ascii?Q?liexmL19ZmtedelLp88RYsU3rB4zTDzU5+bHKw1UZmvO+IXkEsAuA/cAomqD?= =?us-ascii?Q?Qd4QS7NDGvpoNQNsHnHyDbQd08DfUdB28MfEjCH5fWF3FlL3PA0FQc233ZGq?= =?us-ascii?Q?n49LtNJ/UmHOqFv1gcv9UDWUv1y33S8E8mrOoTFwCCd0YzH6T4VHOsTVwuvQ?= =?us-ascii?Q?RUfxjqgshSjISDd7CGPE1mJMPHyT5wiEx0yGmNwfFbXPoidQh4PrijOxvkOn?= =?us-ascii?Q?WXxXnpfG5waLqJrV69Ej5Te1dk6+kT9ZO9rPRSAu2LWWu0rZBDJDBZARE9x1?= =?us-ascii?Q?OtcVwhR+D0nBKyPHx7vx4y02LSibB+03QreQeMDbyPCQ/CGtM1p1LDbLCii/?= =?us-ascii?Q?1zoW+5dn6avzwvY9lqbkEqNuMKch6nlROVWrg74va4vkh2BXEYRjhIbIHfbq?= =?us-ascii?Q?AZ0uXieu2uONvXoovNM1WlrLHcNejO9sOrIluJUPOQ0CgO6zS9pveLrJyAN2?= =?us-ascii?Q?U8Pyvzub9JBoT7DntmLjPQQR7qDe4l7dk/AIXcJx581vghBD3Rgkjf5Og91J?= =?us-ascii?Q?zNel/qjzpoEuHEUQDU03x3siHvh7lILHUYNQ/Jy2yoEa2wfEPDaGo4QsM7WX?= =?us-ascii?Q?Fdr4r3GCtJDcC/PIMefLIl4OZKFL7ugKkaTut/r4uGnaZBkaZ7vEGISlxV6+?= =?us-ascii?Q?Z649R7oYY8EoIhhlLiahcXVqwsNx6bftkqZrfZcdyjZjnc2cwWhLCTErstS/?= =?us-ascii?Q?pvrWdlOvGrOZ/r7u4RJbVp0F4hG4KYvs7XKBsvlH2bHjIn/RiArCrIHRsggY?= =?us-ascii?Q?OUQtjF9KUc6HzABMgZuDApZvPUgWluPO/VqKEyIR1Ff4gZeaoiOTaJ7AbRKJ?= =?us-ascii?Q?4Z1F6EL8Aet5oHZrk30PsTnpl1VJSqOzVnk2U+/q5kCf7Jqwl+uxMguc2NcM?= =?us-ascii?Q?4brzz+NB+8bYmx8aOt6mPzHDkM6g6JohBTWiG63VkWHsIKci/yvGjdI+wSNk?= =?us-ascii?Q?cE31jYfO2McXWnSkpkCWlfvSOArT+deYxTL1VVRSDkhsZnNDXPTjjeQwyZ9z?= =?us-ascii?Q?3aMMK/2wEN3Ta+pl1PDBkRJ7ukOOsjgCDUUbGdZNqCVmS8tJUN25Lv+35iUR?= =?us-ascii?Q?tqS4H+An0bZumdHUcM4jVAy6THKVyhBkebXVMNx0b9gYAXCTKN/G4z0TrvCN?= =?us-ascii?Q?CrZ97MFq1zSntvlAvQ0/mL0LnNutyBVBZ2Q/qsKsGdJosNy0vrxw1vQ5+YTr?= =?us-ascii?Q?W28YXJqGNrlJWHsT53GNWCjL?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f620b167-c428-44af-b51b-08d9918a392c X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8630.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2021 16:21:50.2233 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: pZpD0rRJaOpMey5gB2f4mS7lytrMFM/AwiAumVLlD6IJwGhXg8a2k1k25Z4bUROj/pfS9OJbNNAXSIE8PYMmSg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8615 Subject: [dpdk-dev] [PATCH v5 12/15] crypto/dpaa_sec: support authonly and chain with raw APIs X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Gagandeep Singh This patch improves the raw vector support in dpaa_sec driver for authonly and chain usecase. Signed-off-by: Gagandeep Singh --- drivers/crypto/dpaa_sec/dpaa_sec.h | 3 +- drivers/crypto/dpaa_sec/dpaa_sec_raw_dp.c | 296 +++++++++++++++++++++- 2 files changed, 287 insertions(+), 12 deletions(-) diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.h b/drivers/crypto/dpaa_sec/dpaa_sec.h index 77288cd1eb..7890687828 100644 --- a/drivers/crypto/dpaa_sec/dpaa_sec.h +++ b/drivers/crypto/dpaa_sec/dpaa_sec.h @@ -135,7 +135,8 @@ typedef struct dpaa_sec_job* (*dpaa_sec_build_raw_dp_fd_t)(uint8_t *drv_ctx, struct rte_crypto_va_iova_ptr *digest, struct rte_crypto_va_iova_ptr *auth_iv, union rte_crypto_sym_ofs ofs, - void *userdata); + void *userdata, + struct qm_fd *fd); typedef struct dpaa_sec_session_entry { struct sec_cdb cdb; /**< cmd block associated with qp */ diff --git a/drivers/crypto/dpaa_sec/dpaa_sec_raw_dp.c b/drivers/crypto/dpaa_sec/dpaa_sec_raw_dp.c index 7376da4cbc..03ce21e53f 100644 --- a/drivers/crypto/dpaa_sec/dpaa_sec_raw_dp.c +++ b/drivers/crypto/dpaa_sec/dpaa_sec_raw_dp.c @@ -12,6 +12,7 @@ #endif /* RTA header files */ +#include #include #include @@ -26,6 +27,17 @@ struct dpaa_sec_raw_dp_ctx { uint16_t cached_dequeue; }; +static inline int +is_encode(dpaa_sec_session *ses) +{ + return ses->dir == DIR_ENC; +} + +static inline int is_decode(dpaa_sec_session *ses) +{ + return ses->dir == DIR_DEC; +} + static __rte_always_inline int dpaa_sec_raw_enqueue_done(void *qp_data, uint8_t *drv_ctx, uint32_t n) { @@ -82,18 +94,276 @@ build_dpaa_raw_dp_auth_fd(uint8_t *drv_ctx, struct rte_crypto_va_iova_ptr *digest, struct rte_crypto_va_iova_ptr *auth_iv, union rte_crypto_sym_ofs ofs, - void *userdata) + void *userdata, + struct qm_fd *fd) { - RTE_SET_USED(drv_ctx); - RTE_SET_USED(sgl); RTE_SET_USED(dest_sgl); RTE_SET_USED(iv); - RTE_SET_USED(digest); RTE_SET_USED(auth_iv); - RTE_SET_USED(ofs); - RTE_SET_USED(userdata); + RTE_SET_USED(fd); - return NULL; + dpaa_sec_session *ses = + ((struct dpaa_sec_raw_dp_ctx *)drv_ctx)->session; + struct dpaa_sec_job *cf; + struct dpaa_sec_op_ctx *ctx; + struct qm_sg_entry *sg, *out_sg, *in_sg; + phys_addr_t start_addr; + uint8_t *old_digest, extra_segs; + int data_len, data_offset, total_len = 0; + unsigned int i; + + for (i = 0; i < sgl->num; i++) + total_len += sgl->vec[i].len; + + data_len = total_len - ofs.ofs.auth.head - ofs.ofs.auth.tail; + data_offset = ofs.ofs.auth.head; + + /* Support only length in bits for SNOW3G and ZUC */ + + if (is_decode(ses)) + extra_segs = 3; + else + extra_segs = 2; + + if (sgl->num > MAX_SG_ENTRIES) { + DPAA_SEC_DP_ERR("Auth: Max sec segs supported is %d", + MAX_SG_ENTRIES); + return NULL; + } + ctx = dpaa_sec_alloc_raw_ctx(ses, sgl->num * 2 + extra_segs); + if (!ctx) + return NULL; + + cf = &ctx->job; + ctx->userdata = (void *)userdata; + old_digest = ctx->digest; + + /* output */ + out_sg = &cf->sg[0]; + qm_sg_entry_set64(out_sg, digest->iova); + out_sg->length = ses->digest_length; + cpu_to_hw_sg(out_sg); + + /* input */ + in_sg = &cf->sg[1]; + /* need to extend the input to a compound frame */ + in_sg->extension = 1; + in_sg->final = 1; + in_sg->length = data_len; + qm_sg_entry_set64(in_sg, rte_dpaa_mem_vtop(&cf->sg[2])); + + /* 1st seg */ + sg = in_sg + 1; + + if (ses->iv.length) { + uint8_t *iv_ptr; + + iv_ptr = rte_crypto_op_ctod_offset(userdata, uint8_t *, + ses->iv.offset); + + if (ses->auth_alg == RTE_CRYPTO_AUTH_SNOW3G_UIA2) { + iv_ptr = conv_to_snow_f9_iv(iv_ptr); + sg->length = 12; + } else if (ses->auth_alg == RTE_CRYPTO_AUTH_ZUC_EIA3) { + iv_ptr = conv_to_zuc_eia_iv(iv_ptr); + sg->length = 8; + } else { + sg->length = ses->iv.length; + } + qm_sg_entry_set64(sg, rte_dpaa_mem_vtop(iv_ptr)); + in_sg->length += sg->length; + cpu_to_hw_sg(sg); + sg++; + } + + qm_sg_entry_set64(sg, sgl->vec[0].iova); + sg->offset = data_offset; + + if (data_len <= (int)(sgl->vec[0].len - data_offset)) { + sg->length = data_len; + } else { + sg->length = sgl->vec[0].len - data_offset; + + /* remaining i/p segs */ + for (i = 1; i < sgl->num; i++) { + cpu_to_hw_sg(sg); + sg++; + qm_sg_entry_set64(sg, sgl->vec[i].iova); + if (data_len > (int)sgl->vec[i].len) + sg->length = sgl->vec[0].len; + else + sg->length = data_len; + + data_len = data_len - sg->length; + if (data_len < 1) + break; + } + } + + if (is_decode(ses)) { + /* Digest verification case */ + cpu_to_hw_sg(sg); + sg++; + rte_memcpy(old_digest, digest->va, + ses->digest_length); + start_addr = rte_dpaa_mem_vtop(old_digest); + qm_sg_entry_set64(sg, start_addr); + sg->length = ses->digest_length; + in_sg->length += ses->digest_length; + } + sg->final = 1; + cpu_to_hw_sg(sg); + cpu_to_hw_sg(in_sg); + + return cf; +} + +static inline struct dpaa_sec_job * +build_dpaa_raw_dp_chain_fd(uint8_t *drv_ctx, + struct rte_crypto_sgl *sgl, + struct rte_crypto_sgl *dest_sgl, + struct rte_crypto_va_iova_ptr *iv, + struct rte_crypto_va_iova_ptr *digest, + struct rte_crypto_va_iova_ptr *auth_iv, + union rte_crypto_sym_ofs ofs, + void *userdata, + struct qm_fd *fd) +{ + RTE_SET_USED(auth_iv); + + dpaa_sec_session *ses = + ((struct dpaa_sec_raw_dp_ctx *)drv_ctx)->session; + struct dpaa_sec_job *cf; + struct dpaa_sec_op_ctx *ctx; + struct qm_sg_entry *sg, *out_sg, *in_sg; + uint8_t *IV_ptr = iv->va; + unsigned int i; + uint16_t auth_hdr_len = ofs.ofs.cipher.head - + ofs.ofs.auth.head; + uint16_t auth_tail_len = ofs.ofs.auth.tail; + uint32_t auth_only_len = (auth_tail_len << 16) | auth_hdr_len; + int data_len = 0, auth_len = 0, cipher_len = 0; + + for (i = 0; i < sgl->num; i++) + data_len += sgl->vec[i].len; + + cipher_len = data_len - ofs.ofs.cipher.head - ofs.ofs.cipher.tail; + auth_len = data_len - ofs.ofs.auth.head - ofs.ofs.auth.tail; + + if (sgl->num > MAX_SG_ENTRIES) { + DPAA_SEC_DP_ERR("Cipher-Auth: Max sec segs supported is %d", + MAX_SG_ENTRIES); + return NULL; + } + + ctx = dpaa_sec_alloc_raw_ctx(ses, sgl->num * 2 + 4); + if (!ctx) + return NULL; + + cf = &ctx->job; + ctx->userdata = (void *)userdata; + + rte_prefetch0(cf->sg); + + /* output */ + out_sg = &cf->sg[0]; + out_sg->extension = 1; + if (is_encode(ses)) + out_sg->length = cipher_len + ses->digest_length; + else + out_sg->length = cipher_len; + + /* output sg entries */ + sg = &cf->sg[2]; + qm_sg_entry_set64(out_sg, rte_dpaa_mem_vtop(sg)); + cpu_to_hw_sg(out_sg); + + /* 1st seg */ + if (dest_sgl) { + qm_sg_entry_set64(sg, dest_sgl->vec[0].iova); + sg->length = dest_sgl->vec[0].len - ofs.ofs.cipher.head; + sg->offset = ofs.ofs.cipher.head; + + /* Successive segs */ + for (i = 1; i < dest_sgl->num; i++) { + cpu_to_hw_sg(sg); + sg++; + qm_sg_entry_set64(sg, dest_sgl->vec[i].iova); + sg->length = dest_sgl->vec[i].len; + } + } else { + qm_sg_entry_set64(sg, sgl->vec[0].iova); + sg->length = sgl->vec[0].len - ofs.ofs.cipher.head; + sg->offset = ofs.ofs.cipher.head; + + /* Successive segs */ + for (i = 1; i < sgl->num; i++) { + cpu_to_hw_sg(sg); + sg++; + qm_sg_entry_set64(sg, sgl->vec[i].iova); + sg->length = sgl->vec[i].len; + } + } + + if (is_encode(ses)) { + cpu_to_hw_sg(sg); + /* set auth output */ + sg++; + qm_sg_entry_set64(sg, digest->iova); + sg->length = ses->digest_length; + } + sg->final = 1; + cpu_to_hw_sg(sg); + + /* input */ + in_sg = &cf->sg[1]; + in_sg->extension = 1; + in_sg->final = 1; + if (is_encode(ses)) + in_sg->length = ses->iv.length + auth_len; + else + in_sg->length = ses->iv.length + auth_len + + ses->digest_length; + + /* input sg entries */ + sg++; + qm_sg_entry_set64(in_sg, rte_dpaa_mem_vtop(sg)); + cpu_to_hw_sg(in_sg); + + /* 1st seg IV */ + qm_sg_entry_set64(sg, rte_dpaa_mem_vtop(IV_ptr)); + sg->length = ses->iv.length; + cpu_to_hw_sg(sg); + + /* 2 seg */ + sg++; + qm_sg_entry_set64(sg, sgl->vec[0].iova); + sg->length = sgl->vec[0].len - ofs.ofs.auth.head; + sg->offset = ofs.ofs.auth.head; + + /* Successive segs */ + for (i = 1; i < sgl->num; i++) { + cpu_to_hw_sg(sg); + sg++; + qm_sg_entry_set64(sg, sgl->vec[i].iova); + sg->length = sgl->vec[i].len; + } + + if (is_decode(ses)) { + cpu_to_hw_sg(sg); + sg++; + memcpy(ctx->digest, digest->va, + ses->digest_length); + qm_sg_entry_set64(sg, rte_dpaa_mem_vtop(ctx->digest)); + sg->length = ses->digest_length; + } + sg->final = 1; + cpu_to_hw_sg(sg); + + if (auth_only_len) + fd->cmd = 0x80000000 | auth_only_len; + + return cf; } static struct dpaa_sec_job * @@ -104,10 +374,13 @@ build_dpaa_raw_dp_cipher_fd(uint8_t *drv_ctx, struct rte_crypto_va_iova_ptr *digest, struct rte_crypto_va_iova_ptr *auth_iv, union rte_crypto_sym_ofs ofs, - void *userdata) + void *userdata, + struct qm_fd *fd) { RTE_SET_USED(digest); RTE_SET_USED(auth_iv); + RTE_SET_USED(fd); + dpaa_sec_session *ses = ((struct dpaa_sec_raw_dp_ctx *)drv_ctx)->session; struct dpaa_sec_job *cf; @@ -264,15 +537,14 @@ dpaa_sec_raw_enqueue_burst(void *qp_data, uint8_t *drv_ctx, &vec->digest[loop], &vec->auth_iv[loop], ofs, - user_data[loop]); + user_data[loop], + fd); if (!cf) { DPAA_SEC_ERR("error: Improper packet contents" " for crypto operation"); goto skip_tx; } inq[loop] = ses->inq[rte_lcore_id() % MAX_DPAA_CORES]; - fd->opaque_addr = 0; - fd->cmd = 0; qm_fd_addr_set64(fd, rte_dpaa_mem_vtop(cf->sg)); fd->_format1 = qm_fd_compound; fd->length29 = 2 * sizeof(struct qm_sg_entry); @@ -470,6 +742,8 @@ dpaa_sec_configure_raw_dp_ctx(struct rte_cryptodev *dev, uint16_t qp_id, sess->build_raw_dp_fd = build_dpaa_raw_dp_cipher_fd; else if (sess->ctxt == DPAA_SEC_AUTH) sess->build_raw_dp_fd = build_dpaa_raw_dp_auth_fd; + else if (sess->ctxt == DPAA_SEC_CIPHER_HASH) + sess->build_raw_dp_fd = build_dpaa_raw_dp_chain_fd; else return -ENOTSUP; dp_ctx = (struct dpaa_sec_raw_dp_ctx *)raw_dp_ctx->drv_ctx_data; -- 2.17.1