common/dpaax: remove dead code
authorGagandeep Singh <g.singh@nxp.com>
Thu, 17 Mar 2022 08:55:57 +0000 (14:25 +0530)
committerAkhil Goyal <gakhil@marvell.com>
Thu, 28 Apr 2022 06:54:50 +0000 (08:54 +0200)
This patch remove structural and logical dead code from
caamflib.

Coverity issue: 375251, 375258, 375261, 375267, 375269
Coverity issue: 375285, 373161, 375249, 375257

Fixes: 6127fff842a7 ("common/dpaax: remove outdated caamflib code")
Fixes: 81eb760d2207 ("common/dpaax/caamflib: remove some inline keys")
Cc: stable@dpdk.org
Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
drivers/common/dpaax/caamflib/desc/pdcp.h
drivers/common/dpaax/caamflib/desc/sdap.h

index 2fe56c5..46153b9 100644 (file)
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: BSD-3-Clause or GPL-2.0+
  * Copyright 2008-2013 Freescale Semiconductor, Inc.
- * Copyright 2019-2021 NXP
+ * Copyright 2019-2022 NXP
  */
 
 #ifndef __DESC_PDCP_H__
@@ -776,21 +776,11 @@ pdcp_insert_uplane_snow_snow_op(struct program *p,
 
                return 0;
        }
-       /* Non-proto is supported only for 5bit cplane and 18bit uplane */
-       switch (sn_size) {
-       case PDCP_SN_SIZE_18:
-               offset = 5;
-               length = 3;
-               sn_mask = (swap == false) ? PDCP_U_PLANE_18BIT_SN_MASK :
-                                       PDCP_U_PLANE_18BIT_SN_MASK_BE;
-               break;
-       case PDCP_SN_SIZE_5:
-       case PDCP_SN_SIZE_7:
-       case PDCP_SN_SIZE_12:
-       case PDCP_SN_SIZE_15:
-               pr_err("Invalid sn_size for %s\n", __func__);
-               return -ENOTSUP;
-       }
+       /* sn_size is 18 */
+       offset = 5;
+       length = 3;
+       sn_mask = (swap == false) ? PDCP_U_PLANE_18BIT_SN_MASK :
+                               PDCP_U_PLANE_18BIT_SN_MASK_BE;
 
        if (dir == OP_TYPE_ENCAP_PROTOCOL)
                MATHB(p, SEQINSZ, SUB, length, VSEQINSZ, 4, IMMED2);
@@ -901,21 +891,11 @@ pdcp_insert_uplane_zuc_zuc_op(struct program *p,
 
                return 0;
        }
-       /* Non-proto is supported only for 5bit cplane and 18bit uplane */
-       switch (sn_size) {
-       case PDCP_SN_SIZE_18:
-               offset = 5;
-               length = 3;
-               sn_mask = (swap == false) ? PDCP_U_PLANE_18BIT_SN_MASK :
-                                       PDCP_U_PLANE_18BIT_SN_MASK_BE;
-               break;
-       case PDCP_SN_SIZE_5:
-       case PDCP_SN_SIZE_7:
-       case PDCP_SN_SIZE_12:
-       case PDCP_SN_SIZE_15:
-               pr_err("Invalid sn_size for %s\n", __func__);
-               return -ENOTSUP;
-       }
+       /* sn_size is 18 */
+       offset = 5;
+       length = 3;
+       sn_mask = (swap == false) ? PDCP_U_PLANE_18BIT_SN_MASK :
+                               PDCP_U_PLANE_18BIT_SN_MASK_BE;
 
        SEQLOAD(p, MATH0, offset, length, 0);
        JUMP(p, 1, LOCAL_JUMP, ALL_TRUE, CALM);
@@ -1190,27 +1170,11 @@ pdcp_insert_cplane_snow_aes_op(struct program *p,
 
                return 0;
        }
-       /* Non-proto is supported only for 5bit cplane and 18bit uplane */
-       switch (sn_size) {
-       case PDCP_SN_SIZE_5:
-               offset = 7;
-               length = 1;
-               sn_mask = (swap == false) ? PDCP_C_PLANE_SN_MASK :
-                                       PDCP_C_PLANE_SN_MASK_BE;
-               break;
-       case PDCP_SN_SIZE_18:
-               offset = 5;
-               length = 3;
-               sn_mask = (swap == false) ? PDCP_U_PLANE_18BIT_SN_MASK :
-                                       PDCP_U_PLANE_18BIT_SN_MASK_BE;
-               break;
-       case PDCP_SN_SIZE_7:
-       case PDCP_SN_SIZE_12:
-       case PDCP_SN_SIZE_15:
-               pr_err("Invalid sn_size for %s\n", __func__);
-               return -ENOTSUP;
-
-       }
+       /* sn_size is 18 */
+       offset = 5;
+       length = 3;
+       sn_mask = (swap == false) ? PDCP_U_PLANE_18BIT_SN_MASK :
+                               PDCP_U_PLANE_18BIT_SN_MASK_BE;
 
        SEQLOAD(p, MATH0, offset, length, 0);
        JUMP(p, 1, LOCAL_JUMP, ALL_TRUE, CALM);
