From patchwork Wed Nov 6 05:17:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 178603 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp127568ilf; Tue, 5 Nov 2019 21:22:23 -0800 (PST) X-Google-Smtp-Source: APXvYqzAi6VYbT6dD1YFqQnyflbSxzDuNVaQNIRxBGFuuAGDzfVVCigxl8O+nJDNMrc7ZC0AtRpI X-Received: by 2002:aa7:ce96:: with SMTP id y22mr690110edv.100.1573017743349; Tue, 05 Nov 2019 21:22:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573017743; cv=none; d=google.com; s=arc-20160816; b=tnq2bLUy7T6zRuEulccNzUJG4H2at9SUbH5USDFo0NgQKRNT1gp8GtTT4tidWHrJXW a+pBjw1YYtDPL53IaNkDIp1u4+Gy3AvByhtExz9IsqaJiXNPQyIYdvbH7tkV34J1F3tQ ylsEiznxQfDgCUcgmP2aLa2A0IYGAzQfMCtsxK9uGyPP+9iUV+LHNT/GUzEAMHEgAFMH ODjCm0v8no4AW2L80+QJiuQrDpJkVLzJ9gW30jt153XOmjsJFLmWUqo7DGXCBmGB0FKM 2vaPtuulLzXjuPxdVcRripQEe6Btnx2fFGx1N+dcnj+1U7Qwh1XxnBPXAWU8fkzHRTzN GtkA== 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=V8j4Hl0f2YzF9nyT3Q9u6mc0gsY6QAsNdNiM+iv+BRI=; b=slqQ10odPTvv+Gc1f0QVUm4gddBo3TKc5XMso3z/L2t4nG10To8xjFxx2a3eELOY+d GA5Q4vvNykrJWtn37at86cgu2OacfkGgK0efQHwbkzYcQ5msVIGLjrO4pGG6tX6lf/x+ l2KVetnmOz/BFUsGcCHFj7tDEtknRg8O+IZAuNpkF3s1cxQG8fZOz8lEr5XvnDnYwIJ2 rP4BTXN2uSD+UldmmGBzERuFl2c+bJTKuu9WNgismPobLYToNS7E/v/f7P17mJwAImgU G78eYM6/SxeqH3lfzydFJnpvmCW4lMaxD9FI7/4y4e85aqtRrvR+r4xiN7J26tDFwbBE iKHw== 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 g27si10527972ejc.219.2019.11.05.21.22.23; Tue, 05 Nov 2019 21:22:23 -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 DF28C1C014; Wed, 6 Nov 2019 06:21:01 +0100 (CET) Received: from inva021.nxp.com (inva021.nxp.com [92.121.34.21]) by dpdk.org (Postfix) with ESMTP id 420691BF8F for ; Wed, 6 Nov 2019 06:20:45 +0100 (CET) Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 2316020059D; Wed, 6 Nov 2019 06:20:45 +0100 (CET) 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 7F483200302; Wed, 6 Nov 2019 06:20:43 +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 4B616402A9; Wed, 6 Nov 2019 13:20:41 +0800 (SGT) From: Hemant Agrawal To: dev@dpdk.org Cc: akhil.goyal@nxp.com Date: Wed, 6 Nov 2019 10:47:31 +0530 Message-Id: <20191106051731.3625-13-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191106051731.3625-1-hemant.agrawal@nxp.com> References: <20191101175141.4663-1-hemant.agrawal@nxp.com> <20191106051731.3625-1-hemant.agrawal@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH v3 13/13] crypto/dpaa_sec: enable ipsec aes-ctr to use nonce 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: Vakul Garg The protocol aware ipsec descriptor has been modified to use ctr_initial value of 1 and salt configured for ipsec SA. Signed-off-by: Hemant Agrawal Signed-off-by: Vakul Garg --- drivers/common/dpaax/caamflib/desc/ipsec.h | 18 ++++++++---------- drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 8 ++++++++ drivers/crypto/dpaa_sec/dpaa_sec.c | 12 ++++++++++-- 3 files changed, 26 insertions(+), 12 deletions(-) -- 2.17.1 diff --git a/drivers/common/dpaax/caamflib/desc/ipsec.h b/drivers/common/dpaax/caamflib/desc/ipsec.h index f33c68cc9..cf6fa4252 100644 --- a/drivers/common/dpaax/caamflib/desc/ipsec.h +++ b/drivers/common/dpaax/caamflib/desc/ipsec.h @@ -256,14 +256,14 @@ struct ipsec_encap_cbc { /** * struct ipsec_encap_ctr - PDB part for IPsec CTR encapsulation - * @ctr_nonce: 4-byte array nonce + * @ctr_nonce: 4-byte nonce * @ctr_initial: initial count constant * @iv: initialization vector */ struct ipsec_encap_ctr { - uint8_t ctr_nonce[4]; + uint32_t ctr_nonce; uint32_t ctr_initial; - uint64_t iv; + uint8_t iv[8]; }; /** @@ -346,10 +346,9 @@ __rta_copy_ipsec_encap_pdb(struct program *program, break; case OP_PCL_IPSEC_AES_CTR: - rta_copy_data(program, pdb->ctr.ctr_nonce, - sizeof(pdb->ctr.ctr_nonce)); + rta_copy_data(program, (uint8_t *)&pdb->ctr.ctr_nonce, 4); __rta_out32(program, pdb->ctr.ctr_initial); - __rta_out64(program, true, pdb->ctr.iv); + rta_copy_data(program, pdb->ctr.iv, sizeof(pdb->ctr.iv)); break; case OP_PCL_IPSEC_AES_CCM8: @@ -386,11 +385,11 @@ struct ipsec_decap_cbc { /** * struct ipsec_decap_ctr - PDB part for IPsec CTR decapsulation - * @ctr_nonce: 4-byte array nonce + * @ctr_nonce: 4-byte nonce * @ctr_initial: initial count constant */ struct ipsec_decap_ctr { - uint8_t ctr_nonce[4]; + uint32_t ctr_nonce; uint32_t ctr_initial; }; @@ -464,8 +463,7 @@ __rta_copy_ipsec_decap_pdb(struct program *program, break; case OP_PCL_IPSEC_AES_CTR: - rta_copy_data(program, pdb->ctr.ctr_nonce, - sizeof(pdb->ctr.ctr_nonce)); + rta_copy_data(program, (uint8_t *)&pdb->ctr.ctr_nonce, 4); __rta_out32(program, pdb->ctr.ctr_initial); break; diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c index 46925be5f..555730519 100644 --- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c +++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c @@ -2811,6 +2811,10 @@ dpaa2_sec_set_ipsec_session(struct rte_cryptodev *dev, /* copy algo specific data to PDB */ switch (cipherdata.algtype) { + case OP_PCL_IPSEC_AES_CTR: + encap_pdb.ctr.ctr_initial = 0x00000001; + encap_pdb.ctr.ctr_nonce = ipsec_xform->salt; + break; case OP_PCL_IPSEC_AES_GCM8: case OP_PCL_IPSEC_AES_GCM12: case OP_PCL_IPSEC_AES_GCM16: @@ -2881,6 +2885,10 @@ dpaa2_sec_set_ipsec_session(struct rte_cryptodev *dev, memset(&decap_pdb, 0, sizeof(struct ipsec_decap_pdb)); /* copy algo specific data to PDB */ switch (cipherdata.algtype) { + case OP_PCL_IPSEC_AES_CTR: + decap_pdb.ctr.ctr_initial = 0x00000001; + decap_pdb.ctr.ctr_nonce = ipsec_xform->salt; + break; case OP_PCL_IPSEC_AES_GCM8: case OP_PCL_IPSEC_AES_GCM12: case OP_PCL_IPSEC_AES_GCM16: diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c b/drivers/crypto/dpaa_sec/dpaa_sec.c index 2c1915fec..b0fa74540 100644 --- a/drivers/crypto/dpaa_sec/dpaa_sec.c +++ b/drivers/crypto/dpaa_sec/dpaa_sec.c @@ -2592,6 +2592,7 @@ dpaa_sec_ipsec_aead_init(struct rte_crypto_aead_xform *aead_xform, static int dpaa_sec_ipsec_proto_init(struct rte_crypto_cipher_xform *cipher_xform, struct rte_crypto_auth_xform *auth_xform, + struct rte_security_ipsec_xform *ipsec_xform, dpaa_sec_session *session) { if (cipher_xform) { @@ -2698,6 +2699,13 @@ dpaa_sec_ipsec_proto_init(struct rte_crypto_cipher_xform *cipher_xform, case RTE_CRYPTO_CIPHER_AES_CTR: session->cipher_key.alg = OP_PCL_IPSEC_AES_CTR; session->cipher_key.algmode = OP_ALG_AAI_CTR; + if (session->dir == DIR_ENC) { + session->encap_pdb.ctr.ctr_initial = 0x00000001; + session->encap_pdb.ctr.ctr_nonce = ipsec_xform->salt; + } else { + session->decap_pdb.ctr.ctr_initial = 0x00000001; + session->decap_pdb.ctr.ctr_nonce = ipsec_xform->salt; + } break; case RTE_CRYPTO_CIPHER_NULL: session->cipher_key.alg = OP_PCL_IPSEC_NULL; @@ -2749,13 +2757,13 @@ dpaa_sec_set_ipsec_session(__rte_unused struct rte_cryptodev *dev, if (conf->crypto_xform->next) auth_xform = &conf->crypto_xform->next->auth; ret = dpaa_sec_ipsec_proto_init(cipher_xform, auth_xform, - session); + ipsec_xform, session); } else if (conf->crypto_xform->type == RTE_CRYPTO_SYM_XFORM_AUTH) { auth_xform = &conf->crypto_xform->auth; if (conf->crypto_xform->next) cipher_xform = &conf->crypto_xform->next->cipher; ret = dpaa_sec_ipsec_proto_init(cipher_xform, auth_xform, - session); + ipsec_xform, session); } else if (conf->crypto_xform->type == RTE_CRYPTO_SYM_XFORM_AEAD) { aead_xform = &conf->crypto_xform->aead; ret = dpaa_sec_ipsec_aead_init(aead_xform,