From patchwork Wed Dec 13 13:56:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil Goyal X-Patchwork-Id: 121776 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp5514267qgn; Wed, 13 Dec 2017 06:04:49 -0800 (PST) X-Received: by 10.223.164.218 with SMTP id h26mr2020819wrb.271.1513173649964; Wed, 13 Dec 2017 06:00:49 -0800 (PST) X-Google-Smtp-Source: ACJfBouGtrOeDuRUKbf+fxdW1ef12X6f6NxDoAeFCH3zED1RPbJOVuOvuXj4G0VPOy0jo0YDYQgq X-Received: by 10.223.164.218 with SMTP id h26mr2020776wrb.271.1513173649175; Wed, 13 Dec 2017 06:00:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513173649; cv=none; d=google.com; s=arc-20160816; b=kCaCxPAPAiwimCXNR/Ws6OCYCKdJh4obP3Jk4ZfsIulBKHxNsmrnDLWFxdjRpcp5j2 ZsftpYTyUs4OVxQ0Pl4QBstHonNW55TD7xYT8XqpyhkaWENyfCHjNK6EWL5J0q+Ma+kH IArYF19PZf6yWMn53HtQpi2sG62nKdvnIu+J9dypnNnFdjYc33yRSE/GhRh1G1hQ29Bs uvQ4Bz8V24qtND5DILxVV5J73AHsLuw7pkhuA/qCq3D+6U1mTnjvc6tm4+qmPsDRuR9e Pemlb+8bCQMW2SU6dk49e0Gm1zhwLTnLp905VKcTlKVR3BGbFy6KB1jsIqL6BOVJO3yZ ZiIQ== 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=65HvHE/fEXO/d5dBpQdP1t114GW2wMPXy4wX6IqSEGc=; b=xUzo5CgctlyoHHBhHzHOMTYgU5bSgFFxk5lJYDtflouvecMjVHabY2gZ1YzZ2F28SM MoJcTHlnXUWmr3ozLqdYG2m+Lk1fygjDRgpHl4gbfZsf98zsY1zYgk7CVUkP4RY+qpwG KKyW1UpLSt33igrM0uxuFH1bAdZ9SqbgSUZHSgRVLGe67/IjlFep8TIpumV3K9Q8/WyY e8JwOV9F9JkJv9YmYnW4O3ov/6CYhEJ1aZNwCuvXMKCWibvyS8bfFeLWIbO8IoAjfaAP vQH5qUYIVTJKKhak4z78SC5qyNc81AgIK967BKPD/rej3WyRBalRoYktD6gcoR9GYnR/ RbSQ== 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 d4si1348290wre.36.2017.12.13.06.00.48; Wed, 13 Dec 2017 06:00:49 -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 0B8B11B010; Wed, 13 Dec 2017 15:00:43 +0100 (CET) Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0070.outbound.protection.outlook.com [104.47.40.70]) by dpdk.org (Postfix) with ESMTP id C2A482030 for ; Wed, 13 Dec 2017 15:00:40 +0100 (CET) Received: from CY4PR03CA0082.namprd03.prod.outlook.com (2603:10b6:910:4d::23) 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.302.9; Wed, 13 Dec 2017 14:00:39 +0000 Received: from BN1BFFO11FD042.protection.gbl (2a01:111:f400:7c10::1:192) by CY4PR03CA0082.outlook.office365.com (2603:10b6:910:4d::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.302.9 via Frontend Transport; Wed, 13 Dec 2017 14:00:39 +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 BN1BFFO11FD042.mail.protection.outlook.com (10.58.144.105) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.282.5 via Frontend Transport; Wed, 13 Dec 2017 14:00:31 +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 vBDE0WHi023690; Wed, 13 Dec 2017 07:00:36 -0700 From: Akhil Goyal To: CC: , , Date: Wed, 13 Dec 2017 19:26:55 +0530 Message-ID: <20171213135659.32648-2-akhil.goyal@nxp.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20171213135659.32648-1-akhil.goyal@nxp.com> References: <20171213135659.32648-1-akhil.goyal@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131576472319526126; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(336005)(39860400002)(39380400002)(376002)(346002)(2980300002)(1109001)(1110001)(339900001)(189003)(199004)(305945005)(356003)(47776003)(51416003)(76176011)(2906002)(36756003)(1076002)(6666003)(2950100002)(8656006)(6916009)(8936002)(53936002)(16586007)(4326008)(97736004)(104016004)(85426001)(8676002)(81166006)(81156014)(50226002)(50466002)(316002)(106466001)(77096006)(296002)(48376002)(2351001)(54906003)(5660300001)(68736007)(498600001)(105606002)(86362001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN2PR03MB2365; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD042; 1:/CXrk/mZk9ZlEDtO+uUwJKl1E/xcYffxnVeSKSkQXdFGkGAnLOjdUlXFG/v/4tcVzOpbH9GNi2innIsFv733jPOBJPCYzKsD8nuXEUVmVIV/ZucyaKa/3uYzUrLKSsoy MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7e844769-a344-462b-84ee-08d54231dfde X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(5600026)(4604075)(4534020)(4628075)(201703131517081)(2017052603307); SRVR:SN2PR03MB2365; X-Microsoft-Exchange-Diagnostics: 1; SN2PR03MB2365; 3:q74ch2LQFbsqu7Hco/k70QA95839NnqVMTdc8DHJ1bFMKjmcl6XxG5AkjsX1rBBZEeVl8OhMwbUpBYup+1wRtoy+vYBo4tNbFwbYj7zVQhcHPwF3vSaJ35ghLxM5MczDqCKqwXJbOwLaYsxKvoSMPlAuO6WhrIIc27VHoW7+cQxzWkOUQpC96dqRC5xmeDFuc1UUOY/uh1HdLd8KAPSaWM8tcbVQdMoN3YvMA4lD6mhBkK1dQqyk9HM40Q/jnDXIB4tYKISMzm2Fqr0JtPYxQccI+UJn0dLeARzgxCju0ljKlkkgdg7h5XFQ48duRH4wRgyzHvpq4GfIppWtGv+XSidNiNmn1Tl30cGkJCKV0j4=; 25:i7rPRK34ovuEb9SWSEihMhPQ5FkcDiOGKISmV9hZ1tlfLcNWiMCwaGmvawTtrHTL3Wa0G8+c30DymRAQGtN3mJNyPSbUq/GBnWoWl/tfbaTabvtlxTOatd9IYdbgc3X69MMst4FkD1iRr+YoBaLvwchfigNX/+Y2bh6RL+RvhIopmiIz0guoR2Lwx60lUTDoYznWPbUpRjTGaCu/YexnlFR1y6PV1BUu8qocQQiq87Zpm6mlPycF265iz9K9uQt/z1GXIEObq587IL01ijwWA3HtxQQIy+7CseuG0Ov6ojjeR5zuPf/2AGCzu6n8zeL5gxYpxPcGgFEftoY7HW58gg== X-MS-TrafficTypeDiagnostic: SN2PR03MB2365: X-Microsoft-Exchange-Diagnostics: 1; SN2PR03MB2365; 31:Ss0xaDbmDczVji4WI0SHWLohsfeX+nqybwxRP2mNqHNW6BZLQY2BX/2DsMM5+1FvEab3PlIdpDO5G1QPBjeScA1u34G32LdK+OlAzowRbwqLmdd7Epyq7LboXjNJ1jg5ImD/eYV/dqbRIqrhnx93Q6dBe/eJfy9Ro9ShCwe2J1e6wIqcLCjrfyvWyBJ/RvmB+mniiYzNH65WijLj1qDngDjLfb/+lMCucENWftXGkmM=; 4:ue8cyS7vlsHuRpJAwjXTYFWFyNWgtreyjjUr0Wa0oyvmnVNUsk89/pum800elOSPgPMseVoPBMA5IkXf8nPBN8oV++vEU/KCwEWyk45NYbN7YT1kcUhqFIIDp5YLa9mQ+HwqdYBoyU/XTrSue8f9mj3zjeKlLpwRH/Lsc8HslI79OZTB164jranSFipTCysAfEiFwVMIhuFCB/NqDyB8qVZw8F0lllN7Rv1z2ErLPUgK7L0GfeJXuuZ99ImCA/VllNWE84qyVzpCgJMC4RmoF/aCuDadJ8252Z0RV8YuBrd3ct3jIaAS5jKzTDSwTTda 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)(3231023)(93006095)(93001095)(10201501046)(3002001)(6055026)(6096035)(201703131430075)(201703131520075)(201703131433075)(201703131448075)(201703161259150)(201703151042153)(20161123563025)(20161123556025)(20161123561025)(20161123565025)(20161123559100)(201708071742011); SRVR:SN2PR03MB2365; BCL:0; PCL:0; RULEID:(100000803101)(100110400095)(400006); SRVR:SN2PR03MB2365; X-Forefront-PRVS: 052017CAF1 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN2PR03MB2365; 23:iRFIhhto/tZlDAjn57Qh/DZZVWBH1S52gvuqbsyD/?= 1wPxrE7P4CyfpfJnkUR+HCsRmQkGtU6PYG7ndt673+MHFUwDoOakJQoqRkC/G1NYVT0q3wtEbU/mAtzStcJ8KzxWrsMoh5vQKczwfhj+m47SerznAdc8vaF9KH1S25dSt4dYtaadFxIhiXsXHegFzE2uLhW78QNtAaKPkg5PXp3j1+o6J1TdbQQr51Al14QiL3E2vuqaKC7XYZVqIVE/22ew+pzp5cN//vH0ucTgHML23A6UrfHg/HSgeE9SI/T/KNTXEYrzV4uJhWDZX+05GLP/SiJgwhHOamRhGge4N95V/HLonUfQfXF+PiqYAs0J+2H+aGkQmY+G51O7uC+VQ+vgeZ9YumN8crONNe4/RVwBWV1yHnQZoZun6U2KGeHdTNQsKUJcCSdlCM20ltH4hmOFxupC94HBRzyWEUOJ3YxqnO5PjDvw6Jw8pdiOdN89GgM9rxLr2t54js6ZJr55qdA/pbkA4Lpx0omFYgXQm2bTzQgj8XfJoeXhZLejoBQrlg2t1Pl1xMhhfSkXQ4TK3bFoEGyobwsXCPaJUexvB81+uFFgL5HPGDzoglIYB+hr+7Np4Wu7XIEGz7rsL4eVV4xbV+vwhTEtC1dLyOIU1SlKDaBhFcvve1smjphbN3XtFjBV57SaDZDpv6rz9adyvflynTsPJQdi5Ve2vU/p399XrYTFi1idg4/7giN8uTfN6s9Ip48qx8kD1zsqShrCyWywbm06Iki7ZLnMu0Co15fx+300iEuAnVI+YvFWtmo4/F67asZ7VWAbjjeVDnOGcrISgCwN7XR9QK38vP5nbST35YobnP8n0G9PrYj7I272qAvHewtNOXJSNOySIvKzgAZNceJq4PdcuPd9YVDqctpdHY4JqscVe3uFzyNBQR5vY8EmLtSUwUJzc4Gbkr1Lfsqjm9LCjkZnBA6GIpq2PMHvJ//IP94eLThG/EOtJm+WLO9fTTOJvVR6Mo4mDUI+Jh2XCWlgNkUQ0CLQIwCULUPTdXNhk2cDA/9wvJCwiDCbklaHDGXAWM9/6aikAglIAY68y1U0hfphuy9GtFGrjhVpA== X-Microsoft-Exchange-Diagnostics: 1; SN2PR03MB2365; 6:1mUPZ1UOX9fL/qqdp/IH18uAM/ZUcAKx45lUXe80pSED78kXvyD6LUNPSqe5SQ1ovkn1jrSLUw903UwZ/o58KURUvhv+/k5xAzHC+mvWeRT3ZSU36LCf72yibP5KiGgCOtJ88NQlbFbyGtFx45ZDdZUqnD2zHI2ZkTb4Au6JiCFLSbKC0QhYddZ8jLmtpGqSC0qplDEHiIELcnSspB3Uc+PTo9pNBl0V6+I8fcWLVSXcbFmUjFJKWNK0GvB7gNYDgev/RdIDnDg9HCA6WyRanRuAf1kFgBVjnR2izLcsn6kP20M7C4gI/lT9FzteTz4RVcrCEPTHwOkraQmueZMLKsk8/51P3Fkrq4iqddWpI7U=; 5:vHdXM/YC9E28KH0LfhSm51rJIIV+T6VH9h7xjZ9TkMnW6ymR1BCiXXP0PCoAPjpbq/MG+sy3eNqOcILlfzpAkjlkYj/zADDzVNjrnF2TaEQNsyrPM8uM5zAdmxxK/AHCMua6x0EeZKcK3QMzI6O/xktQbTn9B13lg2rZxtbtvxk=; 24:TwqJpDbnVhooXqrpYSu/ZfeYsYILbDhd4VJucsvBSEvpCG2IlnRz4RNqU/sie4OdiAbj7vE8B4LLVSAQlAqZd4OBPrCxzgVJH9ZLj27eYHQ=; 7:NMjhFsgAydB5W6QfA6V8zqRTcuDgR+MzEAl3iYQCYY+22U4A6MIgzj50vCsK1iTkmxn61vsvmaLDKY9jAtq2NEcACiOybjqZsWTKBX+Fek2Ej8R15l72/osKwJgsWA7YMnNZg47GrFfZxOs5eOznWvRdrGbHb3asO9u/5YRJh/nH0Vg9d8tuYwnQTOftOO4gA15YIjrXiQCSjmDskkPRy6GVD8aDVANaAFkNqrc29ZrCxw1O2zAk1C6TP7lXhtSc SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Dec 2017 14:00:31.7654 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7e844769-a344-462b-84ee-08d54231dfde 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 1/5] 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 16155b1..a1271be 100644 --- a/drivers/crypto/dpaa_sec/dpaa_sec.c +++ b/drivers/crypto/dpaa_sec/dpaa_sec.c @@ -106,6 +106,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; } @@ -130,6 +132,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) { @@ -589,7 +598,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); @@ -603,7 +612,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; @@ -657,7 +666,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]; @@ -703,7 +712,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; @@ -748,7 +757,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; @@ -762,7 +771,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; @@ -814,7 +823,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; @@ -844,7 +853,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; @@ -858,7 +867,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 af3f255..eba07b6 100644 --- a/drivers/crypto/dpaa_sec/dpaa_sec.h +++ b/drivers/crypto/dpaa_sec/dpaa_sec.h @@ -181,6 +181,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 Wed Dec 13 13:56:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil Goyal X-Patchwork-Id: 121773 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp5508124qgn; Wed, 13 Dec 2017 06:00:59 -0800 (PST) X-Google-Smtp-Source: ACJfBot2Ioes5ChZLgKetCmgSBZT4FQ2sZztIM55DLP5bUTdA0qhQVp7n61QYN7WMJtLTy1ydMVq X-Received: by 10.223.138.212 with SMTP id z20mr2376780wrz.154.1513173659637; Wed, 13 Dec 2017 06:00:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513173659; cv=none; d=google.com; s=arc-20160816; b=0z6ivAquJZz0gT6J1jXKpY5x8cIqLB3BR83m3k9yr6/gxJ7W/s/QGvdjwMCPQ/Zq/A OOozr5Nv38tOT9ZtD3aWQYvON1pqLg2kVlYrV/Q3MesEa8t7dgTqPbYmoF4CGRU+1vLM hFdb5le78AVTbOQlP56eVIVLOCfC1/uAwkKO4C7X+/EOImT3M7GXgg9BjfxUx44x0B+T ihklopu3BXWTRhmbzpLR6JuiIt5Fzm0tkfC3Qm1irqDCyAv/+o/jx5Pag+DeUtPaaykG cDedq8tKz5br42BqIUn47W0uQXCuYzETw9XkaRn5DDGS+5cUsuXPUC02AOLXGM5mScWd kSuQ== 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=G2j+Itgg5Sy2HqmFb7Q4iZAiIgxzEhUaZpZDR5Ib3UU=; b=z95DLnYTZL/oPH8XjF/B0fMRGam9MjfT1bIgkPmwcifaRzBmjmEGb7eg1/xUOL/T7B h47rJ3KhjaYqyRfnfmkYwWwde7Dc7mKjG3GMnMQzP05vI+fQ14/1hJwURxj4J1TpHs2M lqsO9UQ3Oke5JAwEM/dPAtKVo9dm3rcT7+vODZ0eDzuy/XnXW9H14fo2N7a4OmoTe2OE pyFiVVrcGZd9tAWstrq8Vl3stMmbJZIYnBGzUCDz+2W7kZbEu6cz7sq7+91lECGQZ4H7 LQnqenZ8k89M4uCOvnQ7ySkwMhv0dHDI1kJKqG/KWdA3yfqO2n5STNVjn/u7y7NY2P2V DgmA== 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 g80si1517376wmc.162.2017.12.13.06.00.59; Wed, 13 Dec 2017 06:00:59 -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 3117D1B015; Wed, 13 Dec 2017 15:00:47 +0100 (CET) Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-sn1nam01on0055.outbound.protection.outlook.com [104.47.32.55]) by dpdk.org (Postfix) with ESMTP id 195351B015 for ; Wed, 13 Dec 2017 15:00:45 +0100 (CET) Received: from CY4PR03CA0007.namprd03.prod.outlook.com (2603:10b6:903:33::17) by BN1PR0301MB0724.namprd03.prod.outlook.com (2a01:111:e400:4c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.302.9; Wed, 13 Dec 2017 14:00:42 +0000 Received: from BN1BFFO11FD027.protection.gbl (2a01:111:f400:7c10::1:128) by CY4PR03CA0007.outlook.office365.com (2603:10b6:903:33::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.302.9 via Frontend Transport; Wed, 13 Dec 2017 14:00:41 +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 BN1BFFO11FD027.mail.protection.outlook.com (10.58.144.90) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.282.5 via Frontend Transport; Wed, 13 Dec 2017 14:00: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 vBDE0WHj023690; Wed, 13 Dec 2017 07:00:38 -0700 From: Akhil Goyal To: CC: , , Date: Wed, 13 Dec 2017 19:26:56 +0530 Message-ID: <20171213135659.32648-3-akhil.goyal@nxp.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20171213135659.32648-1-akhil.goyal@nxp.com> References: <20171213135659.32648-1-akhil.goyal@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131576472341283720; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(336005)(7966004)(376002)(39860400002)(346002)(39380400002)(2980300002)(1110001)(1109001)(339900001)(189003)(199004)(81166006)(2950100002)(51416003)(48376002)(8656006)(86362001)(36756003)(6916009)(6666003)(2351001)(77096006)(5660300001)(5890100001)(50466002)(97736004)(106466001)(105606002)(316002)(8676002)(81156014)(4326008)(47776003)(1076002)(76176011)(498600001)(356003)(68736007)(305945005)(296002)(53936002)(104016004)(8936002)(50226002)(54906003)(59450400001)(16586007)(85426001)(2906002); DIR:OUT; SFP:1101; SCL:1; SRVR:BN1PR0301MB0724; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD027; 1:EdsX8TGt5pFGb/Zbrf6siTcNf2alC0Mjk8qyGQtnAQU+F9ICIp36qWyvmJ5As7t0uyp3JwxCdG7w4w+ZeVg/TT4Nj31NxLOKVLLD1CH7M/X1FRBdvSnodur5sCrTApSH MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 86a915f7-e70f-455a-8388-08d54231e12a X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4628075)(201703131517081)(5600026)(4604075)(2017052603307); SRVR:BN1PR0301MB0724; X-Microsoft-Exchange-Diagnostics: 1; BN1PR0301MB0724; 3:rNVsbmav5fgZiIZHQyCbQziWVOzzq2od9HnzpSJQoPM+sFHpw6O12YOdwEdOpB1iPKt3Ai3J9v3RPI7qwrN8wRMxQCfOIrz0g8rj1uSeq7re8oc9zkwEX5bJci3BmPb6j+j60p2MOw+3g5WEkh6zybWxOatcJp5nuxN18+DH6D8Bgsk/teSnQHqvNUsI12rb2Z5rn4uZJHTq0qccURD2Mu1llyszQyBcYdSZWBs7eoQBl0rq0ASB5nc83PPcL8VZC9uTjKoNFKnrUBQeFczGQ1JGPZnfbdEFMt1FOcCWZ9PwpTO7yiWhVz773h0kErcOcTA52gAqrpy0PtK6twOTFuClbkhDOTWeX7ZPRRDigO0=; 25:u9A/s9Z3nTxT5dIIDJidK0ajRni3Wll78yLvz9M6MJ7OtDfExZTq0A4kjt7h2gNSveVQpu7TMdDukmxoZpqRQklxzMm2P65dzuk06qg3vQkaMMrfA1e1rjc8UxUxX18gLveHPgz57REEfkGPGmXcd4Rbn/TIHqP05K1UX6Lt5Pil4t137ljKCVpmRkI9SCdix6kbre118L+ZFTe1OsWJHXkR42OxkITaGQooTqQxp+wAtiLOhyzH+2bfz0/t8uHWAUsKJEf1oIdzFoUSYwb8uQMG5MLnSXkJp83lT/bVa62UV9qsYBqlbjArgI1GZ3/ClR/c3wR8rUy6jYRhWX7EB1x5x6jLa4+KdjkbksMeOU8= X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN1PR0301MB0724: X-Microsoft-Exchange-Diagnostics: 1; BN1PR0301MB0724; 31:+EdrJg9INSBIJl3JEqTEWMwzbkop6xOuY3lkOehXqizE2Rfav9pSAqHGYh8UL0g0X8jP5u/4nYl+sRhmTdxCGMXDDzIRTmEnuKbwtnsUOIVrfjDN5gireF5P4O0RnmL/0PFT7jEShGwIlDxf2E4hGccPPgzLStmfS/cEdwycK+GYZifOopBucTxwI/DWb9ZbvR9UPYTOQDYGmus6gxpbea+BiMxcDYc9X/llDG7sqd4=; 4:K13cSx0wyQIj0DmM1BqjDoabi5omdi5rpYq/3UR4RJVEFlH1wZf00KXMONBP0uSLJRYJEROGsioqlS0QjzT/opLuX4SxKSdUJgt6gmKwlEpAeEfWdHpreYwVH6LBKduK23DickTJF3ZYB6kzPsQJSrg6BS/0POgibnAlXyjkNhFUlRgMdvc6URz4/OmGofDIyOqpYLJ/n2YRGHBCa5UjOnuJBcXfO2HqsRLeXtKcrNHQ+epDqi8OdU+N3R3eayJqsrT67tq3vCHb9EGa1388UYlCUcwbCIrEPrIWGIfCjBA/OGl1Riwghtcw8EMboCij 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)(3231023)(93006095)(93001095)(6055026)(6096035)(20161123561025)(20161123565025)(20161123559100)(20161123556025)(20161123563025)(201703131430075)(201703131520075)(201703131441075)(201703131448075)(201703131433075)(201703161259150)(201708071742011); SRVR:BN1PR0301MB0724; BCL:0; PCL:0; RULEID:(100000803101)(100110400095)(400006); SRVR:BN1PR0301MB0724; X-Forefront-PRVS: 052017CAF1 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN1PR0301MB0724; 23:JQInDzIn6cOZjmCqdycfL2m/+MxytniPUF5gdjT?= 6VBecy42JOlPpsXmVDYP66kvGQkMKlhHqd4dgL/cPo7hXrP0JvQMnEzb962e7AXPNyluPvVy/bmCk1vsMK2itKTpq7GG+R09RNwHelZtT6z3AXLoysVciS9sw/ffdRHhNzhvJcuyNa+Y+6ytOPFWjqgcTs43RuMhSf4QnSaCi7Cji9pg8cfAj/ZHrhSQjNHTZTbh7iA1QJgsbSjtkI/SZGiXtWaKfDS9TKVo6Uc+kMxQIKbLtamkIOHc+pQ4xuruHfHE4HUxJsanlrdQQu/9LKF8dDbLGebBDpHU60arP9+hCMTuU2cskJm+7NiIYf0jQDsJpci58xPKYxf91Po0Lc5Ks3y43brwCoqbFI1ZHNGI+urgrs/ywsCDch8w4dqLqFE+c49Zaq324V/IGWJ0RfHHKz4l+V9TLVbgbZU/mt9V3HvQpODEgn1VrjIkikUvLIiQMOpWgApE9LgASSDdX06uaUIUr32066yV/qZ3M39Foy9bYZldaJsZ6OchZhXKiQcXJ6T4eFOq1LI0Emt7hV0Za588YYp5zQ8/2+nE81FT4zuqrxXaqDnhU0JiZNihjFaX3MXVh9ccDcQ517mjvG6ywKERnsVO+iBLfgirfR2+32uQCnLORxQ883cfa2TS5w7jMje8UE7YtBQ6cobCQLPiHmnYFMtZ8KWdLmE2Zdrt1zc58U5eER2MIOeAh9NoxJYX6Y783V2YzjYKrqw6G3nAx3K/Jfk+Yi0QM/7G1YvcN0W8qg/2kvm7nKFp+a4My/nM5F2C3Vvkp+cNaUMoDhOg0pbUi5/nE0ch82Pl1PbkCKecYf1vCf9fwliQHhO8iLNoHeW29eOdk2aHgTNgGv/sW7BbvibUNH+rJrOAzi0lWp9OGYZrXB+NrUMuZwibEliC4CifVmEB0SB6XVI8lywymgU0qXv9PmQh25sGtP3StNakhRSxYx/rkhsQ1ADecIvBxrXoGUmpwuOHdtZsNqVPQGxhkP5f+I42nZM4KmyjfE6go7JDgOeXm/47Kv6BQjJFMV0RPTJbkTojxG1gdvnH7JBAVUL8G5sUqxv42EUpqUCfSx43j8l+YI23ivYHn1u06PrC9RXBvqRfnaaCFEIesbUOdR8EcJnS/LMV0AI2EKDUGg+SCUDhmANP5x3fdWUc= X-Microsoft-Exchange-Diagnostics: 1; BN1PR0301MB0724; 6:JkWO8FLDn20OvdGRE+CLIoDFGD8cRhuV1j3+uC1svR2BmN9yOVz6tqW7sOFKt8QRwV3fcGuAzb0VSEsmh5o73VwELaW58qv+ROvs5tThuTty8LJqi6rpDDyTats+tyYnoi9Fuu1sicV7YLjd8juPc+D+C3+oTlCqXSjJj+9X8iNZ7j9rKtJpvPMOLhj8AhsUqBiboRLqixe1rRdArfgUPy7j6kdH7KrKdtVh92B/4vMtGq+3TqrburJtSw5n4kw5shQlruhWCg37mTs6koCJZ+2302cexDjfyk8VJ9KTYoYMGHB7//Ah1jmBSzARYQmxeJD/LYaqECLpqvA+a1le+5ytI1754MeQUGWJlwoT/pE=; 5:hq2vbyzz6UKK00qBYV0cYtHcljgAUr3KjWGrZSBUJEoYGAS62URqGqUunyc07oHdMo6seo4l3GL25Uoum4oYQbhrAQA+rfrZa0BSwt2G9eEvOo630/85dtXMwQej2KuZiIUQ7b7byKpaRMSzcnTBN909A7uNY9L5SOsklOoiyY0=; 24:Cc5d3bNg8a76ZeByRLHgEMNxVgu7m7U94cLis9u4k2pNgS1NTpZm0WBF5NB//HA/EwAmVgCF7mHJ8R6e4B1Q/T7xjMqk5WDZHVONLvenwLs=; 7:nj4dozfie69Ysfnoj6eR45BXWx0YW5ruTe95oA69jvFZ3smRFn7IjQ0eQg3tzk/5HvedbSM4s4TyfXrrHtbp6SvkyBrwMx9F42mcEen+C0RdAtFpA21NQjcFVNyqnBYvqVMfKI9saFTs7A+iLNAvFkVbM5wDBrWgVXknGAE3BlFgTlh+zOl774dL9lTmyoHMOVhPIQ9hi/gG53ue52q6bMS6RMVOJY/lqMCJE/1Z8b5D0BEI5ZiP3/oID4avFFOY SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Dec 2017 14:00:33.9411 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 86a915f7-e70f-455a-8388-08d54231e12a 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: BN1PR0301MB0724 Subject: [dpdk-dev] [PATCH 2/5] 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 a1271be..b51db83 100644 --- a/drivers/crypto/dpaa_sec/dpaa_sec.c +++ b/drivers/crypto/dpaa_sec/dpaa_sec.c @@ -69,6 +69,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) { @@ -177,15 +180,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; @@ -197,9 +191,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; } @@ -383,7 +379,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; @@ -903,12 +899,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; } /* @@ -944,7 +938,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; @@ -1160,43 +1154,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 @@ -1259,8 +1292,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 @@ -1293,6 +1338,7 @@ dpaa_sec_session_configure(struct rte_cryptodev *dev, set_session_private_data(sess, dev->driver_id, sess_private_data); + return 0; } @@ -1301,16 +1347,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); } @@ -1358,7 +1410,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; } } @@ -1403,7 +1456,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]; @@ -1419,7 +1472,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++) { @@ -1430,10 +1483,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 eba07b6..11407d3 100644 --- a/drivers/crypto/dpaa_sec/dpaa_sec.h +++ b/drivers/crypto/dpaa_sec/dpaa_sec.h @@ -64,36 +64,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 */ @@ -143,11 +113,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; @@ -155,12 +155,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; };