@@ -1421,27 +1385,11 @@ pdcp_insert_cplane_aes_snow_op(struct program *p,
 
                return 0;
        }
-       /* Non-proto is supported only for 5bit cplane and 18bit uplane */
-       switch (sn_size) {
-       case PDCP_SN_SIZE_5:
-               offset = 7;
-               length = 1;
-               sn_mask = (swap == false) ? PDCP_C_PLANE_SN_MASK :
-                                       PDCP_C_PLANE_SN_MASK_BE;
-               break;
-       case PDCP_SN_SIZE_18:
-               offset = 5;
-               length = 3;
-               sn_mask = (swap == false) ? PDCP_U_PLANE_18BIT_SN_MASK :
-                                       PDCP_U_PLANE_18BIT_SN_MASK_BE;
-               break;
-       case PDCP_SN_SIZE_7:
-       case PDCP_SN_SIZE_12:
-       case PDCP_SN_SIZE_15:
-               pr_err("Invalid sn_size for %s\n", __func__);
-               return -ENOTSUP;
-
-       }
+       /* sn_size is 18 */
+       offset = 5;
+       length = 3;
+       sn_mask = (swap == false) ? PDCP_U_PLANE_18BIT_SN_MASK :
+                               PDCP_U_PLANE_18BIT_SN_MASK_BE;
 
        if (dir == OP_TYPE_ENCAP_PROTOCOL)
                MATHB(p, SEQINSZ, SUB, length, VSEQINSZ, 4, IMMED2);
@@ -1548,27 +1496,11 @@ pdcp_insert_cplane_snow_zuc_op(struct program *p,
                         (uint16_t)authdata->algtype);
                return 0;
        }
-       /* Non-proto is supported only for 5bit cplane and 18bit uplane */
-       switch (sn_size) {
-       case PDCP_SN_SIZE_5:
-               offset = 7;
-               length = 1;
-               sn_mask = (swap == false) ? PDCP_C_PLANE_SN_MASK :
-                                       PDCP_C_PLANE_SN_MASK_BE;
-               break;
-       case PDCP_SN_SIZE_18:
-               offset = 5;
-               length = 3;
-               sn_mask = (swap == false) ? PDCP_U_PLANE_18BIT_SN_MASK :
-                                       PDCP_U_PLANE_18BIT_SN_MASK_BE;
-               break;
-       case PDCP_SN_SIZE_7:
-       case PDCP_SN_SIZE_12:
-       case PDCP_SN_SIZE_15:
-               pr_err("Invalid sn_size for %s\n", __func__);
-               return -ENOTSUP;
-
-       }
+       /* sn_size is 18 */
+       offset = 5;
+       length = 3;
+       sn_mask = (swap == false) ? PDCP_U_PLANE_18BIT_SN_MASK :
+                               PDCP_U_PLANE_18BIT_SN_MASK_BE;
 
        pkeyjump = JUMP(p, keyjump, LOCAL_JUMP, ALL_TRUE, SHRD | SELF | BOTH);
        KEY(p, KEY1, cipherdata->key_enc_flags, cipherdata->key,
@@ -1667,27 +1599,12 @@ pdcp_insert_cplane_aes_zuc_op(struct program *p,
 
                return 0;
        }
-       /* Non-proto is supported only for 5bit cplane and 18bit uplane */
-       switch (sn_size) {
-       case PDCP_SN_SIZE_5:
-               offset = 7;
-               length = 1;
-               sn_mask = (swap == false) ? PDCP_C_PLANE_SN_MASK :
-                                       PDCP_C_PLANE_SN_MASK_BE;
-               break;
-       case PDCP_SN_SIZE_18:
-               offset = 5;
-               length = 3;
-               sn_mask = (swap == false) ? PDCP_U_PLANE_18BIT_SN_MASK :
-                                       PDCP_U_PLANE_18BIT_SN_MASK_BE;
-               break;
-       case PDCP_SN_SIZE_7:
-       case PDCP_SN_SIZE_12:
-       case PDCP_SN_SIZE_15:
-               pr_err("Invalid sn_size for %s\n", __func__);
-               return -ENOTSUP;
+       /* sn_size is 18 */
+       offset = 5;
+       length = 3;
+       sn_mask = (swap == false) ? PDCP_U_PLANE_18BIT_SN_MASK :
+                               PDCP_U_PLANE_18BIT_SN_MASK_BE;
 
-       }
        pkeyjump = JUMP(p, keyjump, LOCAL_JUMP, ALL_TRUE, SHRD | SELF | BOTH);
        KEY(p, KEY1, cipherdata->key_enc_flags, cipherdata->key,
            cipherdata->keylen, INLINE_KEY(cipherdata));
@@ -1789,27 +1706,12 @@ pdcp_insert_cplane_zuc_snow_op(struct program *p,
 
                return 0;
        }
-       /* Non-proto is supported only for 5bit cplane and 18bit uplane */
-       switch (sn_size) {
-       case PDCP_SN_SIZE_5:
-               offset = 7;
-               length = 1;
-               sn_mask = (swap == false) ? PDCP_C_PLANE_SN_MASK :
-                                       PDCP_C_PLANE_SN_MASK_BE;
-               break;
-       case PDCP_SN_SIZE_18:
-               offset = 5;
-               length = 3;
-               sn_mask = (swap == false) ? PDCP_U_PLANE_18BIT_SN_MASK :
-                                       PDCP_U_PLANE_18BIT_SN_MASK_BE;
-               break;
-       case PDCP_SN_SIZE_7:
-       case PDCP_SN_SIZE_12:
-       case PDCP_SN_SIZE_15:
-               pr_err("Invalid sn_size for %s\n", __func__);
-               return -ENOTSUP;
+       /* sn_size is 18 */
+       offset = 5;
+       length = 3;
+       sn_mask = (swap == false) ? PDCP_U_PLANE_18BIT_SN_MASK :
+                               PDCP_U_PLANE_18BIT_SN_MASK_BE;
 
-       }
        pkeyjump = JUMP(p, keyjump, LOCAL_JUMP, ALL_TRUE, SHRD | SELF | BOTH);
        KEY(p, KEY1, cipherdata->key_enc_flags, cipherdata->key,
            cipherdata->keylen, INLINE_KEY(cipherdata));
@@ -1929,26 +1831,12 @@ pdcp_insert_cplane_zuc_aes_op(struct program *p,
                         (uint16_t)authdata->algtype);
                return 0;
        }
