From patchwork Mon Sep 30 14:41:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil Goyal X-Patchwork-Id: 174767 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp7243206ill; Mon, 30 Sep 2019 08:00:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqymgj+PTbnaeelJox5m4Fg/Hghz9ozX29FkHcNWCrpqftIy1kud6vxCHZQlgJJ5A2zpUlAu X-Received: by 2002:a17:906:2542:: with SMTP id j2mr20091007ejb.278.1569855639173; Mon, 30 Sep 2019 08:00:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569855639; cv=none; d=google.com; s=arc-20160816; b=jmIAu/ZlyMNrpc7E09jJLM7+r+Y/ax8JRHZiM+R/+07ApMVRSi1n/uBDQWPxpchmlu hpDvloW0WQxelM2QBUYlz+TSQZETIFv4rOhYw6iwYT9W+ke13C/G9GRlwbU+34wEy3sm r2c7Slf2ME4PiE8dIEYGS1r5mkt31buIl0T5ENLSLOMLgcLmeEw3ZGUVjCSIqFoa15i7 SSIE6gAzNSzWrPdwPT6FgJHcGAFR61FEuM5p5coiNYNkXwao0p7s5SlRFQiKkyc0GnRA KRaLC+6vLGyrFXgIDPl0r9ygtz3+J9gXOFXDUkSztC3mi3vfgfp2+h1ObOhraYjt9Ll3 Wm8g== 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:references:in-reply-to :message-id:date:cc:to:from; bh=kDSxz1ZxDCTRJQz9wVv6hW9v7zQ+8RQ/qzoD9oKK2sA=; b=Tj/kK+6ETbUQROnF85qmIH99NPGg1ClWCvg7DtQRj6QjMSkxxN3zlGZz0QMaz8p1WI WU9pFBirKmNhdnZ3tgto2AyAT92lSrK2SQR3QHGQ/A6X08LT8P27P2VW84MJS+FmEjwu cun7fFoMvJy8QVV53sjeCYPl31/uDS9zYQDGebis6jjhMWqZk24ZUNq63L8K1lDn3Ak8 BdFgc2TSojw+Sii2FrQ4ZVPNhiFhp0JnLVrH1N4SqVkjPgD1kQ2f+9xfZJ0tOOPy2GsJ HoIHYNxRtM/43g0UMq6BJEP4Fx4aEMtlyzPWhdxmjk429HKhAcnA55j47MIYXyPasJM2 gQqQ== 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 k2si7135788ede.311.2019.09.30.08.00.38; Mon, 30 Sep 2019 08:00:39 -0700 (PDT) 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 581BF1BF5B; Mon, 30 Sep 2019 16:57:56 +0200 (CEST) Received: from inva021.nxp.com (inva021.nxp.com [92.121.34.21]) by dpdk.org (Postfix) with ESMTP id C36E61BED5 for ; Mon, 30 Sep 2019 16:56:43 +0200 (CEST) Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id A18B420008A; Mon, 30 Sep 2019 16:56:43 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 47A1920049E; Mon, 30 Sep 2019 16:56:41 +0200 (CEST) Received: from GDB1.ap.freescale.net (GDB1.ap.freescale.net [10.232.132.179]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 45F3B40313; Mon, 30 Sep 2019 22:56:38 +0800 (SGT) From: Akhil Goyal To: dev@dpdk.org Cc: aconole@redhat.com, anoobj@marvell.com, Hemant Agrawal Date: Mon, 30 Sep 2019 20:11:02 +0530 Message-Id: <20190930144104.12742-23-akhil.goyal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190930144104.12742-1-akhil.goyal@nxp.com> References: <20190930115237.5073-1-akhil.goyal@nxp.com> <20190930144104.12742-1-akhil.goyal@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH v3 22/24] crypto/dpaa_sec: dynamic contxt buffer for SG cases 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 This patch allocate/clean the SEC context dynamically based on the number of SG entries in the buffer. Signed-off-by: Hemant Agrawal Acked-by: Akhil Goyal --- drivers/crypto/dpaa_sec/dpaa_sec.c | 43 ++++++++++++++---------------- drivers/crypto/dpaa_sec/dpaa_sec.h | 8 +++--- 2 files changed, 23 insertions(+), 28 deletions(-) -- 2.17.1 diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c b/drivers/crypto/dpaa_sec/dpaa_sec.c index 291cba28d..fa9d03adc 100644 --- a/drivers/crypto/dpaa_sec/dpaa_sec.c +++ b/drivers/crypto/dpaa_sec/dpaa_sec.c @@ -65,10 +65,10 @@ dpaa_sec_op_ending(struct dpaa_sec_op_ctx *ctx) } static inline struct dpaa_sec_op_ctx * -dpaa_sec_alloc_ctx(dpaa_sec_session *ses) +dpaa_sec_alloc_ctx(dpaa_sec_session *ses, int sg_count) { struct dpaa_sec_op_ctx *ctx; - int retval; + int i, retval; retval = rte_mempool_get(ses->ctx_pool, (void **)(&ctx)); if (!ctx || retval) { @@ -81,14 +81,11 @@ dpaa_sec_alloc_ctx(dpaa_sec_session *ses) * to clear all the SG entries. dpaa_sec_alloc_ctx() is called for * each packet, memset is costlier than dcbz_64(). */ - dcbz_64(&ctx->job.sg[SG_CACHELINE_0]); - dcbz_64(&ctx->job.sg[SG_CACHELINE_1]); - dcbz_64(&ctx->job.sg[SG_CACHELINE_2]); - dcbz_64(&ctx->job.sg[SG_CACHELINE_3]); + for (i = 0; i < sg_count && i < MAX_JOB_SG_ENTRIES; i += 4) + dcbz_64(&ctx->job.sg[i]); ctx->ctx_pool = ses->ctx_pool; - ctx->vtop_offset = (size_t) ctx - - rte_mempool_virt2iova(ctx); + ctx->vtop_offset = (size_t) ctx - rte_mempool_virt2iova(ctx); return ctx; } @@ -855,12 +852,12 @@ build_auth_only_sg(struct rte_crypto_op *op, dpaa_sec_session *ses) else extra_segs = 2; - if ((mbuf->nb_segs + extra_segs) > MAX_SG_ENTRIES) { + if (mbuf->nb_segs > MAX_SG_ENTRIES) { DPAA_SEC_DP_ERR("Auth: Max sec segs supported is %d", MAX_SG_ENTRIES); return NULL; } - ctx = dpaa_sec_alloc_ctx(ses); + ctx = dpaa_sec_alloc_ctx(ses, mbuf->nb_segs + extra_segs); if (!ctx) return NULL; @@ -938,7 +935,7 @@ build_auth_only(struct rte_crypto_op *op, dpaa_sec_session *ses) rte_iova_t start_addr; uint8_t *old_digest; - ctx = dpaa_sec_alloc_ctx(ses); + ctx = dpaa_sec_alloc_ctx(ses, 4); if (!ctx) return NULL; @@ -1008,13 +1005,13 @@ build_cipher_only_sg(struct rte_crypto_op *op, dpaa_sec_session *ses) req_segs = mbuf->nb_segs * 2 + 3; } - if (req_segs > MAX_SG_ENTRIES) { + if (mbuf->nb_segs > MAX_SG_ENTRIES) { DPAA_SEC_DP_ERR("Cipher: Max sec segs supported is %d", MAX_SG_ENTRIES); return NULL; } - ctx = dpaa_sec_alloc_ctx(ses); + ctx = dpaa_sec_alloc_ctx(ses, req_segs); if (!ctx) return NULL; @@ -1094,7 +1091,7 @@ build_cipher_only(struct rte_crypto_op *op, dpaa_sec_session *ses) uint8_t *IV_ptr = rte_crypto_op_ctod_offset(op, uint8_t *, ses->iv.offset); - ctx = dpaa_sec_alloc_ctx(ses); + ctx = dpaa_sec_alloc_ctx(ses, 4); if (!ctx) return NULL; @@ -1161,13 +1158,13 @@ build_cipher_auth_gcm_sg(struct rte_crypto_op *op, dpaa_sec_session *ses) if (ses->auth_only_len) req_segs++; - if (req_segs > MAX_SG_ENTRIES) { + if (mbuf->nb_segs > MAX_SG_ENTRIES) { DPAA_SEC_DP_ERR("AEAD: Max sec segs supported is %d", MAX_SG_ENTRIES); return NULL; } - ctx = dpaa_sec_alloc_ctx(ses); + ctx = dpaa_sec_alloc_ctx(ses, req_segs); if (!ctx) return NULL; @@ -1296,7 +1293,7 @@ build_cipher_auth_gcm(struct rte_crypto_op *op, dpaa_sec_session *ses) else dst_start_addr = src_start_addr; - ctx = dpaa_sec_alloc_ctx(ses); + ctx = dpaa_sec_alloc_ctx(ses, 7); if (!ctx) return NULL; @@ -1409,13 +1406,13 @@ build_cipher_auth_sg(struct rte_crypto_op *op, dpaa_sec_session *ses) req_segs = mbuf->nb_segs * 2 + 4; } - if (req_segs > MAX_SG_ENTRIES) { + if (mbuf->nb_segs > MAX_SG_ENTRIES) { DPAA_SEC_DP_ERR("Cipher-Auth: Max sec segs supported is %d", MAX_SG_ENTRIES); return NULL; } - ctx = dpaa_sec_alloc_ctx(ses); + ctx = dpaa_sec_alloc_ctx(ses, req_segs); if (!ctx) return NULL; @@ -1533,7 +1530,7 @@ build_cipher_auth(struct rte_crypto_op *op, dpaa_sec_session *ses) else dst_start_addr = src_start_addr; - ctx = dpaa_sec_alloc_ctx(ses); + ctx = dpaa_sec_alloc_ctx(ses, 7); if (!ctx) return NULL; @@ -1619,7 +1616,7 @@ build_proto(struct rte_crypto_op *op, dpaa_sec_session *ses) struct qm_sg_entry *sg; phys_addr_t src_start_addr, dst_start_addr; - ctx = dpaa_sec_alloc_ctx(ses); + ctx = dpaa_sec_alloc_ctx(ses, 2); if (!ctx) return NULL; cf = &ctx->job; @@ -1666,13 +1663,13 @@ build_proto_sg(struct rte_crypto_op *op, dpaa_sec_session *ses) mbuf = sym->m_src; req_segs = mbuf->nb_segs + sym->m_src->nb_segs + 2; - if (req_segs > MAX_SG_ENTRIES) { + if (mbuf->nb_segs > MAX_SG_ENTRIES) { DPAA_SEC_DP_ERR("Proto: Max sec segs supported is %d", MAX_SG_ENTRIES); return NULL; } - ctx = dpaa_sec_alloc_ctx(ses); + ctx = dpaa_sec_alloc_ctx(ses, req_segs); if (!ctx) return NULL; cf = &ctx->job; diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.h b/drivers/crypto/dpaa_sec/dpaa_sec.h index 68461cecc..2a6a3fad7 100644 --- a/drivers/crypto/dpaa_sec/dpaa_sec.h +++ b/drivers/crypto/dpaa_sec/dpaa_sec.h @@ -183,13 +183,11 @@ struct dpaa_sec_dev_private { }; #define MAX_SG_ENTRIES 16 -#define SG_CACHELINE_0 0 -#define SG_CACHELINE_1 4 -#define SG_CACHELINE_2 8 -#define SG_CACHELINE_3 12 +#define MAX_JOB_SG_ENTRIES 36 + struct dpaa_sec_job { /* sg[0] output, sg[1] input, others are possible sub frames */ - struct qm_sg_entry sg[MAX_SG_ENTRIES]; + struct qm_sg_entry sg[MAX_JOB_SG_ENTRIES]; }; #define DPAA_MAX_NB_MAX_DIGEST 32