From patchwork Thu Jan 11 11:33:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil Goyal X-Patchwork-Id: 124188 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp550181qgn; Thu, 11 Jan 2018 03:37:16 -0800 (PST) X-Google-Smtp-Source: ACJfBot91ya4yOm/azg3CPCccDJXv9VVz2+MgWDc15Epb+STWZT1+1MwjK+AefD0HMEI441edeIQ X-Received: by 10.223.147.39 with SMTP id 36mr21315660wro.63.1515670636587; Thu, 11 Jan 2018 03:37:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515670636; cv=none; d=google.com; s=arc-20160816; b=hIuPecUlZRjb+IS3OZMB4fSxmCnUjTjsoEpqcXEnKNVBVB01Lx+7s0nxuCLa4QIaKX ZBJHDtaKXL/nwM0Lvyz6+HRpD8inRIpPbwe4KliagbQZ6e1IMc1fvXsl2J/JFhD76U7M jzyGDbA/Z0FByCEmjhsgqekjC4hHRrVRSAoZEYamDie/zVoX/bXMJuURIgYwpCiwtWCY 92hhgqycDxyBGJeIFlwEFRqhrqkZVnxt6lTrecSFxQL8anY8HVkeMAmiN2wFr2J89L2o PC25IfLFVYYNQZ7pkj124R0MTWoMGV8tgy+iAHHzXEPhNuFn8nnHdZx/gjk6WpWtSgbY i/ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:spamdiagnosticmetadata :spamdiagnosticoutput:mime-version:references:in-reply-to:message-id :date:cc:to:from:arc-authentication-results; bh=Zpizh7N1xpPY9YneJeYUA9OwrNADARdF7mpwgyRJh6o=; b=wLjdIsGeGMU1FeyUD1qCMmUT2SJcqsKn5X0ioCBIbTeH8O5oPHd/hJ88XXzoHUsZ2Z Kmu0ENpszSe9+A08RWDKvNYZUljUn799gQGJv4+/vPb7u5u8ESWw6wGXY2D9aVbW5ZEV zF+PMiOYMwBB5i0Zp5zHWvXrjvtbY8mMNUv30i+fRLoyBjoBbbJY+7kOyHnN/6yUexHi MHC0vtVXP+KbSJTIzkKQoZG8LKCL96OaU2pnY5Uv+w1ZEKc7uDZ0L4Jlwx9AqnZwM6Gs GHFivhXOHveOIxZB3knqb4h9uaKWbxHfYe8J8h7Lvq6JUSABTdD5yvf8E5p671hNSNFp H8ag== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from dpdk.org (dpdk.org. [92.243.14.124]) by mx.google.com with ESMTP id m1si473021wmm.250.2018.01.11.03.37.16; Thu, 11 Jan 2018 03:37:16 -0800 (PST) Received-SPF: pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) client-ip=92.243.14.124; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B052BA491; Thu, 11 Jan 2018 12:37:09 +0100 (CET) Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0056.outbound.protection.outlook.com [104.47.34.56]) by dpdk.org (Postfix) with ESMTP id 49F06728B for ; Thu, 11 Jan 2018 12:37:07 +0100 (CET) Received: from MWHPR03CA0039.namprd03.prod.outlook.com (10.174.173.156) by MWHPR03MB2702.namprd03.prod.outlook.com (10.168.207.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.386.5; Thu, 11 Jan 2018 11:37:06 +0000 Received: from BL2FFO11FD032.protection.gbl (2a01:111:f400:7c09::167) by MWHPR03CA0039.outlook.office365.com (2603:10b6:301:3b::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.407.7 via Frontend Transport; Thu, 11 Jan 2018 11:37:05 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; NXP1.onmicrosoft.com; dkim=none (message not signed) header.d=none;NXP1.onmicrosoft.com; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BL2FFO11FD032.mail.protection.outlook.com (10.173.160.73) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.345.12 via Frontend Transport; Thu, 11 Jan 2018 11:36:33 +0000 Received: from netperf2.ap.freescale.net ([10.232.133.164]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id w0BBb0sq031996; Thu, 11 Jan 2018 04:37:03 -0700 From: Akhil Goyal To: CC: , Date: Thu, 11 Jan 2018 17:03:02 +0530 Message-ID: <20180111113304.19709-2-akhil.goyal@nxp.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20180111113304.19709-1-akhil.goyal@nxp.com> References: <20171213135659.32648-1-akhil.goyal@nxp.com> <20180111113304.19709-1-akhil.goyal@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131601441935619998; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(376002)(396003)(39380400002)(39860400002)(346002)(2980300002)(1109001)(1110001)(339900001)(199004)(189003)(5660300001)(8656006)(76176011)(50226002)(356003)(51416003)(48376002)(305945005)(54906003)(47776003)(68736007)(4326008)(50466002)(86362001)(77096006)(1076002)(316002)(2906002)(2351001)(85426001)(81166006)(296002)(8676002)(498600001)(6916009)(36756003)(97736004)(106466001)(104016004)(81156014)(16586007)(8936002)(2950100002)(105606002)(53936002); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR03MB2702; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD032; 1:+TW1OYrBrT63nJvZ32mcXYKE7Dz1Vx6xhVFLSSyDP3fowWDIQCzAq+azlvmJ8nSr+w1e9iCYDHoz2Xz/2hGbNM+toISfF72dcLFM1+QaqvaqXOZytT+n/f5Lqjf8B+Y+ MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 17f0eaef-1e00-4cd9-779e-08d558e790f7 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020065)(5600026)(4604075)(2017052603307); SRVR:MWHPR03MB2702; X-Microsoft-Exchange-Diagnostics: 1; MWHPR03MB2702; 3:Pxvdh7e0adA1Xv9qYaFjfKRVfWlHMVEwHoOTevE0WaB0Lt28RCLf3uKfWEUyYt60r6w5Sq9D6je8ofuo6tO4ZRWudRqpnX0AbcJyoajhzgrsgiysLe3Wv2nbOmbDj1vuog9yxoFZwUptjoRANLmTCtSBrSjvBudq6l8NOHvGWo38sf/Q2JxNG6R6GExcPdsb3GD0zYao3so48hF8t7UDhXxyCYihM2biMEm74KNPG1v3ieetzwdTPsOurqPU8Ck59WrZ87jwVj9fvbLKz6WVZ22lcNjLfFHAMnTRdt5abjrxB9lBF1YEw/0/60FiKaQ0Pw8qdh1lwVfWDjitQ9zpvLvqlNhNQ0DJRqWfNnWLGys=; 25:1AAnEJPEvWtY7C4Zc6L8bEctjeXZCn4JND+qFOovpegPizLQJ7BT2kFnR+9Xwm6MdOUq3Uzb/QZWcBghEYYIWmAbLzyLUbqGSMnIw+SwT0qaMXY1NiO0DOnkMk1p4T51LKliJENt9ZuM1mm8TnMy1JwKuawRPqVGaZaumj5qo9bLJ0YzjxVTw0WZQTN0TbMVI+/k0A24J7wi12B6ZQo8+q5CsBu8oRamhIzKBkBSDug0ys97pmovtKphoDyCoqrxbDDh+1H6ndAiOGzGe9CnbAVL743tzvbBYgFzCY+cyB9h0cbR3/gEPWWxEL6CtMYxTXJwnHTcVzE8ML6vF42ReQ== X-MS-TrafficTypeDiagnostic: MWHPR03MB2702: X-Microsoft-Exchange-Diagnostics: 1; MWHPR03MB2702; 31:yyecxNm5aiwinQomPVNhQoJKXehowwJD/akDdmgNAbQtcikUktbw2jkQRwQUIzzBIinM5Btf6RFgDJG7uzSQg6a0RtHsbZvNOEXg+kKkqokZm6AD7KS29E3fYD2XKX8lLb0E0+D+xG7rOsCPnErumktFIpdfiQ4BMKGXo0Sn+oBx10IIysh+70moSwshtrRvy5NPgjqr172QmzZg8x8tpbaPVY4eo904m7us+U3NYmE=; 4:Uc+cFbIM07AeBf8ZEI+QMt5/jasmbAJd2xti2qejEXOMVEwP8PZYLORiqteHbCYQ4Tcsgi4ulXmys1/kuRdGha6nlBjvv/hKHkchjmf3Ob46VL2h1XVUpK0mwN1r2HUr5TaCDxWvYf+OrCwvcQznZrCpptaqr/0nqUQW2nI4V2J70plFM/QFoLgr4dINgA0NLY+lz3yukPl27qbJVUu/aspHxeKTjzdGl74JRUIXuas+MahXEGAxzTG2GxkkJjMIckfT8Yho3ysqrBwp72AJ1b5u3A3EbHqCUdjMIw92vJbd8sC1QAvDeCL+jkHKbREM X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095135)(2401047)(8121501046)(5005006)(10201501046)(3231023)(944501134)(3002001)(93006095)(93001095)(6055026)(6096035)(20161123556025)(20161123559100)(20161123565025)(20161123563025)(201703131430075)(201703131520075)(201703131448075)(201703131433075)(201703151042153)(20161123561025)(201708071742011); SRVR:MWHPR03MB2702; BCL:0; PCL:0; RULEID:(100000803101)(100110400095)(400006); SRVR:MWHPR03MB2702; X-Forefront-PRVS: 0549E6FD50 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHPR03MB2702; 23:UKHaY1PbJJwgsqfc5+FbE7KUQTn+nyh5RSyVdoEBG?= oNLqBxQ1ItylEdlmNtkdWWX3MpWsqXTyJojElL1MPjmatZF2zPa3AE/l+8TPv9CtbMdk65JICGVd7ExoxPz8vnRx11YTjh9UUDtEhdgE1oqr/OqnIIPlkogrg5zxwfJsi99RI9UblogfB9KiUMJc5FF3SQgDqTx08zC+YmDoJ+UmX5x+NjqrLwC4TacsF6bOAijVtnxow2zEwoYqSXJ6Wlo2BUlB/NiVTFh/1OyX08saAYiTORddv15W8BmGGAr9Jyz48ng5g0il0Mjd0GbvOyxqvk1ia1MXtaI/b3UNdoLCJtrc9aM3sV6OyY64VmA8nBDt5rrXpR5Xqf6CZBSZ1MQbcIpLTwrL65SSLWfpMf7d7vLeoDy55DIrcAhDDHHRzhwXSOUtkV1FZ2+UgTQallySEBYeg56zAJ/Yivo4wOAtMZDbU27KNILGwkIuJyl31yVfN1x6SOujKr/+lkQUtFhLMENJ2QcSYOP2Tg0RBtA+S7BNHFdD7iS27+dSwJpwRQjPA7E/gXrUlgrjQk49fNPwhBmwk5hAGvWveM58XEmv0tutcydujLSWi7GCo9+Qw+t+GXPi/a2X6dxDcfGma33iJweHtBojfAaLYTuYkQLX7glGlvZHFxGNemVax6fjeB72yXpF5ei68tgDboWkuJhWX0XrU4jQun+Q7VC+Tc7hqcfrvp3C/wnEpidGJRsCKkxqTg9pagwMAfJij9/u3ohvSpHjBA+KxRQsi3V4cQojdTkyet9523r6x1JbUlV3b5ghPS5bhPnqt/ntyo1QQIo4mowm/Co3upF3C51uwo7Te8/YYUolwCJF1JNTlkLBm+jzpBsNMJ2Oe55O+JIpJv3rNjUhiAacBBT48sZk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HM7qpS0InWBQKhiYGQprUrOtVZ/bmXYwwxtvza/C94hE3563 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2018 11:36:33.3903 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 17f0eaef-1e00-4cd9-779e-08d558e790f7 X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR03MB2702 Subject: [dpdk-dev] [PATCH v2 1/3] crypto/dpaa_sec: optimize virt to phy conversion 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" From: Hemant Agrawal Context memory is allocated from mempool. Ideally it will get all memory from single segment, so simple offset calculation is used for address conversion for such addresses from context memory. Signed-off-by: Hemant Agrawal Acked-by: Akhil Goyal --- drivers/crypto/dpaa_sec/dpaa_sec.c | 27 ++++++++++++++++++--------- drivers/crypto/dpaa_sec/dpaa_sec.h | 1 + 2 files changed, 19 insertions(+), 9 deletions(-) -- 2.9.3 diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c b/drivers/crypto/dpaa_sec/dpaa_sec.c index ad1b309..157eace 100644 --- a/drivers/crypto/dpaa_sec/dpaa_sec.c +++ b/drivers/crypto/dpaa_sec/dpaa_sec.c @@ -80,6 +80,8 @@ dpaa_sec_alloc_ctx(dpaa_sec_session *ses) dcbz_64(&ctx->job.sg[SG_CACHELINE_3]); ctx->ctx_pool = ses->ctx_pool; + ctx->vtop_offset = (uint64_t) ctx + - rte_mempool_virt2iova(ctx); return ctx; } @@ -104,6 +106,13 @@ dpaa_mem_vtop(void *vaddr) return (rte_iova_t)(NULL); } +/* virtual address conversin when mempool support is available for ctx */ +static inline phys_addr_t +dpaa_mem_vtop_ctx(struct dpaa_sec_op_ctx *ctx, void *vaddr) +{ + return (uint64_t)vaddr - ctx->vtop_offset; +} + static inline void * dpaa_mem_ptov(rte_iova_t paddr) { @@ -563,7 +572,7 @@ build_auth_only(struct rte_crypto_op *op, dpaa_sec_session *ses) if (is_decode(ses)) { /* need to extend the input to a compound frame */ sg->extension = 1; - qm_sg_entry_set64(sg, dpaa_mem_vtop(&cf->sg[2])); + qm_sg_entry_set64(sg, dpaa_mem_vtop_ctx(ctx, &cf->sg[2])); sg->length = sym->auth.data.length + ses->digest_length; sg->final = 1; cpu_to_hw_sg(sg); @@ -577,7 +586,7 @@ build_auth_only(struct rte_crypto_op *op, dpaa_sec_session *ses) cpu_to_hw_sg(sg); /* let's check digest by hw */ - start_addr = dpaa_mem_vtop(old_digest); + start_addr = dpaa_mem_vtop_ctx(ctx, old_digest); sg++; qm_sg_entry_set64(sg, start_addr); sg->length = ses->digest_length; @@ -631,7 +640,7 @@ build_cipher_only(struct rte_crypto_op *op, dpaa_sec_session *ses) sg->extension = 1; sg->final = 1; sg->length = sym->cipher.data.length + ses->iv.length; - qm_sg_entry_set64(sg, dpaa_mem_vtop(&cf->sg[2])); + qm_sg_entry_set64(sg, dpaa_mem_vtop_ctx(ctx, &cf->sg[2])); cpu_to_hw_sg(sg); sg = &cf->sg[2]; @@ -677,7 +686,7 @@ build_cipher_auth_gcm(struct rte_crypto_op *op, dpaa_sec_session *ses) /* input */ rte_prefetch0(cf->sg); sg = &cf->sg[2]; - qm_sg_entry_set64(&cf->sg[1], dpaa_mem_vtop(sg)); + qm_sg_entry_set64(&cf->sg[1], dpaa_mem_vtop_ctx(ctx, sg)); if (is_encode(ses)) { qm_sg_entry_set64(sg, dpaa_mem_vtop(IV_ptr)); sg->length = ses->iv.length; @@ -722,7 +731,7 @@ build_cipher_auth_gcm(struct rte_crypto_op *op, dpaa_sec_session *ses) ses->digest_length); sg++; - qm_sg_entry_set64(sg, dpaa_mem_vtop(ctx->digest)); + qm_sg_entry_set64(sg, dpaa_mem_vtop_ctx(ctx, ctx->digest)); sg->length = ses->digest_length; length += sg->length; sg->final = 1; @@ -736,7 +745,7 @@ build_cipher_auth_gcm(struct rte_crypto_op *op, dpaa_sec_session *ses) /* output */ sg++; - qm_sg_entry_set64(&cf->sg[0], dpaa_mem_vtop(sg)); + qm_sg_entry_set64(&cf->sg[0], dpaa_mem_vtop_ctx(ctx, sg)); qm_sg_entry_set64(sg, dst_start_addr + sym->aead.data.offset - ses->auth_only_len); sg->length = sym->aead.data.length + ses->auth_only_len; @@ -788,7 +797,7 @@ build_cipher_auth(struct rte_crypto_op *op, dpaa_sec_session *ses) /* input */ rte_prefetch0(cf->sg); sg = &cf->sg[2]; - qm_sg_entry_set64(&cf->sg[1], dpaa_mem_vtop(sg)); + qm_sg_entry_set64(&cf->sg[1], dpaa_mem_vtop_ctx(ctx, sg)); if (is_encode(ses)) { qm_sg_entry_set64(sg, dpaa_mem_vtop(IV_ptr)); sg->length = ses->iv.length; @@ -818,7 +827,7 @@ build_cipher_auth(struct rte_crypto_op *op, dpaa_sec_session *ses) ses->digest_length); sg++; - qm_sg_entry_set64(sg, dpaa_mem_vtop(ctx->digest)); + qm_sg_entry_set64(sg, dpaa_mem_vtop_ctx(ctx, ctx->digest)); sg->length = ses->digest_length; length += sg->length; sg->final = 1; @@ -832,7 +841,7 @@ build_cipher_auth(struct rte_crypto_op *op, dpaa_sec_session *ses) /* output */ sg++; - qm_sg_entry_set64(&cf->sg[0], dpaa_mem_vtop(sg)); + qm_sg_entry_set64(&cf->sg[0], dpaa_mem_vtop_ctx(ctx, sg)); qm_sg_entry_set64(sg, dst_start_addr + sym->cipher.data.offset); sg->length = sym->cipher.data.length; length = sg->length; diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.h b/drivers/crypto/dpaa_sec/dpaa_sec.h index 9342949..e82f4fb 100644 --- a/drivers/crypto/dpaa_sec/dpaa_sec.h +++ b/drivers/crypto/dpaa_sec/dpaa_sec.h @@ -155,6 +155,7 @@ struct dpaa_sec_op_ctx { struct rte_crypto_op *op; struct rte_mempool *ctx_pool; /* mempool pointer for dpaa_sec_op_ctx */ uint32_t fd_status; + int64_t vtop_offset; uint8_t digest[DPAA_MAX_NB_MAX_DIGEST]; }; From patchwork Thu Jan 11 11:33:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil Goyal X-Patchwork-Id: 124189 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp550408qgn; Thu, 11 Jan 2018 03:37:28 -0800 (PST) X-Google-Smtp-Source: ACJfBou/C1ffOY+mLFh0/rt7xmnwB6MyVSVqIZSzmsRpZF/+lvfha5F2svDRiPzdsVPLOmGZwns1 X-Received: by 10.223.157.146 with SMTP id p18mr3108665wre.71.1515670648847; Thu, 11 Jan 2018 03:37:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515670648; cv=none; d=google.com; s=arc-20160816; b=ky4iBHFiIFUvdy5Z45D6q1F6BpTrosNizeQVMkVcn6xmxtLFO8mvKfVBsNsnWomEXq G9D5eEMy3vpmI987lWXYTjiKOKXgR25EmjbsqV0M470NktE93moICY6qlIkiJVy2hZlh vAdNU0EjKhTP8NjMcFMqB/vK6ac+dq/ZibiBWP2e8QzrJIn9cVAXGQ3atkSEl05Mxv0Z krfu6zBicmv+jhWMF1MVMqkleUQK+MMGGY5YIs+WIcj8isyvAmMM7rk7UJX3PJ+WVYpF WbdcKVluY3u4KnLNH4EFWHLJxNY/mMLGTMLGRZKSUUZwRzc/ze+/mTN4zooliwRX/3yK AAyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:spamdiagnosticmetadata :spamdiagnosticoutput:mime-version:references:in-reply-to:message-id :date:cc:to:from:arc-authentication-results; bh=Fu7eAo93WCkXOzj4uiCNzBvIu0B/pbINiZjHU1qVZyk=; b=xh62duKW4t7Rc04RQiP9uRwb6QCZzVecCxrIObriJ4fYtGcCx63JAdDdFqddUXpPZ+ tCRxweE0aHekSZbujfWKbVeX5//+/ylbleqt6nz7qQEiOdTYlLQ12Ic5BvsI+l4ES78z nYmau7tTnT0H/+o44VUj998/RScJ1WPVDq7Pbt8uSiJR6smQZaYvthnI6oSvU0XqZOFe RXIxmfo9Qy2etcQA9zHZm8tLnBcj6WNpN3tbSV04o8ek542g9bdAITau7M3+v8WwEpaK xOWPabni1mX+tmgb6ktrnDG5m14HTxkXFZk/8GcWfN/Newf/3KbSmcPiMqEEve5J7yjw 0Ktg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from dpdk.org (dpdk.org. [92.243.14.124]) by mx.google.com with ESMTP id g83si487748wmg.111.2018.01.11.03.37.28; Thu, 11 Jan 2018 03:37:28 -0800 (PST) Received-SPF: pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) client-ip=92.243.14.124; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 328ADA494; Thu, 11 Jan 2018 12:37:12 +0100 (CET) Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-bl2nam02on0070.outbound.protection.outlook.com [104.47.38.70]) by dpdk.org (Postfix) with ESMTP id 02F9FA494 for ; Thu, 11 Jan 2018 12:37:09 +0100 (CET) Received: from BN6PR03CA0011.namprd03.prod.outlook.com (2603:10b6:404:23::21) by SN2PR03MB2365.namprd03.prod.outlook.com (2603:10b6:804:e::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.386.5; Thu, 11 Jan 2018 11:37:08 +0000 Received: from BY2FFO11FD045.protection.gbl (2a01:111:f400:7c0c::123) by BN6PR03CA0011.outlook.office365.com (2603:10b6:404:23::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.386.5 via Frontend Transport; Thu, 11 Jan 2018 11:37:08 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; NXP1.onmicrosoft.com; dkim=none (message not signed) header.d=none;NXP1.onmicrosoft.com; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BY2FFO11FD045.mail.protection.outlook.com (10.1.15.177) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.345.12 via Frontend Transport; Thu, 11 Jan 2018 11:36:35 +0000 Received: from netperf2.ap.freescale.net ([10.232.133.164]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id w0BBb0sr031996; Thu, 11 Jan 2018 04:37:05 -0700 From: Akhil Goyal To: CC: , Date: Thu, 11 Jan 2018 17:03:03 +0530 Message-ID: <20180111113304.19709-3-akhil.goyal@nxp.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20180111113304.19709-1-akhil.goyal@nxp.com> References: <20171213135659.32648-1-akhil.goyal@nxp.com> <20180111113304.19709-1-akhil.goyal@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131601441959598867; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(396003)(39380400002)(346002)(39860400002)(376002)(2980300002)(1110001)(1109001)(339900001)(199004)(189003)(53936002)(59450400001)(50466002)(54906003)(16586007)(50226002)(104016004)(47776003)(305945005)(8936002)(2351001)(5890100001)(77096006)(68736007)(105606002)(296002)(106466001)(8656006)(356003)(2906002)(5660300001)(6916009)(1076002)(81166006)(36756003)(97736004)(4326008)(575784001)(86362001)(316002)(2950100002)(48376002)(76176011)(51416003)(85426001)(8676002)(81156014)(498600001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN2PR03MB2365; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD045; 1:GzPfNyaPdYISAFBRKmQRbZdf9bu409+AfS/zA0eLtxnOeSGpMkT0AAavrvRoFfojp0GPM/dMQU95BaqwsnQ8Iwxg5+pzILcCa3DdVZCyGwzSGbsFqMGXfeRQzvU8akZu MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9b385bdb-14f4-406b-5b13-08d558e79265 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020065)(5600026)(4604075)(2017052603307); SRVR:SN2PR03MB2365; X-Microsoft-Exchange-Diagnostics: 1; SN2PR03MB2365; 3:V98osM4L2iLwtmEJ2fvswThKcNtOtZd8CUTLIFRnSJpRuwNcosElW5pxQmkQvMLptgmNmFO5aZ4DyAQC36iJsAcmknYJvKZQPYYRszYP0WRhZ8g0QYbpn1Ktda66UiqHSnVGOb1FztptW/KwRwWWAnCdFJ0WfM7TX/Q5h2Mmx1IxIk7pEyPKGu7oqZ1h/wU5+tJ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cMwfH0MCRD30BfEAUvPMp3Y5TnGmXLMJyJ7udrgc7yR7+tQcYwtHU7Q69yYbPqLlRszx9 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095135)(2401047)(5005006)(8121501046)(3002001)(10201501046)(93006095)(93001095)(3231023)(944501134)(6055026)(6096035)(20161123559100)(20161123565025)(201703131430075)(201703131520075)(201703131433075)(201703131448075)(201703151042153)(20161123556025)(20161123563025)(20161123561025)(201708071742011); SRVR:SN2PR03MB2365; BCL:0; PCL:0; RULEID:(100000803101)(100110400095)(400006); SRVR:SN2PR03MB2365; X-Forefront-PRVS: 0549E6FD50 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN2PR03MB2365; 23:SFiZNsiJxzQ6e+vfdI8CLjLuxC5MYyabZegVlu9sT?= F+3kssEh9lnFQ/tYAp8YKS3HeUSc0gwQKWXgDJJhpo3EHyKSLTZ7mwOZm+wlhzNtybT720ncRb8zJzQYB/cInrspX+zGa0secJhYcBl4es9UgrVexy8tDu1hgM3r27R7Cu4oC4KX6NCDaFc08f6xEbNm/fmd38fEjlY2FAkGFIwRsy31IlwkmC2eAkPLa3nDPSrC0x7N5UMFAzpUyRlifhnMFm0TZqQ/tMZLTqvGVmTxUf4u3KBVqn6mH6/b/e+mcaDSviE7eicDlvNUlMNbPsrAvPdbs9F4HxGRsHAYn1hRVEMr3TLGVNcFll2RnV3pDpoUCo2/lgEM4JVwE/dEW8nMGqYgV5JQWpgYNVH0G0f4O5KxSXw2B541K3Oa1rt2/lcwpZGQPrQVA47CVHzrmXdC2rpFr052C/78t93DHyPyGFrXOJvUqY/swq4ssDiTssmbMb0ncHVj4oIbOUEt/Y03ebg2WTJtySQ+fOqcqecCT6CBFopPqfS08Uj/93ezV7IgpV2B4gvUwq6cL7huaozethPrrecwLPvlQsHy8/cwcPpOA4WQmr1SuRdXIvY1FkhPWUW/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c9EBikKZo6hDaVhk23E3NYju63dBDPvNo/HUCPaCrBGRXU=; 24:BgMQUTIwrNXRO3IqgKRv2X0z50GbQbSPEtgbdgd45U1WZ4DBgJetab31P4hagCc5nd2Nig9GsP1YaxCuxHBINDQ0/zuP+SlkqpBkPX9D5PE=; 7:zuNpsinyygZJaktvJUJSArsmFAIxSG8t4J3Ttd0KK8+/yjJ2zEFFrUI4DBm8PhmMGP7BFVBZ3ayrbkGuvjw5WlJtrdNio2k+EyccIdi/uhL/HNuCTmg3rcUsNRouTn/sXy5Q0AkOOoPxQU7nbUVQ6nNwjZRqsgDgJx99Iuq5/I750nz6YnvHgLZ4YDL5KV/Iw0BDRcCKFpZCLbG24NmlHt1+EI4wVALyWLIviGJfvN2YGSwp5QTwAwSv31/WjZvB SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2018 11:36:35.7570 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9b385bdb-14f4-406b-5b13-08d558e79265 X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN2PR03MB2365 Subject: [dpdk-dev] [PATCH v2 2/3] crypto/dpaa_sec: support multiple sessions per qp 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" From: Hemant Agrawal Signed-off-by: Hemant Agrawal Acked-by: Akhil Goyal --- drivers/crypto/dpaa_sec/dpaa_sec.c | 154 +++++++++++++++++++++++++------------ drivers/crypto/dpaa_sec/dpaa_sec.h | 74 +++++++++--------- 2 files changed, 145 insertions(+), 83 deletions(-) -- 2.9.3 diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c b/drivers/crypto/dpaa_sec/dpaa_sec.c index 157eace..f433f0a 100644 --- a/drivers/crypto/dpaa_sec/dpaa_sec.c +++ b/drivers/crypto/dpaa_sec/dpaa_sec.c @@ -43,6 +43,9 @@ static uint8_t cryptodev_driver_id; static __thread struct rte_crypto_op **dpaa_sec_ops; static __thread int dpaa_sec_op_nb; +static int +dpaa_sec_attach_sess_q(struct dpaa_sec_qp *qp, dpaa_sec_session *sess); + static inline void dpaa_sec_op_ending(struct dpaa_sec_op_ctx *ctx) { @@ -151,15 +154,6 @@ dpaa_sec_init_rx(struct qman_fq *fq_in, rte_iova_t hwdesc, /* Clear FQ options */ memset(&fq_opts, 0x00, sizeof(struct qm_mcc_initfq)); - flags = QMAN_FQ_FLAG_LOCKED | QMAN_FQ_FLAG_DYNAMIC_FQID | - QMAN_FQ_FLAG_TO_DCPORTAL; - - ret = qman_create_fq(0, flags, fq_in); - if (unlikely(ret != 0)) { - PMD_INIT_LOG(ERR, "qman_create_fq failed"); - return ret; - } - flags = QMAN_INITFQ_FLAG_SCHED; fq_opts.we_mask = QM_INITFQ_WE_DESTWQ | QM_INITFQ_WE_CONTEXTA | QM_INITFQ_WE_CONTEXTB; @@ -171,9 +165,11 @@ dpaa_sec_init_rx(struct qman_fq *fq_in, rte_iova_t hwdesc, fq_in->cb.ern = ern_sec_fq_handler; + PMD_INIT_LOG(DEBUG, "in-%x out-%x", fq_in->fqid, fqid_out); + ret = qman_init_fq(fq_in, flags, &fq_opts); if (unlikely(ret != 0)) - PMD_INIT_LOG(ERR, "qman_init_fq failed"); + PMD_INIT_LOG(ERR, "qman_init_fq failed %d", ret); return ret; } @@ -357,7 +353,7 @@ dpaa_sec_prep_cdb(dpaa_sec_session *ses) { struct alginfo alginfo_c = {0}, alginfo_a = {0}, alginfo = {0}; uint32_t shared_desc_len = 0; - struct sec_cdb *cdb = &ses->qp->cdb; + struct sec_cdb *cdb = &ses->cdb; int err; #if RTE_BYTE_ORDER == RTE_BIG_ENDIAN int swap = false; @@ -877,12 +873,10 @@ dpaa_sec_enqueue_op(struct rte_crypto_op *op, struct dpaa_sec_qp *qp) ses = (dpaa_sec_session *)get_session_private_data(op->sym->session, cryptodev_driver_id); - if (unlikely(!qp->ses || qp->ses != ses)) { - qp->ses = ses; - ses->qp = qp; - ret = dpaa_sec_prep_cdb(ses); - if (ret) - return ret; + if (unlikely(!ses->qp || ses->qp != qp)) { + PMD_INIT_LOG(DEBUG, "sess->qp - %p qp %p", ses->qp, qp); + if (dpaa_sec_attach_sess_q(qp, ses)) + return -1; } /* @@ -918,7 +912,7 @@ dpaa_sec_enqueue_op(struct rte_crypto_op *op, struct dpaa_sec_qp *qp) if (auth_only_len) fd.cmd = 0x80000000 | auth_only_len; do { - ret = qman_enqueue(&qp->inq, &fd, 0); + ret = qman_enqueue(ses->inq, &fd, 0); } while (ret != 0); return 0; @@ -1134,43 +1128,82 @@ dpaa_sec_aead_init(struct rte_cryptodev *dev __rte_unused, return 0; } -static int -dpaa_sec_qp_attach_sess(struct rte_cryptodev *dev, uint16_t qp_id, void *ses) +static struct qman_fq * +dpaa_sec_attach_rxq(struct dpaa_sec_dev_private *qi) { - dpaa_sec_session *sess = ses; - struct dpaa_sec_qp *qp; + unsigned int i; - PMD_INIT_FUNC_TRACE(); + for (i = 0; i < qi->max_nb_sessions; i++) { + if (qi->inq_attach[i] == 0) { + qi->inq_attach[i] = 1; + return &qi->inq[i]; + } + } + PMD_DRV_LOG(ERR, "All ses session in use %x", qi->max_nb_sessions); + + return NULL; +} - qp = dev->data->queue_pairs[qp_id]; - if (qp->ses != NULL) { - PMD_INIT_LOG(ERR, "qp in-use by another session\n"); - return -EBUSY; +static int +dpaa_sec_detach_rxq(struct dpaa_sec_dev_private *qi, struct qman_fq *fq) +{ + unsigned int i; + + for (i = 0; i < qi->max_nb_sessions; i++) { + if (&qi->inq[i] == fq) { + qi->inq_attach[i] = 0; + return 0; + } } + return -1; +} + +static int +dpaa_sec_attach_sess_q(struct dpaa_sec_qp *qp, dpaa_sec_session *sess) +{ + int ret; - qp->ses = sess; sess->qp = qp; + ret = dpaa_sec_prep_cdb(sess); + if (ret) { + PMD_DRV_LOG(ERR, "Unable to prepare sec cdb"); + return -1; + } - return dpaa_sec_prep_cdb(sess); + ret = dpaa_sec_init_rx(sess->inq, dpaa_mem_vtop(&sess->cdb), + qman_fq_fqid(&qp->outq)); + if (ret) + PMD_DRV_LOG(ERR, "Unable to init sec queue"); + + return ret; +} + +static int +dpaa_sec_qp_attach_sess(struct rte_cryptodev *dev __rte_unused, + uint16_t qp_id __rte_unused, + void *ses __rte_unused) +{ + PMD_INIT_FUNC_TRACE(); + return 0; } static int -dpaa_sec_qp_detach_sess(struct rte_cryptodev *dev, uint16_t qp_id, void *ses) +dpaa_sec_qp_detach_sess(struct rte_cryptodev *dev, + uint16_t qp_id __rte_unused, + void *ses) { dpaa_sec_session *sess = ses; - struct dpaa_sec_qp *qp; + struct dpaa_sec_dev_private *qi = dev->data->dev_private; PMD_INIT_FUNC_TRACE(); - qp = dev->data->queue_pairs[qp_id]; - if (qp->ses != NULL) { - qp->ses = NULL; - sess->qp = NULL; - return 0; - } + if (sess->inq) + dpaa_sec_detach_rxq(qi, sess->inq); + sess->inq = NULL; - PMD_DRV_LOG(ERR, "No session attached to qp"); - return -EINVAL; + sess->qp = NULL; + + return 0; } static int @@ -1233,8 +1266,20 @@ dpaa_sec_set_session_parameters(struct rte_cryptodev *dev, return -EINVAL; } session->ctx_pool = internals->ctx_pool; + session->inq = dpaa_sec_attach_rxq(internals); + if (session->inq == NULL) { + PMD_DRV_LOG(ERR, "unable to attach sec queue"); + goto err1; + } return 0; + +err1: + rte_free(session->cipher_key.data); + rte_free(session->auth_key.data); + memset(session, 0, sizeof(dpaa_sec_session)); + + return -EINVAL; } static int @@ -1267,6 +1312,7 @@ dpaa_sec_session_configure(struct rte_cryptodev *dev, set_session_private_data(sess, dev->driver_id, sess_private_data); + return 0; } @@ -1275,16 +1321,22 @@ static void dpaa_sec_session_clear(struct rte_cryptodev *dev, struct rte_cryptodev_sym_session *sess) { - PMD_INIT_FUNC_TRACE(); + struct dpaa_sec_dev_private *qi = dev->data->dev_private; uint8_t index = dev->driver_id; void *sess_priv = get_session_private_data(sess, index); + + PMD_INIT_FUNC_TRACE(); + dpaa_sec_session *s = (dpaa_sec_session *)sess_priv; if (sess_priv) { + struct rte_mempool *sess_mp = rte_mempool_from_obj(sess_priv); + + if (s->inq) + dpaa_sec_detach_rxq(qi, s->inq); rte_free(s->cipher_key.data); rte_free(s->auth_key.data); memset(s, 0, sizeof(dpaa_sec_session)); - struct rte_mempool *sess_mp = rte_mempool_from_obj(sess_priv); set_session_private_data(sess, index, NULL); rte_mempool_put(sess_mp, sess_priv); } @@ -1332,7 +1384,8 @@ dpaa_sec_dev_infos_get(struct rte_cryptodev *dev, info->capabilities = dpaa_sec_capabilities; info->sym.max_nb_sessions = internals->max_nb_sessions; info->sym.max_nb_sessions_per_qp = - RTE_DPAA_SEC_PMD_MAX_NB_SESSIONS / RTE_MAX_NB_SEC_QPS; + RTE_DPAA_SEC_PMD_MAX_NB_SESSIONS / + RTE_DPAA_MAX_NB_SEC_QPS; info->driver_id = cryptodev_driver_id; } } @@ -1377,7 +1430,7 @@ dpaa_sec_dev_init(struct rte_cryptodev *cryptodev) { struct dpaa_sec_dev_private *internals; struct dpaa_sec_qp *qp; - uint32_t i; + uint32_t i, flags; int ret; char str[20]; @@ -1393,7 +1446,7 @@ dpaa_sec_dev_init(struct rte_cryptodev *cryptodev) RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING; internals = cryptodev->data->dev_private; - internals->max_nb_queue_pairs = RTE_MAX_NB_SEC_QPS; + internals->max_nb_queue_pairs = RTE_DPAA_MAX_NB_SEC_QPS; internals->max_nb_sessions = RTE_DPAA_SEC_PMD_MAX_NB_SESSIONS; for (i = 0; i < internals->max_nb_queue_pairs; i++) { @@ -1404,10 +1457,15 @@ dpaa_sec_dev_init(struct rte_cryptodev *cryptodev) PMD_INIT_LOG(ERR, "config tx of queue pair %d", i); goto init_error; } - ret = dpaa_sec_init_rx(&qp->inq, dpaa_mem_vtop(&qp->cdb), - qman_fq_fqid(&qp->outq)); - if (ret) { - PMD_INIT_LOG(ERR, "config rx of queue pair %d", i); + } + + flags = QMAN_FQ_FLAG_LOCKED | QMAN_FQ_FLAG_DYNAMIC_FQID | + QMAN_FQ_FLAG_TO_DCPORTAL; + for (i = 0; i < internals->max_nb_sessions; i++) { + /* create rx qman fq for sessions*/ + ret = qman_create_fq(0, flags, &internals->inq[i]); + if (unlikely(ret != 0)) { + PMD_INIT_LOG(ERR, "sec qman_create_fq failed"); goto init_error; } } diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.h b/drivers/crypto/dpaa_sec/dpaa_sec.h index e82f4fb..93369e4 100644 --- a/drivers/crypto/dpaa_sec/dpaa_sec.h +++ b/drivers/crypto/dpaa_sec/dpaa_sec.h @@ -38,36 +38,6 @@ enum dpaa_sec_op_type { DPAA_SEC_MAX }; -typedef struct dpaa_sec_session_entry { - uint8_t dir; /*!< Operation Direction */ - enum rte_crypto_cipher_algorithm cipher_alg; /*!< Cipher Algorithm*/ - enum rte_crypto_auth_algorithm auth_alg; /*!< Authentication Algorithm*/ - enum rte_crypto_aead_algorithm aead_alg; /*!< Authentication Algorithm*/ - union { - struct { - uint8_t *data; /**< pointer to key data */ - size_t length; /**< key length in bytes */ - } aead_key; - struct { - struct { - uint8_t *data; /**< pointer to key data */ - size_t length; /**< key length in bytes */ - } cipher_key; - struct { - uint8_t *data; /**< pointer to key data */ - size_t length; /**< key length in bytes */ - } auth_key; - }; - }; - struct { - uint16_t length; - uint16_t offset; - } iv; /**< Initialisation vector parameters */ - uint16_t auth_only_len; /*!< Length of data for Auth only */ - uint32_t digest_length; - struct dpaa_sec_qp *qp; - struct rte_mempool *ctx_pool; /* session mempool for dpaa_sec_op_ctx */ -} dpaa_sec_session; #define DPAA_SEC_MAX_DESC_SIZE 64 /* code or cmd block to caam */ @@ -117,11 +87,41 @@ struct sec_cdb { uint32_t sh_desc[DPAA_SEC_MAX_DESC_SIZE]; }; +typedef struct dpaa_sec_session_entry { + uint8_t dir; /*!< Operation Direction */ + enum rte_crypto_cipher_algorithm cipher_alg; /*!< Cipher Algorithm*/ + enum rte_crypto_auth_algorithm auth_alg; /*!< Authentication Algorithm*/ + enum rte_crypto_aead_algorithm aead_alg; /*!< Authentication Algorithm*/ + union { + struct { + uint8_t *data; /**< pointer to key data */ + size_t length; /**< key length in bytes */ + } aead_key; + struct { + struct { + uint8_t *data; /**< pointer to key data */ + size_t length; /**< key length in bytes */ + } cipher_key; + struct { + uint8_t *data; /**< pointer to key data */ + size_t length; /**< key length in bytes */ + } auth_key; + }; + }; + struct { + uint16_t length; + uint16_t offset; + } iv; /**< Initialisation vector parameters */ + uint16_t auth_only_len; /*!< Length of data for Auth only */ + uint32_t digest_length; + struct dpaa_sec_qp *qp; + struct qman_fq *inq; + struct sec_cdb cdb; /**< cmd block associated with qp */ + struct rte_mempool *ctx_pool; /* session mempool for dpaa_sec_op_ctx */ +} dpaa_sec_session; + struct dpaa_sec_qp { struct dpaa_sec_dev_private *internals; - struct sec_cdb cdb; /* cmd block associated with qp */ - dpaa_sec_session *ses; /* session associated with qp */ - struct qman_fq inq; struct qman_fq outq; int rx_pkts; int rx_errs; @@ -129,12 +129,16 @@ struct dpaa_sec_qp { int tx_errs; }; -#define RTE_MAX_NB_SEC_QPS RTE_DPAA_SEC_PMD_MAX_NB_SESSIONS +#define RTE_DPAA_MAX_NB_SEC_QPS 1 +#define RTE_DPAA_MAX_RX_QUEUE RTE_DPAA_SEC_PMD_MAX_NB_SESSIONS + /* internal sec queue interface */ struct dpaa_sec_dev_private { void *sec_hw; struct rte_mempool *ctx_pool; /* per dev mempool for dpaa_sec_op_ctx */ - struct dpaa_sec_qp qps[RTE_MAX_NB_SEC_QPS]; /* i/o queue for sec */ + struct dpaa_sec_qp qps[RTE_DPAA_MAX_NB_SEC_QPS]; /* i/o queue for sec */ + struct qman_fq inq[RTE_DPAA_MAX_RX_QUEUE]; + unsigned char inq_attach[RTE_DPAA_MAX_RX_QUEUE]; unsigned int max_nb_queue_pairs; unsigned int max_nb_sessions; };