diff mbox series

[v4,09/10] crypto/dpaa_sec: force inline of the keys to save space

Message ID 20210908065953.28349-9-hemant.agrawal@nxp.com (mailing list archive)
State Accepted, archived
Delegated to: akhil goyal
Headers show
Series [v4,01/10] crypto/dpaa_sec: support DES-CBC | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Hemant Agrawal Sept. 8, 2021, 6:59 a.m. UTC
From: Gagandeep Singh <g.singh@nxp.com>

This patch improve storage and performance by force inline
of the keys.

Signed-off-by: Franck LENORMAND <franck.lenormand@nxp.com>
Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/crypto/dpaa_sec/dpaa_sec.c | 35 ++++++++++++++++++++++--------
 1 file changed, 26 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c b/drivers/crypto/dpaa_sec/dpaa_sec.c
index c5416df726..10ef990886 100644
--- a/drivers/crypto/dpaa_sec/dpaa_sec.c
+++ b/drivers/crypto/dpaa_sec/dpaa_sec.c
@@ -1,7 +1,7 @@ 
 /* SPDX-License-Identifier: BSD-3-Clause
  *
  *   Copyright (c) 2016 Freescale Semiconductor, Inc. All rights reserved.
- *   Copyright 2017-2019 NXP
+ *   Copyright 2017-2021 NXP
  *
  */
 
@@ -263,14 +263,31 @@  dpaa_sec_prep_pdcp_cdb(dpaa_sec_session *ses)
 		p_authdata = &authdata;
 	}
 
-	if (rta_inline_pdcp_query(authdata.algtype,
-				cipherdata.algtype,
-				ses->pdcp.sn_size,
-				ses->pdcp.hfn_ovd)) {
-		cipherdata.key =
-			(size_t)rte_dpaa_mem_vtop((void *)
-					(size_t)cipherdata.key);
-		cipherdata.key_type = RTA_DATA_PTR;
+	if (ses->pdcp.sdap_enabled) {
+		int nb_keys_to_inline =
+				rta_inline_pdcp_sdap_query(authdata.algtype,
+					cipherdata.algtype,
+					ses->pdcp.sn_size,
+					ses->pdcp.hfn_ovd);
+		if (nb_keys_to_inline >= 1) {
+			cipherdata.key = (size_t)rte_dpaa_mem_vtop((void *)
+						(size_t)cipherdata.key);
+			cipherdata.key_type = RTA_DATA_PTR;
+		}
+		if (nb_keys_to_inline >= 2) {
+			authdata.key = (size_t)rte_dpaa_mem_vtop((void *)
+						(size_t)authdata.key);
+			authdata.key_type = RTA_DATA_PTR;
+		}
+	} else {
+		if (rta_inline_pdcp_query(authdata.algtype,
+					cipherdata.algtype,
+					ses->pdcp.sn_size,
+					ses->pdcp.hfn_ovd)) {
+			cipherdata.key = (size_t)rte_dpaa_mem_vtop((void *)
+						(size_t)cipherdata.key);
+			cipherdata.key_type = RTA_DATA_PTR;
+		}
 	}
 
 	if (ses->pdcp.domain == RTE_SECURITY_PDCP_MODE_CONTROL) {