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 B7976A0C52; Thu, 12 Aug 2021 09:17:42 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3A1F64125D; Thu, 12 Aug 2021 09:16:29 +0200 (CEST) Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-eopbgr20049.outbound.protection.outlook.com [40.107.2.49]) by mails.dpdk.org (Postfix) with ESMTP id 5443B4125A for ; Thu, 12 Aug 2021 09:16:28 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R52PDsfQNIqez2AYS4mtIibOiVgx2ISZOfhSssm1T7iNQ34zpsYIj/TFit0ruy4vTZRI2AHPPshfGDkETr+3h8h1K77wvMs96ZF0RDt9NPsMpngJk86SWRZfJqafnw9DsANYGy7Tfr6yNqkJ4xAlF72sU9a/DBhyUvYBJVcMTp1FVFEsOS76F22BMCYrBlwS+vDE+tES3HmsgFt66ntp5n79/Vyu+iwk4t1ooJ+E7s1IkhZjB4AOrqnBNZ/46mXv5qHF9NFHTmX4UKV68nSBg8FmsdME0UHEhQcbaaZwcy/fR09SehJY7wH3HQ/7+iwLuj2dsQinLcZ5bh5pB15b5g== 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-SenderADCheck; bh=YqaXcWZmzes9i4Dns5vYrmIBnikEsdWyaDkbLdillH4=; b=Nh24K49Oi1QqHkGkOajs7XhOiHHnhnhPvibHeJmw4WxyBpHNU/UNBTNUqddFlbPvOKcKRx8HPW/fbMWD53j+ksgGOJpkcDnMAHlRJ9gAMvBhlzP9dJP1UzhxbwSRR0GSK4Y82zMdxEM9LwJTFeyHInU99DuABHkO9/Z6E+7yqfzsg/sgRcd8moEOf67S37Sh5P1pA4vop49AMLsHuSqNSYmznfMi8yWf2P8usK8wpU/k70lJpsCz2lYo0TH73AxwHnYODFIwlJov95XDdG/f3TLbOOpqxGvgVJTClUZxbznIMIcBKM5rSDtNNVu78szVvvr4BjmdVfCnWmWdpA6awQ== 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=YqaXcWZmzes9i4Dns5vYrmIBnikEsdWyaDkbLdillH4=; b=F4MGTuZdGTB0P1YG/OD54qsp2MKbVfXgE1SguDP24FFTPeLyBSbzBGDWglQFkbTfWqRlO6l0dfR3msW72BJnSZChXiO69KbcBQkRnvXiYg8J+8dvx/CYl24fF9lzuf4I7JHsSeUFtlvIal1xmbMMD0A9p2ycoJJNqn3bjIIEP9M= 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 DB9PR04MB8461.eurprd04.prod.outlook.com (2603:10a6:10:2bc::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.13; Thu, 12 Aug 2021 07:16:27 +0000 Received: from DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::2590:514a:df1f:a793]) by DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::2590:514a:df1f:a793%9]) with mapi id 15.20.4415.016; Thu, 12 Aug 2021 07:16:27 +0000 From: Hemant Agrawal To: dev@dpdk.org, gakhil@marvell.com Cc: Gagandeep Singh Date: Thu, 12 Aug 2021 12:42:41 +0530 Message-Id: <20210812071244.28799-14-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210812071244.28799-1-hemant.agrawal@nxp.com> References: <20210812071244.28799-1-hemant.agrawal@nxp.com> Content-Type: text/plain X-ClientProxiedBy: SG2PR02CA0105.apcprd02.prod.outlook.com (2603:1096:4:92::21) To DU2PR04MB8630.eurprd04.prod.outlook.com (2603:10a6:10:2dd::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from dpdk-xeon.ap.freescale.net (92.120.0.67) by SG2PR02CA0105.apcprd02.prod.outlook.com (2603:1096:4:92::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.14 via Frontend Transport; Thu, 12 Aug 2021 07:16:26 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4ac7483c-6c0c-4efc-c87f-08d95d6119b1 X-MS-TrafficTypeDiagnostic: DB9PR04MB8461: 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: eALC/H0P2JfJ57dzuTemRjq9o5bFaE6CKAykc/RpZ3W3ONOVemw+wfyav/xKqDVEAlgV4qMiYCDzDPz+BRZuZFmmGcak0cSi6ilH4sKesjOffV2sTF6xWHyEU9XZWVC3peLk1thlYNIlj3Naz3VxMWN7mvKw2pevKXH6Rb4h/lqGswZVwskJV+5Y7PYkWbPYCy7RJa5aDaGzhdlUGaPCOMOdqehaDZWu8ll4CgepggzILKU667U/WBCt+8Z4SlZTT2TTWNUP44bCd3c8MZHWdEHsjiRm/geOGhKcVHPQAqWIV7VVT91Bd7S9wfSyw79jXX775jJPtDXZiK14ubomBIvh0SyMSlijpo1rsHrKDoYd/79diXiFmER6HiVQgCqZzRVQ2NoZJqua2czz0mO1wd1uTdmT6rAmYSRz7yS9OKj8ekHvLTZhBauClyrxvviu3C5vxHD2ur3CszBaGc7WvBpvSxxDihecUbMaCA5TC/tFoCfqi7SL+8ldWlcXTiSfACXhkkj+6jlQitdsgNEMOlX3EOZERb9y6rJ3g3qG5F46BCEVHnsuZtuv6OwK2tGNpwIxFY88qxs8V5Knt8WABcKOwgJRQ7II9xE9+pBynateOd0SSv4IHexmF1dHpYCGwJZ7ZfUzWWQ+z+lQ1sOkw7Si/d0uD/l9hGIxS1HBu8zKZL691oXI2QgGVKzir8drCELkaubhxytdUenJsF1K4w== 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)(376002)(346002)(39860400002)(396003)(136003)(366004)(8936002)(956004)(6512007)(2616005)(2906002)(6666004)(36756003)(86362001)(4326008)(83380400001)(38350700002)(44832011)(478600001)(26005)(6506007)(66476007)(186003)(52116002)(5660300002)(1076003)(66556008)(6486002)(38100700002)(8676002)(66946007)(316002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?SBgpplDxCfMe/8OqoscHp7tVwgRHrRLYHhhu/rntj5Hfcu6yihozJ9SesJtt?= =?us-ascii?Q?1mrI2XTGL4Kn/D3M5Tqzzs48TZSdD/7krNzeS3PesNaLlN/B7so5m1ZSCU5s?= =?us-ascii?Q?e2OXcxISVymLmODtj6M307Wvh70wmbom8YxKp8sHDU424yLAW9F2Fz2j3ol+?= =?us-ascii?Q?2tqEXcgpLmK1TzTPt2saVux5FyWuY7jumvCx8cFjTCIF1KjCS1bRWNBW3ae4?= =?us-ascii?Q?0I1pzR4QbA3H+7BQv2ROQBAsuFWhVMICnKFBqhY8fB9UTwuoJEMU4EHVA+C8?= =?us-ascii?Q?4S/jIKl5ITejsEphPJTmuCXJvaSxJQpQYN2O84/K+vKSKN8jJ4lYSCmjRgjc?= =?us-ascii?Q?HGj5MBl8A5SDwrPvCrF0dlekKv0MctttvTooi2L3d+5sbTTTlmbquSGxLvR7?= =?us-ascii?Q?pA11BtcONXMWKePHY+JeUKsxxqy0TBC6AmyBiPARD1q9kR5OTN5teE37ApUr?= =?us-ascii?Q?UzZLKjHMRH0dX9bLs/6gEkCMsFPZLQYC+J7EEmRKfXhEQEtmp5Ke5QmS3+A6?= =?us-ascii?Q?nzvcCTBEFvyCgldz7faiH1Udhy90Msn6wNy3i93foaw45mk73X5Mfvx3oRjo?= =?us-ascii?Q?rA1LlyvlIAA0S3fJxkAaJLIvNzCyv9IuCLtHh07ALeWzhRTIhVPwciqZNz7l?= =?us-ascii?Q?LNjGfPBBZ0yLGvQphEYn5IYNnHmRjMR0dF+BmjX2Xbw3KOToQ0afDYXelxxa?= =?us-ascii?Q?bhrZ81UWwsexSF2wcjMMnVb0pwtcvnyj0S9XOsWB6/d7QZqTnU6VAYnRbpiu?= =?us-ascii?Q?/EOiPCqAsQIJVtMEUbHG0ypIUhlWV3Nw99BbpN5W9shm9sJyJHYStQ1HjS2+?= =?us-ascii?Q?YBdVWiApqfKtiRY3lZxTCcec43/UG0mN8vYNIZQ+QyDxhV5CeEUNUCbsnk92?= =?us-ascii?Q?IY+DzHm+YDi1mjA+EZyNhWKFOp80CZCG2SmQ7FaEH2REzFUFMmkrKLWtpAQp?= =?us-ascii?Q?6P4vPYb2ntWbSbDAylhRTp+2TYV7Ew0x+n+ERN/B0xyru7RYNJjztrulEKjq?= =?us-ascii?Q?FAP8OEmggZYilT/2lK8G8rbSdN8iP/Prc2Ig1/HgUdtYF8TaLAU+YIY0de2Y?= =?us-ascii?Q?aZnYzBnXPCZRFloQC01HTb/tNaFsY8ft1fmFm1K59pXA12dnhcR7sBkqckms?= =?us-ascii?Q?TOvXOwGgicm2tSNfoNPqX1zbw3oYWrpRxCIshf3JLcpCvoy2PT38GgZzWMCW?= =?us-ascii?Q?hmguKOYX2FoIzpMERv2nK/b601QrvKgvLk5v1OA0A7fiS99TjMP2zRRWsmBG?= =?us-ascii?Q?+M6HOrHcS9Z6BFSamlNghdA4BeQeUz/uNiGg9NXB72Jx6vRrkbGi4UQTftUg?= =?us-ascii?Q?hg0STRfoBGDO25SvZJkAqFs/?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4ac7483c-6c0c-4efc-c87f-08d95d6119b1 X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8630.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Aug 2021 07:16:27.5720 (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: zeTdRF8bqFHCWkliHCV+X4+Xx67zQVtIyAoC/qZNYtDBZsH2eByYDedZtCSNpd6KVHw5Uat0heOCyHkCe9K9hQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8461 Subject: [dpdk-dev] [RFC 13/16] 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 f6e83d46e7..2e0ab93ff0 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 ee0ca2e0d5..4e34629f18 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