From patchwork Fri Nov 1 17:51:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 178323 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp823581ill; Fri, 1 Nov 2019 10:55:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqzXL4r7Kwk5JqTRM/Eu2pQYGEAxNEIKjfz7WOeH2XQ5IlsebeBR5QiqkRONilmf7rESgvKs X-Received: by 2002:a05:6402:12d5:: with SMTP id k21mr14452664edx.56.1572630917944; Fri, 01 Nov 2019 10:55:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572630917; cv=none; d=google.com; s=arc-20160816; b=sS2qS2mz5kKWf5F22AIjjHvFQYo9U4UwySRkXRILSCEDDyiOnwz2dpGVEG2BXOZwQt kaXW1AeS0z8UZyKSm0lK38c44xLJJ0a0qhszKWvgNpBPZA9vp6R2qon3V0pOVkjUIZ8J UD0Fl2Vg2gBf7i4yX4r/gTcKYDlNgeXAo+bRo/iT6oCoQgQR32zeVHUZg4vXXMK+rGYZ FkmeXl9HnKlZMyV1os8iKlCjbrv7gYIPEF+Aqzq+V1/7ikipBIR9pDAEydG8ugXDWP17 NNhTaveB7HmvcsxKHwiYiVc7FXq4lmyKVYx0koqXNIzQ4zFSEQrNT547HgJCRYmz9FoB c9Qw== 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:to:from; bh=0ohOqfd8uDWUSx1JDRv3gJOY5sbnz05W74vGSp65ZGY=; b=NA57u6dMhqaTst0tJltIZHjcrTGNEkBWuypw7rtzzCthGUIkmg7LEJNAS3Zgqs5ud1 YEr91V0PGIEc03cuvtEWtBoqm+f/9nt22SbfG8ezC5l/6cQ9k7cgF8Z8feLydbK8Jjax UWsed/+sBbKhGYU0BiPUwxeVQgiotVobVObxvo3VA9aIni7gq/sJGRf0izCv6LYRn/2Y 32fkUqDR8rXt2b76XsBvL1t7JhJp7EgGWZqlRTV4km40dfOrpBNTuwgBPLF0CZXICboD GAQOytgFKqUspGelKRMlCF6MgL96CN34cBxFlb4ecSpi+sPYY3X4sggamXXiMKL6g9cw t1Cw== 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 nn22si6585202ejb.258.2019.11.01.10.55.17; Fri, 01 Nov 2019 10:55:17 -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 0CFBE1E886; Fri, 1 Nov 2019 18:54:55 +0100 (CET) Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by dpdk.org (Postfix) with ESMTP id ACF351E862 for ; Fri, 1 Nov 2019 18:54:48 +0100 (CET) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 878BE1A08A2; Fri, 1 Nov 2019 18:54:48 +0100 (CET) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id E69571A0125; Fri, 1 Nov 2019 18:54:46 +0100 (CET) Received: from bf-netperf1.ap.freescale.net (bf-netperf1.ap.freescale.net [10.232.133.63]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id B798640318; Sat, 2 Nov 2019 01:54:44 +0800 (SGT) From: Hemant Agrawal To: dev@dpdk.org, akhil.goyal@nxp.com Date: Fri, 1 Nov 2019 23:21:33 +0530 Message-Id: <20191101175141.4663-5-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191101175141.4663-1-hemant.agrawal@nxp.com> References: <20191025083336.24212-1-hemant.agrawal@nxp.com> <20191101175141.4663-1-hemant.agrawal@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH v2 05/13] crypto/dpaa_sec: adding NULL cipher or NULL auth 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" These are supported when using protocol offload mode or when in chain mode. Signed-off-by: Hemant Agrawal --- drivers/crypto/dpaa_sec/dpaa_sec.c | 33 ++++++++++++++++++------ drivers/crypto/dpaa_sec/dpaa_sec.h | 41 ++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 8 deletions(-) -- 2.17.1 diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c b/drivers/crypto/dpaa_sec/dpaa_sec.c index 8704fe33d..ce7860b24 100644 --- a/drivers/crypto/dpaa_sec/dpaa_sec.c +++ b/drivers/crypto/dpaa_sec/dpaa_sec.c @@ -2037,6 +2037,7 @@ dpaa_sec_cipher_init(struct rte_cryptodev *dev __rte_unused, struct rte_crypto_sym_xform *xform, dpaa_sec_session *session) { + session->ctxt = DPAA_SEC_CIPHER; session->cipher_alg = xform->cipher.algo; session->iv.length = xform->cipher.iv.length; session->iv.offset = xform->cipher.iv.offset; @@ -2086,6 +2087,7 @@ dpaa_sec_auth_init(struct rte_cryptodev *dev __rte_unused, struct rte_crypto_sym_xform *xform, dpaa_sec_session *session) { + session->ctxt = DPAA_SEC_AUTH; session->auth_alg = xform->auth.algo; session->auth_key.data = rte_zmalloc(NULL, xform->auth.key.length, RTE_CACHE_LINE_SIZE); @@ -2158,6 +2160,7 @@ dpaa_sec_chain_init(struct rte_cryptodev *dev __rte_unused, struct rte_crypto_cipher_xform *cipher_xform; struct rte_crypto_auth_xform *auth_xform; + session->ctxt = DPAA_SEC_CIPHER_HASH; if (session->auth_cipher_text) { cipher_xform = &xform->cipher; auth_xform = &xform->next->auth; @@ -2359,6 +2362,7 @@ dpaa_sec_set_session_parameters(struct rte_cryptodev *dev, struct dpaa_sec_dev_private *internals = dev->data->dev_private; dpaa_sec_session *session = sess; uint32_t i; + int ret; PMD_INIT_FUNC_TRACE(); @@ -2374,23 +2378,26 @@ dpaa_sec_set_session_parameters(struct rte_cryptodev *dev, /* Cipher Only */ if (xform->type == RTE_CRYPTO_SYM_XFORM_CIPHER && xform->next == NULL) { session->auth_alg = RTE_CRYPTO_AUTH_NULL; - session->ctxt = DPAA_SEC_CIPHER; - dpaa_sec_cipher_init(dev, xform, session); + ret = dpaa_sec_cipher_init(dev, xform, session); /* Authentication Only */ } else if (xform->type == RTE_CRYPTO_SYM_XFORM_AUTH && xform->next == NULL) { session->cipher_alg = RTE_CRYPTO_CIPHER_NULL; session->ctxt = DPAA_SEC_AUTH; - dpaa_sec_auth_init(dev, xform, session); + ret = dpaa_sec_auth_init(dev, xform, session); /* Cipher then Authenticate */ } else if (xform->type == RTE_CRYPTO_SYM_XFORM_CIPHER && xform->next->type == RTE_CRYPTO_SYM_XFORM_AUTH) { if (xform->cipher.op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) { - session->ctxt = DPAA_SEC_CIPHER_HASH; session->auth_cipher_text = 1; - dpaa_sec_chain_init(dev, xform, session); + if (xform->cipher.algo == RTE_CRYPTO_CIPHER_NULL) + ret = dpaa_sec_auth_init(dev, xform, session); + else if (xform->next->auth.algo == RTE_CRYPTO_AUTH_NULL) + ret = dpaa_sec_cipher_init(dev, xform, session); + else + ret = dpaa_sec_chain_init(dev, xform, session); } else { DPAA_SEC_ERR("Not supported: Auth then Cipher"); return -EINVAL; @@ -2399,9 +2406,14 @@ dpaa_sec_set_session_parameters(struct rte_cryptodev *dev, } else if (xform->type == RTE_CRYPTO_SYM_XFORM_AUTH && xform->next->type == RTE_CRYPTO_SYM_XFORM_CIPHER) { if (xform->next->cipher.op == RTE_CRYPTO_CIPHER_OP_DECRYPT) { - session->ctxt = DPAA_SEC_CIPHER_HASH; session->auth_cipher_text = 0; - dpaa_sec_chain_init(dev, xform, session); + if (xform->auth.algo == RTE_CRYPTO_AUTH_NULL) + ret = dpaa_sec_cipher_init(dev, xform, session); + else if (xform->next->cipher.algo + == RTE_CRYPTO_CIPHER_NULL) + ret = dpaa_sec_auth_init(dev, xform, session); + else + ret = dpaa_sec_chain_init(dev, xform, session); } else { DPAA_SEC_ERR("Not supported: Auth then Cipher"); return -EINVAL; @@ -2410,12 +2422,17 @@ dpaa_sec_set_session_parameters(struct rte_cryptodev *dev, /* AEAD operation for AES-GCM kind of Algorithms */ } else if (xform->type == RTE_CRYPTO_SYM_XFORM_AEAD && xform->next == NULL) { - dpaa_sec_aead_init(dev, xform, session); + ret = dpaa_sec_aead_init(dev, xform, session); } else { DPAA_SEC_ERR("Invalid crypto type"); return -EINVAL; } + if (ret) { + DPAA_SEC_ERR("unable to init session"); + goto err1; + } + rte_spinlock_lock(&internals->lock); for (i = 0; i < MAX_DPAA_CORES; i++) { session->inq[i] = dpaa_sec_attach_rxq(internals); diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.h b/drivers/crypto/dpaa_sec/dpaa_sec.h index 32dc8268c..3ecc7eae5 100644 --- a/drivers/crypto/dpaa_sec/dpaa_sec.h +++ b/drivers/crypto/dpaa_sec/dpaa_sec.h @@ -218,6 +218,27 @@ struct dpaa_sec_op_ctx { }; static const struct rte_cryptodev_capabilities dpaa_sec_capabilities[] = { + { /* NULL (AUTH) */ + .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, + {.sym = { + .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH, + {.auth = { + .algo = RTE_CRYPTO_AUTH_NULL, + .block_size = 1, + .key_size = { + .min = 0, + .max = 0, + .increment = 0 + }, + .digest_size = { + .min = 0, + .max = 0, + .increment = 0 + }, + .iv_size = { 0 } + }, }, + }, }, + }, { /* MD5 HMAC */ .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, {.sym = { @@ -374,6 +395,26 @@ static const struct rte_cryptodev_capabilities dpaa_sec_capabilities[] = { }, } }, } }, + { /* NULL (CIPHER) */ + .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, + {.sym = { + .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER, + {.cipher = { + .algo = RTE_CRYPTO_CIPHER_NULL, + .block_size = 1, + .key_size = { + .min = 0, + .max = 0, + .increment = 0 + }, + .iv_size = { + .min = 0, + .max = 0, + .increment = 0 + } + }, }, + }, } + }, { /* AES CBC */ .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, {.sym = {