From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id C8C7EA04B1; Sat, 10 Oct 2020 21:55:13 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5AD5E1D510; Sat, 10 Oct 2020 21:55:11 +0200 (CEST) Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-eopbgr150071.outbound.protection.outlook.com [40.107.15.71]) by dpdk.org (Postfix) with ESMTP id 18FBB1D50F for ; Sat, 10 Oct 2020 21:55:09 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mCXzhTz9l1kW/AzPgg5oh79Vxwytyil7gDVcc9VtOJT6vyqnlEUfN9YBclAVtXck2Up3j/rY1uLtqGjTRm5XPrZ7wLnoRa3QiDuqb4oQJZsuMFT55m8qt+Z/IlTPd41wXXDwHZuqiCVBIZMvOmyMNArc7QGQ2VGRW0kNn4FGMLeIiBZ1AMijs94WQN/rHOYAjQMUW+8aVFs6JLXTiUb6KuPWmrwWx4hzOXhngNtkbwrUNFOsrDRhRD07D5wxOUkxdi9ypb770tBFWtR3r+//9aZvUyRY1J3H0GuFQFpGqJHgvC4u8DADjg9IY6d1Xlxy3eds8dHd58ScwypoTewGLg== 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=ckAp8Dd3YuO9K/bS+eXfxwe8WPBUwHpyClIRWEogINQ=; b=SVM4kxm3XKSnvsN0vULtFydSzT59JETNYgKcFoqr74nOV2nPx2OlYBtUJVCOC84g11/zbPeJpV1f+yr9mnNqv6CIYrf7MpR9thQRCN6xaesauUa3YZpG4u8Wh/gnAdje3wwo9sGA2BegtiB5p1xQbz+ha0Fq72uP0w7cQZzq+9UZi2MWFHSiD15ocw9KajgwaXsL2CGawB8TLKrC5+04IckAmz5VEiE/PF9nvaUZIWdmG2ugb4sCChQM4FJKwj9QKP+uGpBl5fBLi+oIQ8XPL3gPAx7YGMRSUR/psT/ABfDBQT9Qzru/b2enSyolhm8lcHlj4//e2MfGjbVL2Z7a+Q== 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=ckAp8Dd3YuO9K/bS+eXfxwe8WPBUwHpyClIRWEogINQ=; b=imQlig43Ls0UH0N8asGfBXBMPRVMKqVxvXE81FEXDp5XCGg5MWhVWSKU+gcS1Thj6yBUPPllTj4zz3vT4mqB1/zqAxsCakTJ0z+384zYFXqx+FQGglLqK5wpYqcrxRsdIPx3KoIc5u9TW/0dx65qDY88Ck6jpN661Z9dARxrNhg= Received: from AM5PR04MB3153.eurprd04.prod.outlook.com (2603:10a6:206:e::26) by AM6PR0402MB3783.eurprd04.prod.outlook.com (2603:10a6:209:1b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.22; Sat, 10 Oct 2020 19:55:07 +0000 Received: from AM5PR04MB3153.eurprd04.prod.outlook.com ([fe80::91e5:1731:c6e:b79c]) by AM5PR04MB3153.eurprd04.prod.outlook.com ([fe80::91e5:1731:c6e:b79c%2]) with mapi id 15.20.3455.028; Sat, 10 Oct 2020 19:55:07 +0000 From: Akhil Goyal To: Fan Zhang , "dev@dpdk.org" CC: Adam Dybkowski Thread-Topic: [dpdk-dev v11 4/4] test/crypto: add unit-test for cryptodev raw API test Thread-Index: AQHWnoDTkVA0UAExWUSaCN/SjuanZqmRPxwQ Date: Sat, 10 Oct 2020 19:55:07 +0000 Message-ID: References: <20200924163417.49983-1-roy.fan.zhang@intel.com> <20201009211141.14435-1-roy.fan.zhang@intel.com> <20201009211141.14435-5-roy.fan.zhang@intel.com> In-Reply-To: <20201009211141.14435-5-roy.fan.zhang@intel.com> Accept-Language: en-IN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=nxp.com; x-originating-ip: [122.180.231.103] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: d60569c3-e5c0-493b-d13e-08d86d566338 x-ms-traffictypediagnostic: AM6PR0402MB3783: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:7691; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: ZHlfD8ipGxyOcqNTtD6zdxIFJ9F5sLdFnVct0tFXtYyD4McgS4i7POTueo6SXwHU+L6z1eFpFxUENPmvzi01Qn5JjMAMsXty6hZJYA7/X9yAQpcA7TBlY32NEtFC01vFQS8l2CrGGGxnKMBBxgXa1cNFBfsvKGRkQlnSJP73RV7eBo6xWYQ4cewRRZ2yD1k0cqVtbAsmcYuBNKowQK60viHXD+sAUwByDsOwwkQwzbonc3YU13EolzxHTTtVCxAxHX3hxqXYYHk8BJAjtbvV0TSvyLIkGnYZr0u7mZW9rpWEOuAbsmHB0bYKKCi7v0tshpvAxTPBimoiWH8SSBUSVA== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM5PR04MB3153.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(136003)(39860400002)(366004)(376002)(346002)(8676002)(55016002)(8936002)(478600001)(110136005)(86362001)(71200400001)(83380400001)(44832011)(4326008)(66946007)(76116006)(9686003)(6506007)(26005)(2906002)(186003)(7696005)(33656002)(316002)(52536014)(66446008)(64756008)(66476007)(66556008)(5660300002); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: XZtgdRBN1/bVSGiFx41Th+AvFhhtc1kFpa2C81H4JDh3VKqIAipd74IwasguG2SHtnw1J/Ns/mFKXBtTcaGw0NXo3M1g0Dkx1w9nwy78gMTDk0AcS7CZByqYIa9j+H800ltSqV02hP+GMoBvFrL8N69BD3EvSAYxnJB8jmTJNZETYgtk+HV9AZm+bl7c3DUPc0S2HDcajUrH0Cpd5PWHht44CPrfyzjb35O2Ync6AXmUvEpCPyh3xp7K+ze1QbvDKObONIeq1jdF5Nb3VuuqcWHoxUZm/3ZemEP+UJsoNJihzr3eNPqBOmtkJzjjbgUpJnc9Va/5Mjr+4NrQkLmvB/a3epyXkwyxhV4SPl7zFedXxuNKvyIE359B5Yh37No+1slZYwFtP+mQBjZsXTBmz/Srfg372C/uRuBXgn09Piarf1FvjQmSAYrLvOI+nXpYBKs/9BoyILCzgdTPK4oQMcu1Uvup4Sr0PF/mil7/RJW5JLAI4ZwFJva8zEyyo+cwizdK1vlNTMRif7w9RtQm6uSPEMCpKC/1aHyQNnly1zj+g8mSVdJcVBHxL3ef7C0Ud0ZUFQR9h7SpxSxZHGvOB+DEhzM1QEiM/oxDaKinnCNo91XQX5hRDn3vR0RjYWiRLhzD99un2Wn0eBFdtQgrxA== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: AM5PR04MB3153.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: d60569c3-e5c0-493b-d13e-08d86d566338 X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Oct 2020 19:55:07.0599 (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: LItlM0EUb51JmwwkOMsml4WNJFqt0S9ebhI0LFYRApceGN/vPrcYqceRObhcGRtQ17rRwyGO7RltU8quCab/4g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR0402MB3783 Subject: Re: [dpdk-dev] [dpdk-dev v11 4/4] test/crypto: add unit-test for cryptodev raw API test 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi Fan, > +static uint32_t > +get_raw_dp_dequeue_count(void *user_data __rte_unused) > +{ > + return 1; Why is this 1 always? There could be jobs >1 which are processed. > +} > + > +static void > +post_process_raw_dp_op(void *user_data, uint32_t index __rte_unused, > + uint8_t is_op_success) > +{ > + struct rte_crypto_op *op =3D user_data; > + op->status =3D is_op_success ? RTE_CRYPTO_OP_STATUS_SUCCESS : > + RTE_CRYPTO_OP_STATUS_ERROR; > +} > + > +void > +process_sym_raw_dp_op(uint8_t dev_id, uint16_t qp_id, > + struct rte_crypto_op *op, uint8_t is_cipher, uint8_t is_auth, > + uint8_t len_in_bits, uint8_t cipher_iv_len) > +{ > + struct rte_crypto_sym_op *sop =3D op->sym; > + struct rte_crypto_op *ret_op =3D NULL; > + struct rte_crypto_vec data_vec[UINT8_MAX]; > + struct rte_crypto_va_iova_ptr cipher_iv, digest, aad_auth_iv; > + union rte_crypto_sym_ofs ofs; > + struct rte_crypto_sym_vec vec; > + struct rte_crypto_sgl sgl; > + uint32_t max_len; > + union rte_cryptodev_session_ctx sess; > + uint32_t count =3D 0; > + struct rte_crypto_raw_dp_ctx *ctx; > + uint32_t cipher_offset =3D 0, cipher_len =3D 0, auth_offset =3D 0, > + auth_len =3D 0; > + int32_t n; > + uint32_t n_success; > + int ctx_service_size; > + int32_t status =3D 0; > + > + ctx_service_size =3D rte_cryptodev_get_raw_dp_ctx_size(dev_id); > + if (ctx_service_size < 0) { > + op->status =3D RTE_CRYPTO_OP_STATUS_ERROR; > + return; > + } > + > + ctx =3D malloc(ctx_service_size); > + if (!ctx) { > + op->status =3D RTE_CRYPTO_OP_STATUS_ERROR; > + return; > + } > + > + /* Both are enums, setting crypto_sess will suit any session type */ > + sess.crypto_sess =3D op->sym->session; > + > + if (rte_cryptodev_configure_raw_dp_ctx(dev_id, qp_id, ctx, > + op->sess_type, sess, 0) < 0) { > + op->status =3D RTE_CRYPTO_OP_STATUS_ERROR; > + goto exit; > + } > + > + cipher_iv.iova =3D 0; > + cipher_iv.va =3D NULL; > + aad_auth_iv.iova =3D 0; > + aad_auth_iv.va =3D NULL; > + digest.iova =3D 0; > + digest.va =3D NULL; > + sgl.vec =3D data_vec; > + vec.num =3D 1; > + vec.sgl =3D &sgl; > + vec.iv =3D &cipher_iv; > + vec.digest =3D &digest; > + vec.aad =3D &aad_auth_iv; > + vec.status =3D &status; > + > + ofs.raw =3D 0; > + > + if (is_cipher && is_auth) { > + cipher_offset =3D sop->cipher.data.offset; > + cipher_len =3D sop->cipher.data.length; > + auth_offset =3D sop->auth.data.offset; > + auth_len =3D sop->auth.data.length; > + max_len =3D RTE_MAX(cipher_offset + cipher_len, > + auth_offset + auth_len); > + if (len_in_bits) { > + max_len =3D max_len >> 3; > + cipher_offset =3D cipher_offset >> 3; > + auth_offset =3D auth_offset >> 3; > + cipher_len =3D cipher_len >> 3; > + auth_len =3D auth_len >> 3; > + } > + ofs.ofs.cipher.head =3D cipher_offset; > + ofs.ofs.cipher.tail =3D max_len - cipher_offset - cipher_len; > + ofs.ofs.auth.head =3D auth_offset; > + ofs.ofs.auth.tail =3D max_len - auth_offset - auth_len; > + cipher_iv.va =3D rte_crypto_op_ctod_offset(op, void *, > IV_OFFSET); > + cipher_iv.iova =3D rte_crypto_op_ctophys_offset(op, IV_OFFSET); > + aad_auth_iv.va =3D rte_crypto_op_ctod_offset( > + op, void *, IV_OFFSET + cipher_iv_len); > + aad_auth_iv.iova =3D rte_crypto_op_ctophys_offset(op, > IV_OFFSET + > + cipher_iv_len); > + digest.va =3D (void *)sop->auth.digest.data; > + digest.iova =3D sop->auth.digest.phys_addr; > + > + } else if (is_cipher) { > + cipher_offset =3D sop->cipher.data.offset; > + cipher_len =3D sop->cipher.data.length; > + max_len =3D cipher_len + cipher_offset; > + if (len_in_bits) { > + max_len =3D max_len >> 3; > + cipher_offset =3D cipher_offset >> 3; > + cipher_len =3D cipher_len >> 3; > + } > + ofs.ofs.cipher.head =3D cipher_offset; > + ofs.ofs.cipher.tail =3D max_len - cipher_offset - cipher_len; > + cipher_iv.va =3D rte_crypto_op_ctod_offset(op, void *, > IV_OFFSET); > + cipher_iv.iova =3D rte_crypto_op_ctophys_offset(op, IV_OFFSET); > + > + } else if (is_auth) { > + auth_offset =3D sop->auth.data.offset; > + auth_len =3D sop->auth.data.length; > + max_len =3D auth_len + auth_offset; > + if (len_in_bits) { > + max_len =3D max_len >> 3; > + auth_offset =3D auth_offset >> 3; > + auth_len =3D auth_len >> 3; > + } > + ofs.ofs.auth.head =3D auth_offset; > + ofs.ofs.auth.tail =3D max_len - auth_offset - auth_len; > + aad_auth_iv.va =3D rte_crypto_op_ctod_offset( > + op, void *, IV_OFFSET + cipher_iv_len); > + aad_auth_iv.iova =3D rte_crypto_op_ctophys_offset(op, > IV_OFFSET + > + cipher_iv_len); > + digest.va =3D (void *)sop->auth.digest.data; > + digest.iova =3D sop->auth.digest.phys_addr; > + > + } else { /* aead */ > + cipher_offset =3D sop->aead.data.offset; > + cipher_len =3D sop->aead.data.length; > + max_len =3D cipher_len + cipher_offset; > + if (len_in_bits) { > + max_len =3D max_len >> 3; > + cipher_offset =3D cipher_offset >> 3; > + cipher_len =3D cipher_len >> 3; > + } > + ofs.ofs.cipher.head =3D cipher_offset; > + ofs.ofs.cipher.tail =3D max_len - cipher_offset - cipher_len; > + cipher_iv.va =3D rte_crypto_op_ctod_offset(op, void *, > IV_OFFSET); > + cipher_iv.iova =3D rte_crypto_op_ctophys_offset(op, IV_OFFSET); > + aad_auth_iv.va =3D (void *)sop->aead.aad.data; > + aad_auth_iv.iova =3D sop->aead.aad.phys_addr; > + digest.va =3D (void *)sop->aead.digest.data; > + digest.iova =3D sop->aead.digest.phys_addr; > + } > + > + n =3D rte_crypto_mbuf_to_vec(sop->m_src, 0, max_len, > + data_vec, RTE_DIM(data_vec)); > + if (n < 0 || n > sop->m_src->nb_segs) { > + op->status =3D RTE_CRYPTO_OP_STATUS_ERROR; > + goto exit; > + } > + > + sgl.num =3D n; > + > + if (rte_cryptodev_raw_enqueue_burst(ctx, &vec, ofs, (void **)&op, > + &status) > + < 1) { > + op->status =3D RTE_CRYPTO_OP_STATUS_ERROR; > + goto exit; > + } This check will always fail in your case. I believe you have not tested it = with the Recent changes that I suggested on V10. rte_cryptodev_raw_enqueue_burst will return 0 if rte_cryptodev_raw_enqueue_= done need to be called or else the number of successfully enqueued descriptors. > + > + if (status =3D=3D 0) { > + status =3D rte_cryptodev_raw_enqueue_done(ctx, 1); > + if (status < 0) { > + op->status =3D RTE_CRYPTO_OP_STATUS_ERROR; > + goto exit; > + } > + } > + > + n =3D n_success =3D 0; > + while (count++ < MAX_RAW_DEQUEUE_COUNT && n =3D=3D 0) { > + n =3D rte_cryptodev_raw_dequeue_burst(ctx, > + get_raw_dp_dequeue_count, > post_process_raw_dp_op, > + (void **)&ret_op, 0, &n_success, &status); > + > + if (n =3D=3D 0) > + rte_pause(); > + } Same comment here as well.=20 rte_cryptodev_raw_dequeue_burst will return 0 if dequeue_done need to be ca= lled. These checks does not seem to be consistent with the API documentation. > + > + if (n =3D=3D 1 && status =3D=3D 0) { > + if (rte_cryptodev_raw_dequeue_done(ctx, 1) < 0) { > + op->status =3D RTE_CRYPTO_OP_STATUS_ERROR; > + goto exit; > + } > + } > + > + op->status =3D (count =3D=3D MAX_RAW_DEQUEUE_COUNT + 1 || ret_op !=3D > op || > + n_success < 1) ? RTE_CRYPTO_OP_STATUS_ERROR : > + RTE_CRYPTO_OP_STATUS_SUCCESS; > + > +exit: > + free(ctx); > +} > +