-       /* Non-proto is supported only for 5bit cplane and 18bit uplane */
-       switch (sn_size) {
-       case PDCP_SN_SIZE_5:
-               offset = 7;
-               length = 1;
-               sn_mask = (swap == false) ? PDCP_C_PLANE_SN_MASK :
-                                       PDCP_C_PLANE_SN_MASK_BE;
-               break;
-       case PDCP_SN_SIZE_18:
-               offset = 5;
-               length = 3;
-               sn_mask = (swap == false) ? PDCP_U_PLANE_18BIT_SN_MASK :
-                                       PDCP_U_PLANE_18BIT_SN_MASK_BE;
-               break;
-       case PDCP_SN_SIZE_7:
-       case PDCP_SN_SIZE_12:
-       case PDCP_SN_SIZE_15:
-               pr_err("Invalid sn_size for %s\n", __func__);
-               return -ENOTSUP;
-       }
+
+       /* sn_size is 18 */
+       offset = 5;
+       length = 3;
+       sn_mask = (swap == false) ? PDCP_U_PLANE_18BIT_SN_MASK :
+                               PDCP_U_PLANE_18BIT_SN_MASK_BE;
 
        SEQLOAD(p, MATH0, offset, length, 0);
        JUMP(p, 1, LOCAL_JUMP, ALL_TRUE, CALM);
index 07a5442..b38c15a 100644 (file)
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright 2020-2021 NXP
+ * Copyright 2020-2022 NXP
  */
 
 #ifndef __DESC_SDAP_H__
 static inline int
 rta_inline_pdcp_sdap_query(enum auth_type_pdcp auth_alg,
                      enum cipher_type_pdcp cipher_alg,
-                     enum pdcp_sn_size sn_size,
-                     int8_t hfn_ovd)
+                     __rte_unused enum pdcp_sn_size sn_size,
+                     __rte_unused int8_t hfn_ovd)
 {
-       int nb_key_to_inline = 0;
-
        if ((cipher_alg != PDCP_CIPHER_TYPE_NULL) &&
                        (auth_alg != PDCP_AUTH_TYPE_NULL))
                return 2;
        else
                return 0;
-
-       /**
-        * Shared Descriptors for some of the cases does not fit in the
-        * MAX_DESC_SIZE of the descriptor
-        * The cases which exceed are for RTA_SEC_ERA=8 and HFN override
-        * enabled and 12/18 bit uplane and either of following Algo combo.
-        * - AES-SNOW
-        * - AES-ZUC
-        * - SNOW-SNOW
-        * - SNOW-ZUC
-        * - ZUC-SNOW
-        * - ZUC-SNOW
-        *
-        * We cannot make inline for all cases, as this will impact performance
-        * due to extra memory accesses for the keys.
-        */
-
-       /* Inline only the cipher key */
-       if ((rta_sec_era == RTA_SEC_ERA_8) && hfn_ovd &&
-               ((sn_size == PDCP_SN_SIZE_12) ||
-                (sn_size == PDCP_SN_SIZE_18)) &&
-               (cipher_alg != PDCP_CIPHER_TYPE_NULL) &&
-               ((auth_alg == PDCP_AUTH_TYPE_SNOW) ||
-                (auth_alg == PDCP_AUTH_TYPE_ZUC))) {
-
-               nb_key_to_inline++;
-
-               /* Sub case where inlining another key is required */
-               if ((cipher_alg == PDCP_CIPHER_TYPE_AES) &&
-                       (auth_alg == PDCP_AUTH_TYPE_SNOW))
-                       nb_key_to_inline++;
-       }
-
-       /* Inline both keys */
-
-       return nb_key_to_inline;
 }
 
 static inline void key_loading_opti(struct program *p,