crypto/dpaa_sec: force inline keys to save space
authorFranck Lenormand <franck.lenormand@nxp.com>
Wed, 8 Sep 2021 06:59:52 +0000 (12:29 +0530)
committerAkhil Goyal <gakhil@marvell.com>
Wed, 8 Sep 2021 10:11:45 +0000 (12:11 +0200)
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>
Acked-by: Akhil Goyal <gakhil@marvell.com>
drivers/crypto/dpaa_sec/dpaa_sec.c

index d6c1013..fa4d276 100644 (file)
@@ -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) {