[3/3] crypto/ipsec_mb: check SGL support for algorithm

Message ID 20220407103041.4037942-4-ciara.power@intel.com (mailing list archive)
State Superseded, archived
Delegated to: akhil goyal
Headers
Series add partial SGL support to AESNI_MB |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/github-robot: build success github build: passed
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS

Commit Message

Power, Ciara April 7, 2022, 10:30 a.m. UTC
  This patch adds a check when dequeueing ops and processing, SGL support
only exists for AES-GCM and CHACHA20_POLY1305 algorithms.
If an SGL op for an unsupported algorithm is being processed,
submit a NULL job instead.

Signed-off-by: Ciara Power <ciara.power@intel.com>
---
 drivers/crypto/ipsec_mb/pmd_aesni_mb.c | 7 +++++++
 1 file changed, 7 insertions(+)
  

Comments

De Lara Guarch, Pablo May 8, 2022, 2:39 p.m. UTC | #1
Hi Ciara,

> -----Original Message-----
> From: Power, Ciara <ciara.power@intel.com>
> Sent: Thursday, April 7, 2022 11:31 AM
> To: dev@dpdk.org
> Cc: Zhang, Roy Fan <roy.fan.zhang@intel.com>; Ji, Kai <kai.ji@intel.com>;
> Power, Ciara <ciara.power@intel.com>; De Lara Guarch, Pablo
> <pablo.de.lara.guarch@intel.com>
> Subject: [PATCH 3/3] crypto/ipsec_mb: check SGL support for algorithm
> 
> This patch adds a check when dequeueing ops and processing, SGL support only
> exists for AES-GCM and CHACHA20_POLY1305 algorithms.
> If an SGL op for an unsupported algorithm is being processed, submit a NULL job
> instead.
> 
> Signed-off-by: Ciara Power <ciara.power@intel.com>
> ---
>  drivers/crypto/ipsec_mb/pmd_aesni_mb.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/crypto/ipsec_mb/pmd_aesni_mb.c
> b/drivers/crypto/ipsec_mb/pmd_aesni_mb.c
> index 606c8a0caf..9b21c14f58 100644
> --- a/drivers/crypto/ipsec_mb/pmd_aesni_mb.c
> +++ b/drivers/crypto/ipsec_mb/pmd_aesni_mb.c
> @@ -1202,6 +1202,13 @@ set_mb_job_params(IMB_JOB *job, struct
> ipsec_mb_qp *qp,
>  	if (op->sym->m_src->nb_segs > 1)
>  		sgl = 1;
> 
> +	if (sgl && (session->cipher.mode != IMB_CIPHER_GCM
> +			&& session->cipher.mode !=
> IMB_CIPHER_CHACHA20_POLY1305)) {
> +		op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
> +		IPSEC_MB_LOG(ERR, "Device only supports SGL for AES-GCM or
> CHACHA20_POLY1305 algorithms.");

You can use check for cipher.mode inside the previous if, and avoid checking for "sgl" again.
  

Patch

diff --git a/drivers/crypto/ipsec_mb/pmd_aesni_mb.c b/drivers/crypto/ipsec_mb/pmd_aesni_mb.c
index 606c8a0caf..9b21c14f58 100644
--- a/drivers/crypto/ipsec_mb/pmd_aesni_mb.c
+++ b/drivers/crypto/ipsec_mb/pmd_aesni_mb.c
@@ -1202,6 +1202,13 @@  set_mb_job_params(IMB_JOB *job, struct ipsec_mb_qp *qp,
 	if (op->sym->m_src->nb_segs > 1)
 		sgl = 1;
 
+	if (sgl && (session->cipher.mode != IMB_CIPHER_GCM
+			&& session->cipher.mode != IMB_CIPHER_CHACHA20_POLY1305)) {
+		op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
+		IPSEC_MB_LOG(ERR, "Device only supports SGL for AES-GCM or CHACHA20_POLY1305 algorithms.");
+		return -1;
+	}
+
 	/* Set crypto operation */
 	job->chain_order = session->chain_order;