LCOV - code coverage report
Current view: top level - drivers/crypto/cnxk - cnxk_ae.h (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 973 0.0 %
Date: 2026-07-01 18:02:41 Functions: 0 1 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 662 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(C) 2021 Marvell.
       3                 :            :  */
       4                 :            : 
       5                 :            : #ifndef _CNXK_AE_H_
       6                 :            : #define _CNXK_AE_H_
       7                 :            : 
       8                 :            : #include <rte_common.h>
       9                 :            : #include <rte_crypto_asym.h>
      10                 :            : #include <rte_malloc.h>
      11                 :            : 
      12                 :            : #include "roc_ae.h"
      13                 :            : #include "roc_re.h"
      14                 :            : 
      15                 :            : #include "cnxk_cryptodev_ops.h"
      16                 :            : 
      17                 :            : #define ASYM_SESS_SIZE sizeof(struct rte_cryptodev_asym_session)
      18                 :            : 
      19                 :            : #define CNXK_AE_EDDSA_MAX_PARAM_LEN 1024
      20                 :            : 
      21                 :            : struct cnxk_ae_sess {
      22                 :            :         uint8_t rte_sess[ASYM_SESS_SIZE];
      23                 :            :         enum rte_crypto_asym_xform_type xfrm_type;
      24                 :            :         union {
      25                 :            :                 struct rte_crypto_rsa_xform rsa_ctx;
      26                 :            :                 struct rte_crypto_modex_xform mod_ctx;
      27                 :            :                 struct roc_ae_ec_ctx ec_ctx;
      28                 :            :                 struct rte_crypto_ml_kem_xform ml_kem_ctx;
      29                 :            :                 struct rte_crypto_ml_dsa_xform ml_dsa_ctx;
      30                 :            :         };
      31                 :            :         uint64_t *cnxk_fpm_iova;
      32                 :            :         uint64_t *cnxk_ml_iova;
      33                 :            :         struct roc_ae_ec_group **ec_grp;
      34                 :            :         uint64_t cpt_inst_w4;
      35                 :            :         uint64_t cpt_inst_w7;
      36                 :            :         uint64_t cpt_inst_w2;
      37                 :            :         struct cnxk_cpt_qp *qp;
      38                 :            :         struct roc_cpt_lf *lf;
      39                 :            :         uint64_t msg_max_sz;
      40                 :            :         struct hw_ctx_s {
      41                 :            :                 union {
      42                 :            :                         struct {
      43                 :            :                                 uint64_t rsvd : 48;
      44                 :            : 
      45                 :            :                                 uint64_t ctx_push_size : 7;
      46                 :            :                                 uint64_t rsvd1 : 1;
      47                 :            : 
      48                 :            :                                 uint64_t ctx_hdr_size : 2;
      49                 :            :                                 uint64_t aop_valid : 1;
      50                 :            :                                 uint64_t rsvd2 : 1;
      51                 :            :                                 uint64_t ctx_size : 4;
      52                 :            :                         } s;
      53                 :            :                         uint64_t u64;
      54                 :            :                 } w0;
      55                 :            :                 uint8_t rsvd[256];
      56                 :            :         } hw_ctx __plt_aligned(ROC_ALIGN);
      57                 :            : };
      58                 :            : 
      59                 :            : static const uint8_t mldsa_hash_algo[] = {
      60                 :            :         [RTE_CRYPTO_AUTH_SHA3_224] = 0xA,
      61                 :            :         [RTE_CRYPTO_AUTH_SHA3_256] = 0xB,
      62                 :            :         [RTE_CRYPTO_AUTH_SHA3_384] = 0xC,
      63                 :            :         [RTE_CRYPTO_AUTH_SHA3_512] = 0xD,
      64                 :            :         [RTE_CRYPTO_AUTH_SHAKE_128] = 0xE,
      65                 :            :         [RTE_CRYPTO_AUTH_SHAKE_256] = 0xF,
      66                 :            : };
      67                 :            : 
      68                 :            : static __rte_always_inline void
      69                 :            : cnxk_ae_modex_param_normalize(uint8_t **data, size_t *len, size_t max)
      70                 :            : {
      71                 :          0 :         uint8_t msw_len = *len % 8;
      72                 :          0 :         uint64_t msw_val = 0;
      73                 :            :         size_t i;
      74                 :            : 
      75   [ #  #  #  #  :          0 :         if (*len <= 8)
                   #  # ]
      76                 :          0 :                 return;
      77                 :            : 
      78   [ #  #  #  #  :          0 :         memcpy(&msw_val, *data, msw_len);
             #  #  #  # ]
      79   [ #  #  #  #  :          0 :         if (msw_val != 0)
             #  #  #  # ]
      80                 :            :                 return;
      81                 :            : 
      82   [ #  #  #  #  :          0 :         for (i = msw_len; i < *len && (*len - i) < max; i += 8) {
          #  #  #  #  #  
          #  #  #  #  #  
                   #  # ]
      83                 :          0 :                 memcpy(&msw_val, &(*data)[i], 8);
      84   [ #  #  #  #  :          0 :                 if (msw_val != 0)
             #  #  #  # ]
      85                 :            :                         break;
      86                 :            :         }
      87                 :          0 :         *data += i;
      88                 :          0 :         *len -= i;
      89                 :            : }
      90                 :            : 
      91                 :            : static __rte_always_inline int
      92                 :            : cnxk_ae_fill_modex_params(struct cnxk_ae_sess *sess,
      93                 :            :                           struct rte_crypto_asym_xform *xform)
      94                 :            : {
      95                 :            :         struct rte_crypto_modex_xform *ctx = &sess->mod_ctx;
      96                 :          0 :         size_t exp_len = xform->modex.exponent.length;
      97                 :          0 :         size_t mod_len = xform->modex.modulus.length;
      98                 :          0 :         uint8_t *exp = xform->modex.exponent.data;
      99         [ #  # ]:          0 :         uint8_t *mod = xform->modex.modulus.data;
     100                 :            : 
     101                 :            :         cnxk_ae_modex_param_normalize(&mod, &mod_len, SIZE_MAX);
     102                 :            :         cnxk_ae_modex_param_normalize(&exp, &exp_len, mod_len);
     103                 :            : 
     104   [ #  #  #  # ]:          0 :         if (unlikely(exp_len == 0 || mod_len == 0))
     105                 :            :                 return -EINVAL;
     106                 :            : 
     107         [ #  # ]:          0 :         if (unlikely(exp_len > mod_len))
     108                 :            :                 return -ENOTSUP;
     109                 :            : 
     110                 :            :         /* Allocate buffer to hold modexp params */
     111                 :          0 :         ctx->modulus.data = rte_malloc(NULL, mod_len + exp_len, 0);
     112         [ #  # ]:          0 :         if (ctx->modulus.data == NULL)
     113                 :            :                 return -ENOMEM;
     114                 :            : 
     115                 :            :         /* Set up modexp prime modulus and private exponent */
     116                 :            :         memcpy(ctx->modulus.data, mod, mod_len);
     117                 :          0 :         ctx->exponent.data = ctx->modulus.data + mod_len;
     118                 :            :         memcpy(ctx->exponent.data, exp, exp_len);
     119                 :            : 
     120                 :          0 :         ctx->modulus.length = mod_len;
     121                 :          0 :         ctx->exponent.length = exp_len;
     122                 :            : 
     123                 :            :         return 0;
     124                 :            : }
     125                 :            : 
     126                 :            : static __rte_always_inline int
     127                 :            : cnxk_ae_fill_rsa_params(struct cnxk_ae_sess *sess,
     128                 :            :                         struct rte_crypto_asym_xform *xform)
     129                 :            : {
     130                 :          0 :         struct rte_crypto_rsa_priv_key_qt qt = xform->rsa.qt;
     131                 :            :         struct rte_crypto_rsa_xform *xfrm_rsa = &xform->rsa;
     132                 :            :         struct rte_crypto_rsa_xform *rsa = &sess->rsa_ctx;
     133                 :          0 :         struct rte_crypto_param_t d = xform->rsa.d;
     134                 :          0 :         size_t mod_len = xfrm_rsa->n.length;
     135                 :          0 :         size_t exp_len = xfrm_rsa->e.length;
     136                 :            :         uint64_t total_size;
     137                 :            :         size_t len = 0;
     138                 :            : 
     139                 :            :         /* Set private key type */
     140                 :          0 :         rsa->key_type = xfrm_rsa->key_type;
     141                 :            : 
     142         [ #  # ]:          0 :         if (rsa->key_type == RTE_RSA_KEY_TYPE_QT) {
     143   [ #  #  #  # ]:          0 :                 if (qt.p.length != 0 && qt.p.data == NULL)
     144                 :            :                         return -EINVAL;
     145                 :            : 
     146                 :            :                 /* Make sure key length used is not more than mod_len/2 */
     147         [ #  # ]:          0 :                 if (qt.p.data != NULL)
     148         [ #  # ]:          0 :                         len = (((mod_len / 2) < qt.p.length) ? 0 : qt.p.length * 5);
     149         [ #  # ]:          0 :         } else if (rsa->key_type == RTE_RSA_KEY_TYPE_EXP) {
     150   [ #  #  #  # ]:          0 :                 if (d.length != 0 && d.data == NULL)
     151                 :            :                         return -EINVAL;
     152                 :            : 
     153                 :            :                 len = d.length;
     154                 :            :         }
     155                 :            : 
     156                 :            :         /* Total size required for RSA key params(n,e,(q,dQ,p,dP,qInv)) */
     157                 :          0 :         total_size = mod_len + exp_len + len;
     158                 :            : 
     159                 :            :         /* Allocate buffer to hold all RSA keys */
     160                 :          0 :         rsa->n.data = rte_malloc(NULL, total_size, 0);
     161         [ #  # ]:          0 :         if (rsa->n.data == NULL)
     162                 :            :                 return -ENOMEM;
     163                 :            : 
     164                 :            :         /* Set up RSA prime modulus and public key exponent */
     165         [ #  # ]:          0 :         memcpy(rsa->n.data, xfrm_rsa->n.data, mod_len);
     166                 :          0 :         rsa->e.data = rsa->n.data + mod_len;
     167                 :          0 :         memcpy(rsa->e.data, xfrm_rsa->e.data, exp_len);
     168                 :            : 
     169         [ #  # ]:          0 :         if (rsa->key_type == RTE_RSA_KEY_TYPE_QT) {
     170                 :            :                 /* Private key in quintuple format */
     171         [ #  # ]:          0 :                 rsa->qt.q.data = rsa->e.data + exp_len;
     172                 :            :                 memcpy(rsa->qt.q.data, qt.q.data, qt.q.length);
     173                 :          0 :                 rsa->qt.dQ.data = rsa->qt.q.data + qt.q.length;
     174                 :            :                 memcpy(rsa->qt.dQ.data, qt.dQ.data, qt.dQ.length);
     175                 :          0 :                 rsa->qt.p.data = rsa->qt.dQ.data + qt.dQ.length;
     176         [ #  # ]:          0 :                 if (qt.p.data != NULL)
     177                 :            :                         memcpy(rsa->qt.p.data, qt.p.data, qt.p.length);
     178                 :          0 :                 rsa->qt.dP.data = rsa->qt.p.data + qt.p.length;
     179                 :            :                 memcpy(rsa->qt.dP.data, qt.dP.data, qt.dP.length);
     180                 :          0 :                 rsa->qt.qInv.data = rsa->qt.dP.data + qt.dP.length;
     181                 :            :                 memcpy(rsa->qt.qInv.data, qt.qInv.data, qt.qInv.length);
     182                 :            : 
     183                 :          0 :                 rsa->qt.q.length = qt.q.length;
     184                 :          0 :                 rsa->qt.dQ.length = qt.dQ.length;
     185                 :          0 :                 rsa->qt.p.length = qt.p.length;
     186                 :          0 :                 rsa->qt.dP.length = qt.dP.length;
     187                 :          0 :                 rsa->qt.qInv.length = qt.qInv.length;
     188         [ #  # ]:          0 :         } else if (rsa->key_type == RTE_RSA_KEY_TYPE_EXP) {
     189                 :            :                 /* Private key in exponent format */
     190                 :          0 :                 rsa->d.data = rsa->e.data + exp_len;
     191                 :            :                 memcpy(rsa->d.data, d.data, d.length);
     192                 :          0 :                 rsa->d.length = d.length;
     193                 :            :         }
     194                 :          0 :         rsa->n.length = mod_len;
     195                 :          0 :         rsa->e.length = exp_len;
     196                 :            : 
     197                 :            :         /* Set padding info */
     198                 :          0 :         rsa->padding.type = xform->rsa.padding.type;
     199                 :            : 
     200                 :            :         return 0;
     201                 :            : }
     202                 :            : 
     203                 :            : static __rte_always_inline int
     204                 :            : cnxk_ae_fill_ec_params(struct cnxk_ae_sess *sess, struct rte_crypto_asym_xform *xform)
     205                 :            : {
     206                 :            :         struct roc_ae_ec_ctx *ec = &sess->ec_ctx;
     207                 :          0 :         union cpt_inst_w4 w4 = {0};
     208                 :            : 
     209   [ #  #  #  #  :          0 :         switch (xform->ec.curve_id) {
             #  #  #  #  
                      # ]
     210                 :          0 :         case RTE_CRYPTO_EC_GROUP_SECP192R1:
     211                 :          0 :                 ec->curveid = ROC_AE_EC_ID_P192;
     212                 :          0 :                 break;
     213                 :          0 :         case RTE_CRYPTO_EC_GROUP_SECP224R1:
     214                 :          0 :                 ec->curveid = ROC_AE_EC_ID_P224;
     215                 :          0 :                 break;
     216                 :          0 :         case RTE_CRYPTO_EC_GROUP_SECP256R1:
     217                 :          0 :                 ec->curveid = ROC_AE_EC_ID_P256;
     218                 :          0 :                 break;
     219                 :          0 :         case RTE_CRYPTO_EC_GROUP_SECP384R1:
     220                 :          0 :                 ec->curveid = ROC_AE_EC_ID_P384;
     221                 :          0 :                 break;
     222                 :          0 :         case RTE_CRYPTO_EC_GROUP_SECP521R1:
     223                 :          0 :                 ec->curveid = ROC_AE_EC_ID_P521;
     224                 :          0 :                 break;
     225                 :          0 :         case RTE_CRYPTO_EC_GROUP_SM2:
     226                 :          0 :                 ec->curveid = ROC_AE_EC_ID_SM2;
     227                 :          0 :                 break;
     228                 :          0 :         case RTE_CRYPTO_EC_GROUP_ED25519:
     229                 :          0 :                 ec->curveid = ROC_AE_EC_ID_ED25519;
     230                 :          0 :                 w4.s.param1 = ROC_AE_ED_PARAM1_25519;
     231                 :          0 :                 break;
     232                 :          0 :         case RTE_CRYPTO_EC_GROUP_ED448:
     233                 :          0 :                 ec->curveid = ROC_AE_EC_ID_ED448;
     234                 :          0 :                 w4.s.param1 = ROC_AE_ED_PARAM1_448;
     235                 :          0 :                 break;
     236                 :            :         default:
     237                 :            :                 /* Only NIST curves (FIPS 186-4) and SM2 are supported */
     238                 :            :                 return -EINVAL;
     239                 :            :         }
     240                 :            : 
     241         [ #  # ]:          0 :         if (xform->xform_type == RTE_CRYPTO_ASYM_XFORM_ECPM)
     242                 :            :                 return 0;
     243                 :            : 
     244                 :          0 :         ec->pkey.length = xform->ec.pkey.length;
     245         [ #  # ]:          0 :         if (ec->pkey.length > ROC_AE_EC_DATA_MAX)
     246                 :          0 :                 ec->pkey.length = ROC_AE_EC_DATA_MAX;
     247         [ #  # ]:          0 :         if (ec->pkey.length)
     248         [ #  # ]:          0 :                 rte_memcpy(ec->pkey.data, xform->ec.pkey.data, ec->pkey.length);
     249                 :            : 
     250                 :          0 :         ec->q.x.length = xform->ec.q.x.length;
     251         [ #  # ]:          0 :         if (ec->q.x.length > ROC_AE_EC_DATA_MAX)
     252                 :          0 :                 ec->q.x.length = ROC_AE_EC_DATA_MAX;
     253         [ #  # ]:          0 :         if (ec->q.x.length)
     254         [ #  # ]:          0 :                 rte_memcpy(ec->q.x.data, xform->ec.q.x.data, ec->q.x.length);
     255                 :            : 
     256         [ #  # ]:          0 :         if (xform->xform_type == RTE_CRYPTO_ASYM_XFORM_EDDSA) {
     257                 :          0 :                 w4.s.opcode_major = ROC_AE_MAJOR_OP_EDDSA;
     258                 :            : 
     259                 :            :                 /* Use q.x to store compressed public key. q.y is set to 0 */
     260                 :          0 :                 ec->q.y.length = 0;
     261                 :          0 :                 goto _exit;
     262                 :            :         }
     263                 :            : 
     264                 :          0 :         ec->q.y.length = xform->ec.q.y.length;
     265         [ #  # ]:          0 :         if (ec->q.y.length > ROC_AE_EC_DATA_MAX)
     266                 :          0 :                 ec->q.y.length = ROC_AE_EC_DATA_MAX;
     267         [ #  # ]:          0 :         if (xform->ec.q.y.length)
     268         [ #  # ]:          0 :                 rte_memcpy(ec->q.y.data, xform->ec.q.y.data, ec->q.y.length);
     269                 :            : 
     270                 :          0 : _exit:
     271                 :          0 :         sess->cpt_inst_w4 = w4.u64;
     272                 :            :         return 0;
     273                 :            : }
     274                 :            : 
     275                 :            : static __rte_always_inline int
     276                 :            : cnxk_ae_fill_ml_kem_params(struct cnxk_ae_sess *sess,
     277                 :            :                            struct rte_crypto_asym_xform *xform)
     278                 :            : {
     279                 :            :         struct rte_crypto_ml_kem_xform *ml_kem = &sess->ml_kem_ctx;
     280         [ #  # ]:          0 :         if (xform->mlkem.type == RTE_CRYPTO_ML_KEM_NONE)
     281                 :            :                 return -EINVAL;
     282                 :            : 
     283                 :          0 :         ml_kem->type = xform->mlkem.type;
     284                 :            :         return 0;
     285                 :            : }
     286                 :            : 
     287                 :            : static __rte_always_inline int
     288                 :            : cnxk_ae_fill_ml_dsa_params(struct cnxk_ae_sess *sess,
     289                 :            :                            struct rte_crypto_asym_xform *xform)
     290                 :            : {
     291                 :            :         struct rte_crypto_ml_dsa_xform *ml_dsa = &sess->ml_dsa_ctx;
     292         [ #  # ]:          0 :         if (xform->mldsa.type == RTE_CRYPTO_ML_DSA_NONE)
     293                 :            :                 return -EINVAL;
     294                 :            : 
     295                 :          0 :         ml_dsa->type = xform->mldsa.type;
     296                 :          0 :         ml_dsa->sign_deterministic = xform->mldsa.sign_deterministic;
     297                 :          0 :         ml_dsa->sign_prehash = xform->mldsa.sign_prehash;
     298                 :            :         return 0;
     299                 :            : }
     300                 :            : 
     301                 :            : static __rte_always_inline int
     302                 :            : cnxk_ae_fill_session_parameters(struct cnxk_ae_sess *sess,
     303                 :            :                                 struct rte_crypto_asym_xform *xform)
     304                 :            : {
     305                 :            :         int ret;
     306                 :            : 
     307                 :          0 :         sess->xfrm_type = xform->xform_type;
     308                 :          0 :         sess->msg_max_sz = cnxk_cpt_asym_get_mlen();
     309                 :            : 
     310   [ #  #  #  #  :          0 :         switch (xform->xform_type) {
                   #  # ]
     311                 :            :         case RTE_CRYPTO_ASYM_XFORM_RSA:
     312                 :            :                 ret = cnxk_ae_fill_rsa_params(sess, xform);
     313                 :            :                 break;
     314                 :            :         case RTE_CRYPTO_ASYM_XFORM_MODEX:
     315                 :            :                 ret = cnxk_ae_fill_modex_params(sess, xform);
     316                 :            :                 break;
     317                 :            :         case RTE_CRYPTO_ASYM_XFORM_ECDSA:
     318                 :            :                 /* Fall through */
     319                 :            :         case RTE_CRYPTO_ASYM_XFORM_ECDH:
     320                 :            :         case RTE_CRYPTO_ASYM_XFORM_ECPM:
     321                 :            :         case RTE_CRYPTO_ASYM_XFORM_ECFPM:
     322                 :            :         case RTE_CRYPTO_ASYM_XFORM_SM2:
     323                 :            :         case RTE_CRYPTO_ASYM_XFORM_EDDSA:
     324                 :            :                 ret = cnxk_ae_fill_ec_params(sess, xform);
     325                 :            :                 break;
     326                 :            :         case RTE_CRYPTO_ASYM_XFORM_ML_KEM:
     327                 :            :                 ret = cnxk_ae_fill_ml_kem_params(sess, xform);
     328                 :            :                 break;
     329                 :            :         case RTE_CRYPTO_ASYM_XFORM_ML_DSA:
     330                 :            :                 ret = cnxk_ae_fill_ml_dsa_params(sess, xform);
     331                 :            :                 break;
     332                 :            :         default:
     333                 :            :                 return -ENOTSUP;
     334                 :            :         }
     335                 :            :         return ret;
     336                 :            : }
     337                 :            : 
     338                 :            : static inline void
     339                 :          0 : cnxk_ae_free_session_parameters(struct cnxk_ae_sess *sess)
     340                 :            : {
     341                 :            :         struct rte_crypto_modex_xform *mod;
     342                 :            :         struct rte_crypto_rsa_xform *rsa;
     343                 :            : 
     344      [ #  #  # ]:          0 :         switch (sess->xfrm_type) {
     345                 :          0 :         case RTE_CRYPTO_ASYM_XFORM_RSA:
     346                 :            :                 rsa = &sess->rsa_ctx;
     347                 :          0 :                 rte_free(rsa->n.data);
     348                 :          0 :                 break;
     349                 :          0 :         case RTE_CRYPTO_ASYM_XFORM_MODEX:
     350                 :            :                 mod = &sess->mod_ctx;
     351                 :          0 :                 rte_free(mod->modulus.data);
     352                 :          0 :                 break;
     353                 :            :         case RTE_CRYPTO_ASYM_XFORM_ECDSA:
     354                 :            :                 /* Fall through */
     355                 :            :         case RTE_CRYPTO_ASYM_XFORM_ECPM:
     356                 :            :         case RTE_CRYPTO_ASYM_XFORM_ECFPM:
     357                 :            :                 break;
     358                 :            :         default:
     359                 :            :                 break;
     360                 :            :         }
     361                 :          0 : }
     362                 :            : 
     363                 :            : static __rte_always_inline int
     364                 :            : cnxk_ae_modex_prep(struct rte_crypto_op *op, struct roc_ae_buf_ptr *meta_buf,
     365                 :            :                    struct rte_crypto_modex_xform *mod, struct cpt_inst_s *inst)
     366                 :            : {
     367                 :          0 :         uint32_t exp_len = mod->exponent.length;
     368                 :          0 :         uint32_t mod_len = mod->modulus.length;
     369                 :            :         struct rte_crypto_mod_op_param mod_op;
     370                 :            :         uint64_t total_key_len;
     371                 :            :         union cpt_inst_w4 w4;
     372                 :            :         size_t base_len;
     373                 :            :         uint32_t dlen;
     374                 :            :         uint8_t *dptr;
     375                 :            : 
     376                 :          0 :         mod_op = op->asym->modex;
     377                 :            : 
     378                 :            :         base_len = mod_op.base.length;
     379                 :          0 :         if (unlikely(base_len > mod_len)) {
     380                 :            :                 cnxk_ae_modex_param_normalize(&mod_op.base.data, &base_len, mod_len);
     381   [ #  #  #  # ]:          0 :                 if (base_len > mod_len) {
     382                 :          0 :                         op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
     383                 :          0 :                         return -ENOTSUP;
     384                 :            :                 }
     385                 :            :         }
     386                 :            : 
     387                 :          0 :         total_key_len = mod_len + exp_len;
     388                 :            : 
     389                 :            :         /* Input buffer */
     390                 :            :         dptr = meta_buf->vaddr;
     391                 :          0 :         inst->dptr = (uintptr_t)dptr;
     392                 :          0 :         memcpy(dptr, mod->modulus.data, total_key_len);
     393                 :          0 :         dptr += total_key_len;
     394                 :            :         memcpy(dptr, mod_op.base.data, base_len);
     395                 :          0 :         dptr += base_len;
     396                 :          0 :         dlen = total_key_len + base_len;
     397                 :            : 
     398                 :            :         /* Setup opcodes */
     399                 :          0 :         w4.s.opcode_major = ROC_AE_MAJOR_OP_MODEX;
     400                 :          0 :         w4.s.opcode_minor = ROC_AE_MINOR_OP_MODEX;
     401                 :            : 
     402                 :          0 :         w4.s.param1 = mod_len;
     403                 :          0 :         w4.s.param2 = exp_len;
     404                 :          0 :         w4.s.dlen = dlen;
     405                 :            : 
     406                 :          0 :         inst->w4.u64 = w4.u64;
     407                 :          0 :         inst->rptr = (uintptr_t)dptr;
     408                 :            : 
     409                 :          0 :         return 0;
     410                 :            : }
     411                 :            : 
     412                 :            : static __rte_always_inline void
     413                 :            : cnxk_ae_rsa_prep(struct rte_crypto_op *op, struct roc_ae_buf_ptr *meta_buf,
     414                 :            :                  struct rte_crypto_rsa_xform *rsa,
     415                 :            :                  rte_crypto_param *crypto_param, struct cpt_inst_s *inst)
     416                 :            : {
     417                 :            :         struct rte_crypto_rsa_op_param rsa_op;
     418                 :          0 :         uint32_t mod_len = rsa->n.length;
     419                 :          0 :         uint32_t exp_len = rsa->e.length;
     420                 :            :         uint64_t total_key_len;
     421                 :            :         union cpt_inst_w4 w4;
     422                 :            :         uint32_t in_size;
     423                 :            :         uint32_t dlen;
     424                 :            :         uint8_t *dptr;
     425                 :            : 
     426                 :            :         rsa_op = op->asym->rsa;
     427                 :          0 :         total_key_len = mod_len + exp_len;
     428                 :            : 
     429                 :            :         /* Input buffer */
     430                 :            :         dptr = meta_buf->vaddr;
     431                 :          0 :         inst->dptr = (uintptr_t)dptr;
     432                 :          0 :         memcpy(dptr, rsa->n.data, total_key_len);
     433                 :          0 :         dptr += total_key_len;
     434                 :            : 
     435                 :          0 :         in_size = crypto_param->length;
     436                 :          0 :         memcpy(dptr, crypto_param->data, in_size);
     437                 :            : 
     438                 :          0 :         dptr += in_size;
     439                 :          0 :         dlen = total_key_len + in_size;
     440                 :            : 
     441   [ #  #  #  #  :          0 :         if (rsa->padding.type == RTE_CRYPTO_RSA_PADDING_NONE) {
             #  #  #  # ]
     442                 :            :                 /* Use mod_exp operation for no_padding type */
     443                 :          0 :                 w4.s.opcode_minor = ROC_AE_MINOR_OP_MODEX;
     444                 :          0 :                 w4.s.param2 = exp_len;
     445                 :            :         } else {
     446                 :            :                 if (rsa_op.op_type == RTE_CRYPTO_ASYM_OP_ENCRYPT) {
     447                 :          0 :                         w4.s.opcode_minor = ROC_AE_MINOR_OP_PKCS_ENC;
     448                 :            :                         /* Public key encrypt, use BT2*/
     449                 :          0 :                         w4.s.param2 = ROC_AE_CPT_BLOCK_TYPE2 |
     450                 :          0 :                                       ((uint16_t)(exp_len) << 1);
     451                 :            :                 } else if (rsa_op.op_type == RTE_CRYPTO_ASYM_OP_VERIFY) {
     452                 :          0 :                         w4.s.opcode_minor = ROC_AE_MINOR_OP_PKCS_DEC;
     453                 :            :                         /* Public key decrypt, use BT1 */
     454                 :          0 :                         w4.s.param2 = ROC_AE_CPT_BLOCK_TYPE1;
     455                 :            :                 }
     456                 :            :         }
     457                 :            : 
     458                 :          0 :         w4.s.opcode_major = ROC_AE_MAJOR_OP_MODEX;
     459                 :            : 
     460                 :          0 :         w4.s.param1 = mod_len;
     461                 :          0 :         w4.s.dlen = dlen;
     462                 :            : 
     463                 :          0 :         inst->w4.u64 = w4.u64;
     464                 :          0 :         inst->rptr = (uintptr_t)dptr;
     465                 :          0 : }
     466                 :            : 
     467                 :            : static __rte_always_inline void
     468                 :            : cnxk_ae_rsa_exp_prep(struct rte_crypto_op *op, struct roc_ae_buf_ptr *meta_buf,
     469                 :            :                      struct rte_crypto_rsa_xform *rsa, rte_crypto_param *crypto_param,
     470                 :            :                      struct cpt_inst_s *inst)
     471                 :            : {
     472                 :            :         struct rte_crypto_rsa_op_param rsa_op;
     473                 :          0 :         uint32_t privkey_len = rsa->d.length;
     474                 :          0 :         uint32_t mod_len = rsa->n.length;
     475                 :            :         union cpt_inst_w4 w4;
     476                 :            :         uint32_t in_size;
     477                 :            :         uint32_t dlen;
     478                 :            :         uint8_t *dptr;
     479                 :            : 
     480                 :            :         rsa_op = op->asym->rsa;
     481                 :            : 
     482                 :            :         /* Input buffer */
     483                 :            :         dptr = meta_buf->vaddr;
     484                 :          0 :         inst->dptr = (uintptr_t)dptr;
     485   [ #  #  #  #  :          0 :         memcpy(dptr, rsa->n.data, mod_len);
             #  #  #  # ]
     486                 :          0 :         dptr += mod_len;
     487                 :          0 :         memcpy(dptr, rsa->d.data, privkey_len);
     488                 :          0 :         dptr += privkey_len;
     489                 :            : 
     490                 :          0 :         in_size = crypto_param->length;
     491                 :          0 :         memcpy(dptr, crypto_param->data, in_size);
     492                 :            : 
     493                 :          0 :         dptr += in_size;
     494                 :          0 :         dlen = mod_len + privkey_len + in_size;
     495                 :            : 
     496   [ #  #  #  #  :          0 :         if (rsa->padding.type == RTE_CRYPTO_RSA_PADDING_NONE) {
             #  #  #  # ]
     497                 :            :                 /* Use mod_exp operation for no_padding type */
     498                 :          0 :                 w4.s.opcode_minor = ROC_AE_MINOR_OP_MODEX;
     499                 :          0 :                 w4.s.param2 = privkey_len;
     500                 :            :         } else {
     501                 :            :                 if (rsa_op.op_type == RTE_CRYPTO_ASYM_OP_SIGN) {
     502                 :          0 :                         w4.s.opcode_minor = ROC_AE_MINOR_OP_PKCS_ENC;
     503                 :            :                         /* Private key encrypt (exponent), use BT1*/
     504                 :          0 :                         w4.s.param2 = ROC_AE_CPT_BLOCK_TYPE1 | ((uint16_t)(privkey_len) << 1);
     505                 :            :                 } else if (rsa_op.op_type == RTE_CRYPTO_ASYM_OP_DECRYPT) {
     506                 :          0 :                         w4.s.opcode_minor = ROC_AE_MINOR_OP_PKCS_DEC;
     507                 :            :                         /* Private key decrypt (exponent), use BT2 */
     508                 :          0 :                         w4.s.param2 = ROC_AE_CPT_BLOCK_TYPE2;
     509                 :            :                 }
     510                 :            :         }
     511                 :            : 
     512                 :          0 :         w4.s.opcode_major = ROC_AE_MAJOR_OP_MODEX;
     513                 :            : 
     514                 :          0 :         w4.s.param1 = mod_len;
     515                 :          0 :         w4.s.dlen = dlen;
     516                 :            : 
     517                 :          0 :         inst->w4.u64 = w4.u64;
     518                 :          0 :         inst->rptr = (uintptr_t)dptr;
     519                 :          0 : }
     520                 :            : 
     521                 :            : static __rte_always_inline void
     522                 :            : cnxk_ae_rsa_crt_prep(struct rte_crypto_op *op, struct roc_ae_buf_ptr *meta_buf,
     523                 :            :                      struct rte_crypto_rsa_xform *rsa, rte_crypto_param *crypto_param,
     524                 :            :                      struct cpt_inst_s *inst)
     525                 :            : {
     526                 :          0 :         uint32_t qInv_len = rsa->qt.qInv.length;
     527                 :            :         struct rte_crypto_rsa_op_param rsa_op;
     528                 :          0 :         uint32_t dP_len = rsa->qt.dP.length;
     529                 :          0 :         uint32_t dQ_len = rsa->qt.dQ.length;
     530                 :          0 :         uint32_t p_len = rsa->qt.p.length;
     531                 :          0 :         uint32_t q_len = rsa->qt.q.length;
     532                 :          0 :         uint32_t mod_len = rsa->n.length;
     533                 :            :         uint64_t total_key_len;
     534                 :            :         union cpt_inst_w4 w4;
     535                 :            :         uint32_t in_size;
     536                 :            :         uint32_t dlen;
     537                 :            :         uint8_t *dptr;
     538                 :            : 
     539                 :            :         rsa_op = op->asym->rsa;
     540                 :          0 :         total_key_len = p_len + q_len + dP_len + dQ_len + qInv_len;
     541                 :            : 
     542                 :            :         /* Input buffer */
     543                 :            :         dptr = meta_buf->vaddr;
     544                 :          0 :         inst->dptr = (uintptr_t)dptr;
     545   [ #  #  #  #  :          0 :         memcpy(dptr, rsa->qt.q.data, total_key_len);
             #  #  #  # ]
     546                 :          0 :         dptr += total_key_len;
     547                 :            : 
     548                 :          0 :         in_size = crypto_param->length;
     549                 :          0 :         memcpy(dptr, crypto_param->data, in_size);
     550                 :            : 
     551                 :          0 :         dptr += in_size;
     552                 :          0 :         dlen = total_key_len + in_size;
     553                 :            : 
     554   [ #  #  #  #  :          0 :         if (rsa->padding.type == RTE_CRYPTO_RSA_PADDING_NONE) {
             #  #  #  # ]
     555                 :            :                 /*Use mod_exp operation for no_padding type */
     556                 :          0 :                 w4.s.opcode_minor = ROC_AE_MINOR_OP_MODEX_CRT;
     557                 :            :         } else {
     558                 :            :                 if (rsa_op.op_type == RTE_CRYPTO_ASYM_OP_SIGN) {
     559                 :          0 :                         w4.s.opcode_minor = ROC_AE_MINOR_OP_PKCS_ENC_CRT;
     560                 :            :                         /* Private encrypt, use BT1 */
     561                 :          0 :                         w4.s.param2 = ROC_AE_CPT_BLOCK_TYPE1;
     562                 :            :                 } else if (rsa_op.op_type == RTE_CRYPTO_ASYM_OP_DECRYPT) {
     563                 :          0 :                         w4.s.opcode_minor = ROC_AE_MINOR_OP_PKCS_DEC_CRT;
     564                 :            :                         /* Private decrypt, use BT2 */
     565                 :          0 :                         w4.s.param2 = ROC_AE_CPT_BLOCK_TYPE2;
     566                 :            :                 }
     567                 :            :         }
     568                 :            : 
     569                 :          0 :         w4.s.opcode_major = ROC_AE_MAJOR_OP_MODEX;
     570                 :            : 
     571                 :          0 :         w4.s.param1 = mod_len;
     572                 :          0 :         w4.s.dlen = dlen;
     573                 :            : 
     574                 :          0 :         inst->w4.u64 = w4.u64;
     575                 :          0 :         inst->rptr = (uintptr_t)dptr;
     576                 :          0 : }
     577                 :            : 
     578                 :            : static __rte_always_inline int __rte_hot
     579                 :            : cnxk_ae_enqueue_rsa_op(struct rte_crypto_op *op, struct roc_ae_buf_ptr *meta_buf,
     580                 :            :                        struct cnxk_ae_sess *sess, struct cpt_inst_s *inst)
     581                 :            : {
     582                 :            :         struct rte_crypto_rsa_op_param *rsa = &op->asym->rsa;
     583                 :            :         struct rte_crypto_rsa_xform *ctx = &sess->rsa_ctx;
     584                 :            : 
     585   [ #  #  #  #  :          0 :         switch (rsa->op_type) {
          #  #  #  #  #  
                      # ]
     586   [ #  #  #  # ]:          0 :         case RTE_CRYPTO_ASYM_OP_VERIFY:
     587                 :            :                 cnxk_ae_rsa_prep(op, meta_buf, ctx, &rsa->sign, inst);
     588                 :            :                 break;
     589   [ #  #  #  # ]:          0 :         case RTE_CRYPTO_ASYM_OP_ENCRYPT:
     590                 :            :                 cnxk_ae_rsa_prep(op, meta_buf, ctx, &rsa->message, inst);
     591                 :            :                 break;
     592                 :          0 :         case RTE_CRYPTO_ASYM_OP_SIGN:
     593   [ #  #  #  # ]:          0 :                 if (ctx->key_type == RTE_RSA_KEY_TYPE_QT)
     594                 :            :                         cnxk_ae_rsa_crt_prep(op, meta_buf, ctx, &rsa->message, inst);
     595                 :            :                 else
     596                 :            :                         cnxk_ae_rsa_exp_prep(op, meta_buf, ctx, &rsa->message, inst);
     597                 :            :                 break;
     598                 :          0 :         case RTE_CRYPTO_ASYM_OP_DECRYPT:
     599   [ #  #  #  # ]:          0 :                 if (ctx->key_type == RTE_RSA_KEY_TYPE_QT)
     600                 :            :                         cnxk_ae_rsa_crt_prep(op, meta_buf, ctx, &rsa->cipher, inst);
     601                 :            :                 else
     602                 :            :                         cnxk_ae_rsa_exp_prep(op, meta_buf, ctx, &rsa->cipher, inst);
     603                 :            :                 break;
     604                 :          0 :         default:
     605                 :          0 :                 op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
     606                 :          0 :                 return -EINVAL;
     607                 :            :         }
     608                 :            :         return 0;
     609                 :            : }
     610                 :            : 
     611                 :            : static __rte_always_inline int __rte_hot
     612                 :            : cnxk_ae_enqueue_ml_kem_op(struct rte_crypto_op *op, struct roc_ae_buf_ptr *meta_buf,
     613                 :            :                        struct cnxk_ae_sess *sess, struct cpt_inst_s *inst)
     614                 :            : {
     615                 :          0 :         size_t metabuf_len = cnxk_cpt_asym_get_mlen(), reqbuf_len;
     616                 :            :         struct rte_crypto_ml_kem_op *mlkem = &op->asym->mlkem;
     617                 :            :         union cpt_inst_w4 w4;
     618                 :            :         uint32_t dlen = 0;
     619                 :            :         uint16_t param2;
     620                 :            :         uint8_t *dptr;
     621                 :            : 
     622                 :            :         /* Input buffer */
     623                 :            :         dptr = meta_buf->vaddr;
     624                 :          0 :         inst->dptr = (uintptr_t)dptr;
     625                 :            : 
     626   [ #  #  #  #  :          0 :         switch (mlkem->op) {
             #  #  #  # ]
     627                 :          0 :         case RTE_CRYPTO_ML_KEM_OP_KEYGEN:
     628                 :          0 :                 reqbuf_len = mlkem->keygen.d.length + mlkem->keygen.z.length;
     629   [ #  #  #  # ]:          0 :                 if (reqbuf_len > (metabuf_len - dlen)) {
     630                 :          0 :                         op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
     631                 :          0 :                         return -ENOMEM;
     632                 :            :                 }
     633                 :            : 
     634   [ #  #  #  # ]:          0 :                 memcpy(dptr, mlkem->keygen.d.data, mlkem->keygen.d.length);
     635                 :          0 :                 dptr += mlkem->keygen.d.length;
     636                 :          0 :                 memcpy(dptr, mlkem->keygen.z.data, mlkem->keygen.z.length);
     637                 :          0 :                 dptr += mlkem->keygen.z.length;
     638                 :            : 
     639                 :          0 :                 dlen = mlkem->keygen.d.length + mlkem->keygen.z.length;
     640                 :          0 :                 w4.s.opcode_major = ROC_RE_MAJOR_OP_MLKEM;
     641                 :          0 :                 w4.s.opcode_minor = ROC_RE_MINOR_OP_MLKEM_KEYGEN;
     642                 :          0 :                 param2 = sess->ml_kem_ctx.type;
     643   [ #  #  #  # ]:          0 :                 param2 |= (!!dlen << ROC_RE_ML_KEM_PARAM2_INSEED_BIT);
     644                 :          0 :                 break;
     645                 :          0 :         case RTE_CRYPTO_ML_KEM_OP_ENCAP:
     646                 :          0 :                 reqbuf_len = mlkem->encap.message.length + mlkem->encap.ek.length;
     647   [ #  #  #  # ]:          0 :                 if (reqbuf_len > (metabuf_len - dlen)) {
     648                 :          0 :                         op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
     649                 :          0 :                         return -ENOMEM;
     650                 :            :                 }
     651                 :            : 
     652   [ #  #  #  # ]:          0 :                 memcpy(dptr, mlkem->encap.message.data, mlkem->encap.message.length);
     653                 :          0 :                 dptr += mlkem->encap.message.length;
     654                 :          0 :                 memcpy(dptr, mlkem->encap.ek.data, mlkem->encap.ek.length);
     655                 :          0 :                 dptr += mlkem->encap.ek.length;
     656                 :            : 
     657                 :          0 :                 dlen = mlkem->encap.message.length + mlkem->encap.ek.length;
     658                 :          0 :                 w4.s.opcode_major = ROC_RE_MAJOR_OP_MLKEM;
     659                 :          0 :                 w4.s.opcode_minor = ROC_RE_MINOR_OP_MLKEM_ENCAP;
     660                 :          0 :                 param2 = sess->ml_kem_ctx.type;
     661   [ #  #  #  # ]:          0 :                 param2 |= (!!mlkem->encap.message.length << ROC_RE_ML_KEM_PARAM2_INMSG_BIT);
     662                 :          0 :                 break;
     663                 :          0 :         case RTE_CRYPTO_ML_KEM_OP_DECAP:
     664                 :          0 :                 reqbuf_len = mlkem->decap.dk.length + mlkem->decap.cipher.length;
     665   [ #  #  #  # ]:          0 :                 if (reqbuf_len > (metabuf_len - dlen)) {
     666                 :          0 :                         op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
     667                 :          0 :                         return -ENOMEM;
     668                 :            :                 }
     669                 :            : 
     670                 :          0 :                 memcpy(dptr, mlkem->decap.dk.data, mlkem->decap.dk.length);
     671                 :          0 :                 dptr += mlkem->decap.dk.length;
     672                 :          0 :                 memcpy(dptr, mlkem->decap.cipher.data, mlkem->decap.cipher.length);
     673                 :          0 :                 dptr += mlkem->decap.cipher.length;
     674                 :            : 
     675                 :          0 :                 dlen = mlkem->decap.cipher.length + mlkem->decap.dk.length;
     676                 :          0 :                 w4.s.opcode_major = ROC_RE_MAJOR_OP_MLKEM;
     677                 :          0 :                 w4.s.opcode_minor = ROC_RE_MINOR_OP_MLKEM_DECAP;
     678                 :          0 :                 param2 = sess->ml_kem_ctx.type;
     679                 :          0 :                 break;
     680                 :          0 :         default:
     681                 :          0 :                 op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
     682                 :          0 :                 return -EINVAL;
     683                 :            :         }
     684                 :            : 
     685                 :          0 :         w4.s.param1 = 0;
     686                 :          0 :         w4.s.param2 = param2;
     687                 :          0 :         w4.s.dlen = dlen;
     688                 :            : 
     689                 :          0 :         inst->w4.u64 = w4.u64;
     690                 :            : 
     691                 :            :         /* Reuse entire space of meta buffer as output is large in PQC */
     692                 :          0 :         inst->rptr = (uintptr_t)meta_buf->vaddr;
     693                 :            : 
     694                 :          0 :         return 0;
     695                 :            : }
     696                 :            : 
     697                 :            : static __rte_always_inline int __rte_hot
     698                 :            : cnxk_ae_enqueue_ml_dsa_op(struct rte_crypto_op *op, struct roc_ae_buf_ptr *meta_buf,
     699                 :            :                        struct cnxk_ae_sess *sess, struct cpt_inst_s *inst)
     700                 :            : {
     701                 :          0 :         size_t metabuf_len = cnxk_cpt_asym_get_mlen(), reqbuf_len;
     702                 :            :         struct rte_crypto_ml_dsa_op *mldsa = &op->asym->mldsa;
     703                 :            :         enum rte_crypto_auth_algorithm hash;
     704                 :            :         bool sign_deterministic;
     705                 :            :         union cpt_inst_w4 w4;
     706                 :            :         uint16_t param1 = 0;
     707                 :            :         uint32_t dlen = 0;
     708                 :            :         uint16_t param2;
     709                 :            :         uint8_t *dptr;
     710                 :            :         uint8_t minor;
     711                 :            : 
     712                 :            :         /* Input buffer */
     713                 :            :         dptr = meta_buf->vaddr;
     714                 :          0 :         inst->dptr = (uintptr_t)dptr;
     715                 :            : 
     716   [ #  #  #  #  :          0 :         switch (mldsa->op) {
             #  #  #  # ]
     717                 :          0 :         case RTE_CRYPTO_ML_DSA_OP_KEYGEN:
     718                 :          0 :                 reqbuf_len = mldsa->keygen.seed.length;
     719   [ #  #  #  # ]:          0 :                 if (reqbuf_len > (metabuf_len - dlen)) {
     720                 :          0 :                         op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
     721                 :          0 :                         return -ENOMEM;
     722                 :            :                 }
     723                 :            : 
     724                 :          0 :                 param2 = sess->ml_dsa_ctx.type;
     725                 :            : 
     726   [ #  #  #  # ]:          0 :                 memcpy(dptr, mldsa->keygen.seed.data, mldsa->keygen.seed.length);
     727                 :          0 :                 dptr += mldsa->keygen.seed.length;
     728   [ #  #  #  # ]:          0 :                 param2 |= (!!mldsa->keygen.seed.length << ROC_RE_ML_DSA_PARAM2_SEED_BIT);
     729                 :            : 
     730                 :          0 :                 dlen += mldsa->keygen.seed.length;
     731                 :          0 :                 w4.s.opcode_major = ROC_RE_MAJOR_OP_MLDSA;
     732                 :          0 :                 w4.s.opcode_minor = ROC_RE_MINOR_OP_MLDSA_KEYGEN;
     733                 :          0 :                 break;
     734                 :          0 :         case RTE_CRYPTO_ML_DSA_OP_SIGN:
     735                 :          0 :                 reqbuf_len = mldsa->siggen.message.length + mldsa->siggen.privkey.length +
     736                 :          0 :                              mldsa->siggen.ctx.length + mldsa->siggen.mu.length +
     737                 :          0 :                              mldsa->siggen.seed.length;
     738                 :            : 
     739   [ #  #  #  # ]:          0 :                 if (reqbuf_len > (metabuf_len - dlen)) {
     740                 :          0 :                         op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
     741                 :          0 :                         return -ENOMEM;
     742                 :            :                 }
     743                 :            : 
     744                 :          0 :                 sign_deterministic = sess->ml_dsa_ctx.sign_deterministic;
     745                 :          0 :                 hash = op->asym->mldsa.siggen.hash;
     746                 :            :                 minor = ROC_RE_MINOR_OP_MLDSA_SIGN;
     747                 :            : 
     748                 :          0 :                 param1 = mldsa->siggen.message.length;
     749                 :          0 :                 param2 = sess->ml_dsa_ctx.type;
     750   [ #  #  #  # ]:          0 :                 if (hash == 0) {
     751                 :            :                         minor |= (0 << ROC_RE_ML_DSA_MINOR_MSG_TYPE_BIT);
     752   [ #  #  #  # ]:          0 :                 } else if (mldsa->siggen.mu.length != 0) {
     753                 :            :                         minor |= (3 << ROC_RE_ML_DSA_MINOR_MSG_TYPE_BIT);
     754                 :            :                 } else {
     755   [ #  #  #  #  :          0 :                         if (!sess->ml_dsa_ctx.sign_prehash ||
             #  #  #  # ]
     756   [ #  #  #  # ]:          0 :                                 hash >= RTE_DIM(mldsa_hash_algo) || mldsa_hash_algo[hash] == 0) {
     757                 :          0 :                                 op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
     758                 :          0 :                                 return -EINVAL;
     759                 :            :                         }
     760                 :            : 
     761                 :            :                         minor |= (1 << ROC_RE_ML_DSA_MINOR_MSG_TYPE_BIT);
     762                 :          0 :                         param2 |= (mldsa_hash_algo[hash] << ROC_RE_ML_DSA_PARAM2_SIGN_BIT);
     763                 :            :                 }
     764                 :            : 
     765   [ #  #  #  # ]:          0 :                 minor |= ((sign_deterministic ? 0 : 2) << ROC_RE_ML_DSA_MINOR_SIGN_TYPE_BIT);
     766                 :            : 
     767   [ #  #  #  # ]:          0 :                 if (!sign_deterministic) {
     768   [ #  #  #  # ]:          0 :                         if (!mldsa->siggen.seed.length) {
     769                 :          0 :                                 op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
     770                 :          0 :                                 return -EINVAL;
     771                 :            :                         }
     772                 :            : 
     773                 :          0 :                         memcpy(dptr, mldsa->siggen.seed.data, mldsa->siggen.seed.length);
     774                 :          0 :                         dptr += mldsa->siggen.seed.length;
     775                 :          0 :                         dlen += mldsa->siggen.seed.length;
     776                 :            :                 }
     777                 :            : 
     778   [ #  #  #  # ]:          0 :                 memcpy(dptr, mldsa->siggen.privkey.data, mldsa->siggen.privkey.length);
     779                 :          0 :                 dptr += mldsa->siggen.privkey.length;
     780                 :          0 :                 dlen += mldsa->siggen.privkey.length;
     781                 :            : 
     782                 :          0 :                 memcpy(dptr, mldsa->siggen.ctx.data, mldsa->siggen.ctx.length);
     783                 :          0 :                 dptr += mldsa->siggen.ctx.length;
     784                 :          0 :                 dlen += mldsa->siggen.ctx.length;
     785   [ #  #  #  # ]:          0 :                 if (mldsa->siggen.ctx.length > (UINT16_MAX >> ROC_RE_ML_DSA_PARAM2_CTXN_BIT)) {
     786                 :          0 :                         op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
     787                 :          0 :                         return -EINVAL;
     788                 :            :                 }
     789                 :          0 :                 param2 |= ((uint16_t)mldsa->siggen.ctx.length
     790                 :          0 :                                 << ROC_RE_ML_DSA_PARAM2_CTXN_BIT);
     791                 :            : 
     792   [ #  #  #  # ]:          0 :                 if (mldsa->siggen.mu.length != 0) {
     793                 :          0 :                         memcpy(dptr, mldsa->siggen.mu.data, mldsa->siggen.mu.length);
     794                 :          0 :                         dptr += mldsa->siggen.mu.length;
     795                 :          0 :                         dlen += mldsa->siggen.mu.length;
     796                 :          0 :                         param1 = mldsa->siggen.mu.length;
     797   [ #  #  #  # ]:          0 :                 } else if (mldsa->siggen.message.length != 0) {
     798                 :          0 :                         memcpy(dptr, mldsa->siggen.message.data, mldsa->siggen.message.length);
     799                 :          0 :                         dptr += mldsa->siggen.message.length;
     800                 :          0 :                         dlen += mldsa->siggen.message.length;
     801                 :            :                 }
     802                 :            : 
     803                 :          0 :                 w4.s.opcode_major = ROC_RE_MAJOR_OP_MLDSA;
     804                 :          0 :                 w4.s.opcode_minor = minor;
     805                 :          0 :                 break;
     806                 :          0 :         case RTE_CRYPTO_ML_DSA_OP_VERIFY:
     807                 :          0 :                 reqbuf_len = mldsa->sigver.message.length + mldsa->sigver.pubkey.length +
     808                 :          0 :                              mldsa->sigver.ctx.length + mldsa->sigver.mu.length +
     809                 :          0 :                              mldsa->sigver.sign.length;
     810                 :            : 
     811   [ #  #  #  # ]:          0 :                 if (reqbuf_len > (metabuf_len - dlen)) {
     812                 :          0 :                         op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
     813                 :          0 :                         return -ENOMEM;
     814                 :            :                 }
     815                 :            : 
     816                 :          0 :                 hash = op->asym->mldsa.sigver.hash;
     817                 :            :                 minor = ROC_RE_MINOR_OP_MLDSA_VERIFY;
     818                 :            : 
     819                 :          0 :                 param1 = mldsa->sigver.message.length;
     820                 :          0 :                 param2 = sess->ml_dsa_ctx.type;
     821   [ #  #  #  # ]:          0 :                 if (hash == 0) {
     822                 :            :                         minor |= (0 << ROC_RE_ML_DSA_MINOR_MSG_TYPE_BIT);
     823   [ #  #  #  # ]:          0 :                 } else if (mldsa->sigver.mu.length != 0) {
     824                 :            :                         minor |= (3 << ROC_RE_ML_DSA_MINOR_MSG_TYPE_BIT);
     825                 :            :                 } else {
     826   [ #  #  #  #  :          0 :                         if (!sess->ml_dsa_ctx.sign_prehash ||
             #  #  #  # ]
     827   [ #  #  #  # ]:          0 :                                 hash >= RTE_DIM(mldsa_hash_algo) || mldsa_hash_algo[hash] == 0) {
     828                 :          0 :                                 op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
     829                 :          0 :                                 return -EINVAL;
     830                 :            :                         }
     831                 :            : 
     832                 :            :                         minor |= (1 << ROC_RE_ML_DSA_MINOR_MSG_TYPE_BIT);
     833                 :          0 :                         param2 |= (mldsa_hash_algo[hash] << ROC_RE_ML_DSA_PARAM2_SIGN_BIT);
     834                 :            :                 }
     835                 :            : 
     836   [ #  #  #  # ]:          0 :                 memcpy(dptr, mldsa->sigver.pubkey.data, mldsa->sigver.pubkey.length);
     837                 :          0 :                 dptr += mldsa->sigver.pubkey.length;
     838                 :          0 :                 dlen += mldsa->sigver.pubkey.length;
     839                 :            : 
     840                 :          0 :                 memcpy(dptr, mldsa->sigver.ctx.data, mldsa->sigver.ctx.length);
     841                 :          0 :                 dptr += mldsa->sigver.ctx.length;
     842                 :          0 :                 dlen += mldsa->sigver.ctx.length;
     843   [ #  #  #  # ]:          0 :                 if (mldsa->sigver.ctx.length > (UINT16_MAX >> ROC_RE_ML_DSA_PARAM2_CTXN_BIT)) {
     844                 :          0 :                         op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
     845                 :          0 :                         return -EINVAL;
     846                 :            :                 }
     847                 :          0 :                 param2 |= ((uint16_t)mldsa->sigver.ctx.length
     848                 :          0 :                                 << ROC_RE_ML_DSA_PARAM2_CTXN_BIT);
     849                 :            : 
     850   [ #  #  #  # ]:          0 :                 if (mldsa->sigver.mu.length != 0) {
     851                 :          0 :                         memcpy(dptr, mldsa->sigver.mu.data, mldsa->sigver.mu.length);
     852                 :          0 :                         dptr += mldsa->sigver.mu.length;
     853                 :          0 :                         dlen += mldsa->sigver.mu.length;
     854                 :          0 :                         param1 = mldsa->sigver.mu.length;
     855   [ #  #  #  # ]:          0 :                 } else if (mldsa->sigver.message.length != 0) {
     856                 :          0 :                         memcpy(dptr, mldsa->sigver.message.data, mldsa->sigver.message.length);
     857                 :          0 :                         dptr += mldsa->sigver.message.length;
     858                 :          0 :                         dlen += mldsa->sigver.message.length;
     859                 :            :                 }
     860                 :            : 
     861                 :          0 :                 memcpy(dptr, mldsa->sigver.sign.data, mldsa->sigver.sign.length);
     862                 :          0 :                 dptr += mldsa->sigver.sign.length;
     863                 :          0 :                 dlen += mldsa->sigver.sign.length;
     864                 :            : 
     865                 :          0 :                 w4.s.opcode_major = ROC_RE_MAJOR_OP_MLDSA;
     866                 :          0 :                 w4.s.opcode_minor = minor;
     867                 :          0 :                 break;
     868                 :          0 :         default:
     869                 :          0 :                 op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
     870                 :          0 :                 return -EINVAL;
     871                 :            :         }
     872                 :            : 
     873                 :          0 :         w4.s.param1 = param1;
     874                 :          0 :         w4.s.param2 = param2;
     875                 :          0 :         w4.s.dlen = dlen;
     876                 :            : 
     877                 :          0 :         inst->w4.u64 = w4.u64;
     878                 :            : 
     879                 :            :         /* Reuse entire space of meta buffer as output is large in PQC */
     880                 :          0 :         inst->rptr = (uintptr_t)meta_buf->vaddr;
     881                 :            : 
     882                 :          0 :         return 0;
     883                 :            : }
     884                 :            : 
     885                 :            : static __rte_always_inline void
     886                 :            : cnxk_ae_ecdsa_sign_prep(struct rte_crypto_ecdsa_op_param *ecdsa,
     887                 :            :                         struct roc_ae_buf_ptr *meta_buf,
     888                 :            :                         uint64_t fpm_table_iova, struct roc_ae_ec_group *ec_grp,
     889                 :            :                         struct cnxk_ae_sess *sess, struct cpt_inst_s *inst)
     890                 :            : {
     891                 :          0 :         uint16_t message_len = ecdsa->message.length;
     892                 :          0 :         uint16_t pkey_len = sess->ec_ctx.pkey.length;
     893                 :            :         uint8_t curveid = sess->ec_ctx.curveid;
     894                 :            :         uint16_t p_align, k_align, m_align;
     895                 :          0 :         uint16_t k_len = ecdsa->k.length;
     896                 :            :         uint16_t order_len, prime_len;
     897                 :            :         uint16_t o_offset, pk_offset;
     898                 :            :         union cpt_inst_w4 w4;
     899                 :            :         uint16_t dlen;
     900                 :            :         uint8_t *dptr;
     901                 :            : 
     902                 :          0 :         prime_len = ec_grp->prime.length;
     903                 :          0 :         order_len = ec_grp->order.length;
     904                 :            : 
     905                 :            :         /* Truncate input length to curve prime length */
     906                 :            :         if (message_len > prime_len)
     907                 :            :                 message_len = prime_len;
     908                 :          0 :         m_align = RTE_ALIGN_CEIL(message_len, 8);
     909                 :            : 
     910                 :          0 :         p_align = RTE_ALIGN_CEIL(prime_len, 8);
     911                 :          0 :         k_align = RTE_ALIGN_CEIL(k_len, 8);
     912                 :            : 
     913                 :            :         /* Set write offset for order and private key */
     914                 :          0 :         o_offset = prime_len - order_len;
     915                 :          0 :         pk_offset = p_align - pkey_len;
     916                 :            : 
     917                 :            :         /* Input buffer */
     918                 :            :         dptr = meta_buf->vaddr;
     919                 :          0 :         inst->dptr = (uintptr_t)dptr;
     920                 :            : 
     921                 :            :         /*
     922                 :            :          * Set dlen = sum(sizeof(fpm address), ROUNDUP8(scalar len, input len),
     923                 :            :          * ROUNDUP8(priv key len, prime len, order len)).
     924                 :            :          * Please note, private key, order cannot exceed prime
     925                 :            :          * length i.e 3 * p_align.
     926                 :            :          */
     927                 :          0 :         dlen = sizeof(fpm_table_iova) + k_align + m_align + p_align * 5;
     928                 :            : 
     929                 :          0 :         memset(dptr, 0, dlen);
     930                 :            : 
     931                 :          0 :         *(uint64_t *)dptr = fpm_table_iova;
     932                 :          0 :         dptr += sizeof(fpm_table_iova);
     933                 :            : 
     934                 :          0 :         memcpy(dptr, ecdsa->k.data, k_len);
     935                 :          0 :         dptr += k_align;
     936                 :            : 
     937                 :          0 :         memcpy(dptr, ec_grp->prime.data, prime_len);
     938                 :          0 :         dptr += p_align;
     939                 :            : 
     940                 :          0 :         memcpy(dptr + o_offset, ec_grp->order.data, order_len);
     941                 :          0 :         dptr += p_align;
     942                 :            : 
     943                 :          0 :         memcpy(dptr + pk_offset, sess->ec_ctx.pkey.data, pkey_len);
     944                 :          0 :         dptr += p_align;
     945                 :            : 
     946                 :          0 :         memcpy(dptr, ecdsa->message.data, message_len);
     947                 :          0 :         dptr += m_align;
     948                 :            : 
     949                 :          0 :         memcpy(dptr, ec_grp->consta.data, prime_len);
     950                 :          0 :         dptr += p_align;
     951                 :            : 
     952                 :          0 :         memcpy(dptr, ec_grp->constb.data, prime_len);
     953                 :          0 :         dptr += p_align;
     954                 :            : 
     955                 :            :         /* Setup opcodes */
     956                 :          0 :         w4.s.opcode_major = ROC_AE_MAJOR_OP_EC;
     957                 :          0 :         w4.s.opcode_minor = ROC_AE_MINOR_OP_EC_SIGN;
     958                 :            : 
     959                 :          0 :         w4.s.param1 = curveid | (message_len << 8);
     960                 :          0 :         w4.s.param2 = (p_align << 8) | k_len;
     961                 :          0 :         w4.s.dlen = dlen;
     962                 :            : 
     963                 :          0 :         inst->w4.u64 = w4.u64;
     964                 :          0 :         inst->rptr = (uintptr_t)dptr;
     965                 :          0 : }
     966                 :            : 
     967                 :            : static __rte_always_inline void
     968                 :            : cnxk_ae_ecdsa_verify_prep(struct rte_crypto_ecdsa_op_param *ecdsa,
     969                 :            :                           struct roc_ae_buf_ptr *meta_buf,
     970                 :            :                           uint64_t fpm_table_iova,
     971                 :            :                           struct roc_ae_ec_group *ec_grp, struct cnxk_ae_sess *sess,
     972                 :            :                           struct cpt_inst_s *inst)
     973                 :            : {
     974                 :          0 :         uint32_t message_len = ecdsa->message.length;
     975                 :          0 :         uint16_t qx_len = sess->ec_ctx.q.x.length;
     976                 :          0 :         uint16_t qy_len = sess->ec_ctx.q.y.length;
     977                 :            :         uint8_t curveid = sess->ec_ctx.curveid;
     978                 :            :         uint16_t o_offset, r_offset, s_offset;
     979                 :          0 :         uint16_t r_len = ecdsa->r.length;
     980                 :          0 :         uint16_t s_len = ecdsa->s.length;
     981                 :            :         uint16_t order_len, prime_len;
     982                 :            :         uint16_t qx_offset, qy_offset;
     983                 :            :         uint16_t p_align, m_align;
     984                 :            :         union cpt_inst_w4 w4;
     985                 :            :         uint16_t dlen;
     986                 :            :         uint8_t *dptr;
     987                 :            : 
     988                 :          0 :         prime_len = ec_grp->prime.length;
     989                 :          0 :         order_len = ec_grp->order.length;
     990                 :            : 
     991                 :            :         /* Truncate input length to curve prime length */
     992                 :            :         if (message_len > prime_len)
     993                 :            :                 message_len = prime_len;
     994                 :            : 
     995                 :          0 :         m_align = RTE_ALIGN_CEIL(message_len, 8);
     996                 :          0 :         p_align = RTE_ALIGN_CEIL(prime_len, 8);
     997                 :            : 
     998                 :            :         /* Set write offset for sign, order and public key coordinates */
     999                 :          0 :         o_offset = prime_len - order_len;
    1000                 :          0 :         qx_offset = prime_len - qx_len;
    1001                 :          0 :         qy_offset = prime_len - qy_len;
    1002                 :          0 :         r_offset = prime_len - r_len;
    1003                 :          0 :         s_offset = prime_len - s_len;
    1004                 :            : 
    1005                 :            :         /* Input buffer */
    1006                 :            :         dptr = meta_buf->vaddr;
    1007                 :          0 :         inst->dptr = (uintptr_t)dptr;
    1008                 :            : 
    1009                 :            :         /*
    1010                 :            :          * Set dlen = sum(sizeof(fpm address), ROUNDUP8(message len),
    1011                 :            :          * ROUNDUP8(sign len(r and s), public key len(x and y coordinates),
    1012                 :            :          * prime len, order len)).
    1013                 :            :          * Please note sign, public key and order can not exceed prime length
    1014                 :            :          * i.e. 6 * p_align
    1015                 :            :          */
    1016                 :          0 :         dlen = sizeof(fpm_table_iova) + m_align + (8 * p_align);
    1017                 :            : 
    1018                 :          0 :         memset(dptr, 0, dlen);
    1019                 :            : 
    1020                 :          0 :         *(uint64_t *)dptr = fpm_table_iova;
    1021                 :          0 :         dptr += sizeof(fpm_table_iova);
    1022                 :            : 
    1023                 :          0 :         memcpy(dptr + r_offset, ecdsa->r.data, r_len);
    1024                 :          0 :         dptr += p_align;
    1025                 :            : 
    1026                 :          0 :         memcpy(dptr + s_offset, ecdsa->s.data, s_len);
    1027                 :          0 :         dptr += p_align;
    1028                 :            : 
    1029                 :          0 :         memcpy(dptr, ecdsa->message.data, message_len);
    1030                 :          0 :         dptr += m_align;
    1031                 :            : 
    1032                 :          0 :         memcpy(dptr + o_offset, ec_grp->order.data, order_len);
    1033                 :          0 :         dptr += p_align;
    1034                 :            : 
    1035                 :          0 :         memcpy(dptr, ec_grp->prime.data, prime_len);
    1036                 :          0 :         dptr += p_align;
    1037                 :            : 
    1038                 :          0 :         memcpy(dptr + qx_offset, sess->ec_ctx.q.x.data, qx_len);
    1039                 :          0 :         dptr += p_align;
    1040                 :            : 
    1041                 :          0 :         memcpy(dptr + qy_offset, sess->ec_ctx.q.y.data, qy_len);
    1042                 :          0 :         dptr += p_align;
    1043                 :            : 
    1044                 :          0 :         memcpy(dptr, ec_grp->consta.data, prime_len);
    1045                 :          0 :         dptr += p_align;
    1046                 :            : 
    1047                 :          0 :         memcpy(dptr, ec_grp->constb.data, prime_len);
    1048                 :          0 :         dptr += p_align;
    1049                 :            : 
    1050                 :            :         /* Setup opcodes */
    1051                 :          0 :         w4.s.opcode_major = ROC_AE_MAJOR_OP_EC;
    1052                 :          0 :         w4.s.opcode_minor = ROC_AE_MINOR_OP_EC_VERIFY;
    1053                 :            : 
    1054                 :          0 :         w4.s.param1 = curveid | (message_len << 8);
    1055                 :          0 :         w4.s.param2 = 0;
    1056                 :          0 :         w4.s.dlen = dlen;
    1057                 :            : 
    1058                 :          0 :         inst->w4.u64 = w4.u64;
    1059                 :          0 :         inst->rptr = (uintptr_t)dptr;
    1060                 :          0 : }
    1061                 :            : 
    1062                 :            : static __rte_always_inline int __rte_hot
    1063                 :            : cnxk_ae_enqueue_ecdsa_op(struct rte_crypto_op *op,
    1064                 :            :                          struct roc_ae_buf_ptr *meta_buf,
    1065                 :            :                          struct cnxk_ae_sess *sess, uint64_t *fpm_iova,
    1066                 :            :                          struct roc_ae_ec_group **ec_grp,
    1067                 :            :                          struct cpt_inst_s *inst)
    1068                 :            : {
    1069                 :            :         struct rte_crypto_ecdsa_op_param *ecdsa = &op->asym->ecdsa;
    1070                 :          0 :         uint8_t curveid = sess->ec_ctx.curveid;
    1071                 :            : 
    1072                 :          0 :         if (ecdsa->op_type == RTE_CRYPTO_ASYM_OP_SIGN)
    1073                 :          0 :                 cnxk_ae_ecdsa_sign_prep(ecdsa, meta_buf, fpm_iova[curveid],
    1074                 :          0 :                                         ec_grp[curveid], sess, inst);
    1075   [ #  #  #  # ]:          0 :         else if (ecdsa->op_type == RTE_CRYPTO_ASYM_OP_VERIFY)
    1076                 :          0 :                 cnxk_ae_ecdsa_verify_prep(ecdsa, meta_buf, fpm_iova[curveid],
    1077                 :          0 :                                           ec_grp[curveid], sess, inst);
    1078                 :            :         else {
    1079                 :          0 :                 op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
    1080                 :          0 :                 return -EINVAL;
    1081                 :            :         }
    1082                 :            :         return 0;
    1083                 :            : }
    1084                 :            : 
    1085                 :            : static __rte_always_inline void
    1086                 :            : cnxk_ae_eddsa_sign_prep(struct rte_crypto_eddsa_op_param *eddsa, struct roc_ae_buf_ptr *meta_buf,
    1087                 :            :                         uint64_t fpm_table_iova, struct roc_ae_ec_group *ec_grp,
    1088                 :            :                         struct cnxk_ae_sess *sess, struct cpt_inst_s *inst)
    1089                 :            : {
    1090                 :          0 :         const uint8_t iv_sha512[] = {
    1091                 :            :                 0x6a, 0x09, 0xe6, 0x67, 0xf3, 0xbc, 0xc9, 0x08,
    1092                 :            :                 0xbb, 0x67, 0xae, 0x85, 0x84, 0xca, 0xa7, 0x3b,
    1093                 :            :                 0x3c, 0x6e, 0xf3, 0x72, 0xfe, 0x94, 0xf8, 0x2b,
    1094                 :            :                 0xa5, 0x4f, 0xf5, 0x3a, 0x5f, 0x1d, 0x36, 0xf1,
    1095                 :            :                 0x51, 0x0e, 0x52, 0x7f, 0xad, 0xe6, 0x82, 0xd1,
    1096                 :            :                 0x9b, 0x05, 0x68, 0x8c, 0x2b, 0x3e, 0x6c, 0x1f,
    1097                 :            :                 0x1f, 0x83, 0xd9, 0xab, 0xfb, 0x41, 0xbd, 0x6b,
    1098                 :            :                 0x5b, 0xe0, 0xcd, 0x19, 0x13, 0x7e, 0x21, 0x79};
    1099                 :          0 :         const uint8_t domx_ed25519[] = {
    1100                 :            :                 0x53, 0x69, 0x67, 0x45, 0x64, 0x32, 0x35, 0x35,
    1101                 :            :                 0x31, 0x39, 0x20, 0x6E, 0x6F, 0x20, 0x45, 0x64,
    1102                 :            :                 0x32, 0x35, 0x35, 0x31, 0x39, 0x20, 0x63, 0x6F,
    1103                 :            :                 0x6C, 0x6C, 0x69, 0x73, 0x69, 0x6F, 0x6E, 0x73,
    1104                 :            :                 0x00, 0x00};
    1105                 :          0 :         const uint8_t domx_ed448[] = {
    1106                 :            :                 0x53, 0x69, 0x67, 0x45, 0x64, 0x34, 0x34, 0x38,
    1107                 :            :                 0x00, 0x00};
    1108                 :            : 
    1109                 :          0 :         uint16_t pubkey_len = sess->ec_ctx.q.x.length;
    1110                 :          0 :         uint16_t message_len = eddsa->message.length;
    1111                 :          0 :         uint16_t pkey_len = sess->ec_ctx.pkey.length;
    1112                 :            :         uint8_t curveid = sess->ec_ctx.curveid;
    1113                 :            :         const uint8_t *domx_ptr = NULL;
    1114                 :            :         uint16_t order_len, prime_len;
    1115                 :            :         uint16_t ctx_align, k_align;
    1116                 :            :         uint8_t pub = 0, ph = 0;
    1117                 :            :         uint64_t message_handle;
    1118                 :            :         union cpt_inst_w4 w4;
    1119                 :            :         uint8_t domx_len = 0;
    1120                 :            :         uint8_t ctx_len = 0;
    1121                 :            :         uint16_t iv_len = 0;
    1122                 :            :         uint64_t ctrl = 0;
    1123                 :            :         uint16_t dlen;
    1124                 :            :         uint8_t *dptr;
    1125                 :            : 
    1126                 :          0 :         if (eddsa->instance == RTE_CRYPTO_EDCURVE_25519PH ||
    1127                 :            :             eddsa->instance == RTE_CRYPTO_EDCURVE_448PH)
    1128                 :            :                 ph = 1;
    1129                 :            : 
    1130   [ #  #  #  # ]:          0 :         if (curveid == ROC_AE_EC_ID_ED25519)
    1131                 :            :                 iv_len = sizeof(iv_sha512);
    1132                 :            : 
    1133                 :          0 :         prime_len = ec_grp->prime.length;
    1134                 :          0 :         order_len = ec_grp->order.length;
    1135                 :          0 :         ctx_len = eddsa->context.length;
    1136                 :            : 
    1137   [ #  #  #  # ]:          0 :         if (curveid == ROC_AE_EC_ID_ED25519) {
    1138   [ #  #  #  # ]:          0 :                 if (ph || ctx_len) {
    1139                 :            :                         domx_ptr = domx_ed25519;
    1140                 :            :                         domx_len = sizeof(domx_ed25519);
    1141                 :            :                 }
    1142                 :            :         } else {
    1143                 :            :                 domx_ptr = domx_ed448;
    1144                 :            :                 domx_len = sizeof(domx_ed448);
    1145                 :            :         }
    1146                 :            : 
    1147   [ #  #  #  # ]:          0 :         if (pubkey_len)
    1148                 :            :                 pub = 1;
    1149                 :            : 
    1150                 :          0 :         ctx_align = RTE_ALIGN_CEIL(ctx_len + domx_len, 8);
    1151                 :          0 :         k_align = RTE_ALIGN_CEIL(pkey_len, 8);
    1152                 :            : 
    1153                 :            :         /* Set control word */
    1154                 :            :         ctrl = message_len;
    1155                 :          0 :         ctrl |= (ctx_len + domx_len) << 16;
    1156                 :            : 
    1157                 :            :         /* Copy message and set message handle in metabuf */
    1158                 :            :         dptr = meta_buf->vaddr;
    1159   [ #  #  #  # ]:          0 :         memcpy(dptr, eddsa->message.data, message_len);
    1160                 :            :         message_handle = (uint64_t)dptr;
    1161                 :          0 :         dptr += RTE_ALIGN_CEIL(message_len, 8);
    1162                 :            : 
    1163                 :            :         /* Input buffer */
    1164                 :          0 :         inst->dptr = (uintptr_t)dptr;
    1165                 :            : 
    1166                 :            :         /*
    1167                 :            :          * Set dlen = sum(sizeof(fpm address), input handle, ctrl,
    1168                 :            :          * ROUNDUP8(prime len, order len, constant), ROUNDUP8(priv and
    1169                 :            :          * pubkey len), ROUNDUP8(context len) and iv len (if ED25519)).
    1170                 :            :          */
    1171                 :          0 :         dlen = sizeof(fpm_table_iova) + sizeof(message_handle) + sizeof(ctrl) + prime_len * 3 +
    1172                 :          0 :                 k_align * 2 + ctx_align + iv_len;
    1173                 :            : 
    1174                 :          0 :         *(uint64_t *)dptr = fpm_table_iova;
    1175                 :            :         dptr += sizeof(fpm_table_iova);
    1176                 :            : 
    1177   [ #  #  #  # ]:          0 :         *(uint64_t *)dptr = rte_cpu_to_be_64(message_handle);
    1178                 :            :         dptr += sizeof(message_handle);
    1179                 :            : 
    1180   [ #  #  #  # ]:          0 :         *(uint64_t *)dptr = rte_cpu_to_be_64(ctrl);
    1181                 :          0 :         dptr += sizeof(ctrl);
    1182                 :            : 
    1183   [ #  #  #  # ]:          0 :         memcpy(dptr, ec_grp->prime.data, prime_len);
    1184                 :          0 :         dptr += prime_len;
    1185                 :            : 
    1186                 :          0 :         memcpy(dptr, ec_grp->order.data, order_len);
    1187                 :          0 :         dptr += prime_len;
    1188                 :            : 
    1189                 :          0 :         memcpy(dptr, ec_grp->consta.data, prime_len);
    1190                 :          0 :         dptr += prime_len;
    1191                 :            : 
    1192                 :          0 :         memcpy(dptr, sess->ec_ctx.pkey.data, pkey_len);
    1193                 :          0 :         dptr += k_align;
    1194                 :            : 
    1195                 :          0 :         memcpy(dptr, sess->ec_ctx.q.x.data, pubkey_len);
    1196                 :          0 :         dptr += k_align;
    1197                 :            : 
    1198                 :          0 :         memcpy(dptr, domx_ptr, domx_len);
    1199   [ #  #  #  # ]:          0 :         if (eddsa->instance != RTE_CRYPTO_EDCURVE_25519) {
    1200                 :          0 :                 memset(dptr + (domx_len - 1), ctx_len, 1);
    1201                 :          0 :                 memset(dptr + (domx_len - 2), ph, 1);
    1202                 :            :         }
    1203                 :            : 
    1204   [ #  #  #  # ]:          0 :         memcpy(dptr + domx_len, eddsa->context.data, ctx_len);
    1205                 :          0 :         dptr += ctx_align;
    1206                 :            : 
    1207   [ #  #  #  # ]:          0 :         if (curveid == ROC_AE_EC_ID_ED25519) {
    1208                 :          0 :                 memcpy(dptr, iv_sha512, iv_len);
    1209                 :          0 :                 dptr += iv_len;
    1210                 :            :         }
    1211                 :            : 
    1212                 :            :         /* Setup opcodes */
    1213                 :          0 :         w4.u64 = sess->cpt_inst_w4;
    1214                 :          0 :         w4.s.opcode_minor = ROC_AE_MINOR_OP_ED_SIGN;
    1215                 :          0 :         w4.s.param1 |= ((pub << ROC_AE_ED_PARAM1_KEYGEN_BIT) | (ph << ROC_AE_EC_PARAM1_PH_BIT));
    1216                 :          0 :         w4.s.param2 = 0;
    1217                 :          0 :         w4.s.dlen = dlen;
    1218                 :            : 
    1219                 :          0 :         inst->w4.u64 = w4.u64;
    1220                 :          0 :         inst->rptr = (uintptr_t)dptr;
    1221                 :          0 : }
    1222                 :            : 
    1223                 :            : static __rte_always_inline void
    1224                 :            : cnxk_ae_eddsa_verify_prep(struct rte_crypto_eddsa_op_param *eddsa, struct roc_ae_buf_ptr *meta_buf,
    1225                 :            :                           uint64_t fpm_table_iova, struct roc_ae_ec_group *ec_grp,
    1226                 :            :                           struct cnxk_ae_sess *sess, struct cpt_inst_s *inst)
    1227                 :            : {
    1228                 :          0 :         const uint8_t iv_sha512[] = {
    1229                 :            :                 0x6a, 0x09, 0xe6, 0x67, 0xf3, 0xbc, 0xc9, 0x08,
    1230                 :            :                 0xbb, 0x67, 0xae, 0x85, 0x84, 0xca, 0xa7, 0x3b,
    1231                 :            :                 0x3c, 0x6e, 0xf3, 0x72, 0xfe, 0x94, 0xf8, 0x2b,
    1232                 :            :                 0xa5, 0x4f, 0xf5, 0x3a, 0x5f, 0x1d, 0x36, 0xf1,
    1233                 :            :                 0x51, 0x0e, 0x52, 0x7f, 0xad, 0xe6, 0x82, 0xd1,
    1234                 :            :                 0x9b, 0x05, 0x68, 0x8c, 0x2b, 0x3e, 0x6c, 0x1f,
    1235                 :            :                 0x1f, 0x83, 0xd9, 0xab, 0xfb, 0x41, 0xbd, 0x6b,
    1236                 :            :                 0x5b, 0xe0, 0xcd, 0x19, 0x13, 0x7e, 0x21, 0x79};
    1237                 :          0 :         const uint8_t domx_ed25519[] = {
    1238                 :            :                 0x53, 0x69, 0x67, 0x45, 0x64, 0x32, 0x35, 0x35,
    1239                 :            :                 0x31, 0x39, 0x20, 0x6E, 0x6F, 0x20, 0x45, 0x64,
    1240                 :            :                 0x32, 0x35, 0x35, 0x31, 0x39, 0x20, 0x63, 0x6F,
    1241                 :            :                 0x6C, 0x6C, 0x69, 0x73, 0x69, 0x6F, 0x6E, 0x73,
    1242                 :            :                 0x00, 0x00};
    1243                 :          0 :         const uint8_t domx_ed448[] = {
    1244                 :            :                 0x53, 0x69, 0x67, 0x45, 0x64, 0x34, 0x34, 0x38,
    1245                 :            :                 0x00, 0x00};
    1246                 :            : 
    1247                 :          0 :         uint16_t pubkey_len = sess->ec_ctx.q.x.length;
    1248                 :          0 :         uint16_t message_len = eddsa->message.length;
    1249                 :          0 :         uint16_t s_len = eddsa->sign.length / 2;
    1250                 :            :         uint8_t curveid = sess->ec_ctx.curveid;
    1251                 :            :         uint16_t ctx_align, k_align, s_align;
    1252                 :            :         const uint8_t *domx_ptr = NULL;
    1253                 :            :         uint16_t order_len, prime_len;
    1254                 :            :         uint64_t message_handle;
    1255                 :            :         union cpt_inst_w4 w4;
    1256                 :            :         uint8_t domx_len = 0;
    1257                 :            :         uint16_t iv_len = 0;
    1258                 :            :         uint8_t ctx_len = 0;
    1259                 :            :         uint64_t ctrl = 0;
    1260                 :            :         uint8_t ph = 0;
    1261                 :            :         uint16_t dlen;
    1262                 :            :         uint8_t *dptr;
    1263                 :            : 
    1264                 :          0 :         if (eddsa->instance == RTE_CRYPTO_EDCURVE_25519PH ||
    1265                 :            :             eddsa->instance == RTE_CRYPTO_EDCURVE_448PH)
    1266                 :            :                 ph = 1;
    1267                 :            : 
    1268   [ #  #  #  # ]:          0 :         if (curveid == ROC_AE_EC_ID_ED25519)
    1269                 :            :                 iv_len = sizeof(iv_sha512);
    1270                 :            : 
    1271                 :          0 :         prime_len = ec_grp->prime.length;
    1272                 :          0 :         order_len = ec_grp->order.length;
    1273                 :          0 :         ctx_len = eddsa->context.length;
    1274                 :            : 
    1275   [ #  #  #  # ]:          0 :         if (curveid == ROC_AE_EC_ID_ED25519) {
    1276   [ #  #  #  # ]:          0 :                 if (ph || ctx_len) {
    1277                 :            :                         domx_ptr = domx_ed25519;
    1278                 :            :                         domx_len = sizeof(domx_ed25519);
    1279                 :            :                 }
    1280                 :            :         } else {
    1281                 :            :                 domx_ptr = domx_ed448;
    1282                 :            :                 domx_len = sizeof(domx_ed448);
    1283                 :            :         }
    1284                 :            : 
    1285                 :          0 :         ctx_align = RTE_ALIGN_CEIL(ctx_len + domx_len, 8);
    1286                 :          0 :         k_align = RTE_ALIGN_CEIL(pubkey_len, 8);
    1287                 :          0 :         s_align = RTE_ALIGN_CEIL(s_len, 8);
    1288                 :            : 
    1289                 :            :         /* Set control word */
    1290                 :            :         ctrl = message_len;
    1291                 :          0 :         ctrl |= (ctx_len + domx_len) << 16;
    1292                 :            : 
    1293                 :            :         /* Copy message and set message handle in metabuf */
    1294                 :            :         dptr = meta_buf->vaddr;
    1295   [ #  #  #  # ]:          0 :         memcpy(dptr, eddsa->message.data, message_len);
    1296                 :            :         message_handle = (uint64_t)dptr;
    1297                 :          0 :         dptr += RTE_ALIGN_CEIL(message_len, 8);
    1298                 :            : 
    1299                 :            :         /* Input buffer */
    1300                 :          0 :         inst->dptr = (uintptr_t)dptr;
    1301                 :            : 
    1302                 :            :         /*
    1303                 :            :          * Set dlen = sum(sizeof(fpm address), input handle, ctrl,
    1304                 :            :          * ROUNDUP8(prime len, order len, constant), ROUNDUP8(pub key len),
    1305                 :            :          * ROUNDUP8(s and r len), context and iv len (if ED25519)).
    1306                 :            :          */
    1307                 :          0 :         dlen = sizeof(fpm_table_iova) + sizeof(message_handle) + sizeof(ctrl) + prime_len * 3 +
    1308                 :          0 :                 k_align + s_align * 2 + ctx_align + iv_len;
    1309                 :            : 
    1310                 :          0 :         *(uint64_t *)dptr = fpm_table_iova;
    1311                 :            :         dptr += sizeof(fpm_table_iova);
    1312                 :            : 
    1313   [ #  #  #  # ]:          0 :         *(uint64_t *)dptr = rte_cpu_to_be_64(message_handle);
    1314                 :            :         dptr += sizeof(message_handle);
    1315                 :            : 
    1316   [ #  #  #  # ]:          0 :         *(uint64_t *)dptr = rte_cpu_to_be_64(ctrl);
    1317                 :          0 :         dptr += sizeof(ctrl);
    1318                 :            : 
    1319   [ #  #  #  # ]:          0 :         memcpy(dptr, ec_grp->prime.data, prime_len);
    1320                 :          0 :         dptr += prime_len;
    1321                 :            : 
    1322                 :          0 :         memcpy(dptr, ec_grp->order.data, order_len);
    1323                 :          0 :         dptr += prime_len;
    1324                 :            : 
    1325                 :          0 :         memcpy(dptr, ec_grp->consta.data, prime_len);
    1326                 :          0 :         dptr += prime_len;
    1327                 :            : 
    1328                 :          0 :         memcpy(dptr, sess->ec_ctx.q.x.data, pubkey_len);
    1329                 :          0 :         dptr += k_align;
    1330                 :            : 
    1331                 :          0 :         memcpy(dptr, eddsa->sign.data, s_len);
    1332                 :          0 :         dptr += s_align;
    1333                 :            : 
    1334                 :          0 :         memcpy(dptr, eddsa->sign.data + s_len, s_len);
    1335                 :          0 :         dptr += s_align;
    1336                 :            : 
    1337                 :          0 :         memcpy(dptr, domx_ptr, domx_len);
    1338   [ #  #  #  # ]:          0 :         if (eddsa->instance != RTE_CRYPTO_EDCURVE_25519) {
    1339                 :          0 :                 memset(dptr + (domx_len - 1), ctx_len, 1);
    1340                 :          0 :                 memset(dptr + (domx_len - 2), ph, 1);
    1341                 :            :         }
    1342                 :            : 
    1343   [ #  #  #  # ]:          0 :         memcpy(dptr + domx_len, eddsa->context.data, ctx_len);
    1344                 :          0 :         dptr += ctx_align;
    1345                 :            : 
    1346   [ #  #  #  # ]:          0 :         if (curveid == ROC_AE_EC_ID_ED25519) {
    1347                 :          0 :                 memcpy(dptr, iv_sha512, iv_len);
    1348                 :          0 :                 dptr += iv_len;
    1349                 :            :         }
    1350                 :            : 
    1351                 :            :         /* Setup opcodes */
    1352                 :          0 :         w4.u64 = sess->cpt_inst_w4;
    1353                 :          0 :         w4.s.opcode_minor = ROC_AE_MINOR_OP_ED_VERIFY;
    1354                 :            : 
    1355                 :          0 :         w4.s.param1 |= (ph << ROC_AE_EC_PARAM1_PH_BIT);
    1356                 :          0 :         w4.s.param2 = 0;
    1357                 :          0 :         w4.s.dlen = dlen;
    1358                 :            : 
    1359                 :          0 :         inst->w4.u64 = w4.u64;
    1360                 :          0 :         inst->rptr = (uintptr_t)dptr;
    1361                 :          0 : }
    1362                 :            : 
    1363                 :            : static __rte_always_inline int __rte_hot
    1364                 :            : cnxk_ae_enqueue_eddsa_op(struct rte_crypto_op *op, struct roc_ae_buf_ptr *meta_buf,
    1365                 :            :                          struct cnxk_ae_sess *sess, uint64_t *fpm_iova,
    1366                 :            :                          struct roc_ae_ec_group **ec_grp, struct cpt_inst_s *inst)
    1367                 :            : {
    1368                 :            :         struct rte_crypto_eddsa_op_param *eddsa = &op->asym->eddsa;
    1369                 :          0 :         uint8_t curveid = sess->ec_ctx.curveid;
    1370                 :            : 
    1371                 :          0 :         if (eddsa->message.length > (sess->msg_max_sz - CNXK_AE_EDDSA_MAX_PARAM_LEN)) {
    1372                 :          0 :                 op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
    1373                 :          0 :                 return -EINVAL;
    1374                 :            :         }
    1375                 :            : 
    1376   [ #  #  #  # ]:          0 :         if (eddsa->op_type == RTE_CRYPTO_ASYM_OP_SIGN)
    1377   [ #  #  #  # ]:          0 :                 cnxk_ae_eddsa_sign_prep(eddsa, meta_buf, fpm_iova[curveid], ec_grp[curveid], sess,
    1378                 :            :                                           inst);
    1379   [ #  #  #  # ]:          0 :         else if (eddsa->op_type == RTE_CRYPTO_ASYM_OP_VERIFY)
    1380   [ #  #  #  # ]:          0 :                 cnxk_ae_eddsa_verify_prep(eddsa, meta_buf, fpm_iova[curveid], ec_grp[curveid], sess,
    1381                 :            :                                           inst);
    1382                 :            :         else {
    1383                 :          0 :                 op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
    1384                 :          0 :                 return -EINVAL;
    1385                 :            :         }
    1386                 :            :         return 0;
    1387                 :            : }
    1388                 :            : 
    1389                 :            : static __rte_always_inline void
    1390                 :            : cnxk_ae_sm2_sign_prep(struct rte_crypto_sm2_op_param *sm2,
    1391                 :            :                         struct roc_ae_buf_ptr *meta_buf,
    1392                 :            :                         uint64_t fpm_table_iova, struct roc_ae_ec_group *ec_grp,
    1393                 :            :                         struct cnxk_ae_sess *sess, struct cpt_inst_s *inst)
    1394                 :            : {
    1395                 :          0 :         uint16_t message_len = sm2->message.length;
    1396                 :          0 :         uint16_t pkey_len = sess->ec_ctx.pkey.length;
    1397                 :            :         uint16_t p_align, k_align, m_align;
    1398                 :          0 :         uint16_t k_len = sm2->k.length;
    1399                 :            :         uint16_t order_len, prime_len;
    1400                 :            :         uint16_t o_offset, pk_offset;
    1401                 :            :         union cpt_inst_w4 w4;
    1402                 :            :         uint16_t dlen;
    1403                 :            :         uint8_t *dptr;
    1404                 :            : 
    1405                 :          0 :         prime_len = ec_grp->prime.length;
    1406                 :            :         if (prime_len > ROC_AE_EC_DATA_MAX)
    1407                 :            :                 prime_len = ROC_AE_EC_DATA_MAX;
    1408                 :          0 :         order_len = ec_grp->order.length;
    1409                 :            :         if (order_len > ROC_AE_EC_DATA_MAX)
    1410                 :            :                 order_len = ROC_AE_EC_DATA_MAX;
    1411                 :            : 
    1412                 :            :         if (pkey_len > ROC_AE_EC_DATA_MAX)
    1413                 :            :                 pkey_len = ROC_AE_EC_DATA_MAX;
    1414                 :            : 
    1415                 :            :         /* Truncate input length to curve prime length */
    1416                 :            :         if (message_len > prime_len)
    1417                 :            :                 message_len = prime_len;
    1418                 :          0 :         m_align = RTE_ALIGN_CEIL(message_len, 8);
    1419                 :            : 
    1420                 :          0 :         p_align = RTE_ALIGN_CEIL(prime_len, 8);
    1421                 :          0 :         k_align = RTE_ALIGN_CEIL(k_len, 8);
    1422                 :            : 
    1423                 :            :         /* Set write offset for order and private key */
    1424                 :          0 :         o_offset = prime_len - order_len;
    1425                 :          0 :         pk_offset = p_align - pkey_len;
    1426                 :            : 
    1427                 :            :         /* Input buffer */
    1428                 :            :         dptr = meta_buf->vaddr;
    1429                 :          0 :         inst->dptr = (uintptr_t)dptr;
    1430                 :            : 
    1431                 :            :         /*
    1432                 :            :          * Set dlen = sum(sizeof(fpm address), ROUNDUP8(scalar len, input len),
    1433                 :            :          * ROUNDUP8(priv key len, prime len, order len)).
    1434                 :            :          * Please note, private key, order cannot exceed prime
    1435                 :            :          * length i.e 3 * p_align.
    1436                 :            :          */
    1437                 :          0 :         dlen = sizeof(fpm_table_iova) + k_align + m_align + p_align * 5;
    1438                 :            : 
    1439                 :          0 :         memset(dptr, 0, dlen);
    1440                 :            : 
    1441                 :          0 :         *(uint64_t *)dptr = fpm_table_iova;
    1442                 :          0 :         dptr += sizeof(fpm_table_iova);
    1443                 :            : 
    1444   [ #  #  #  # ]:          0 :         rte_memcpy(dptr, sm2->k.data, k_len);
    1445                 :          0 :         dptr += k_align;
    1446                 :            : 
    1447   [ #  #  #  # ]:          0 :         rte_memcpy(dptr, ec_grp->prime.data, prime_len);
    1448                 :          0 :         dptr += p_align;
    1449                 :            : 
    1450   [ #  #  #  # ]:          0 :         rte_memcpy(dptr + o_offset, ec_grp->order.data, order_len);
    1451                 :          0 :         dptr += p_align;
    1452                 :            : 
    1453   [ #  #  #  # ]:          0 :         rte_memcpy(dptr + pk_offset, sess->ec_ctx.pkey.data, pkey_len);
    1454                 :          0 :         dptr += p_align;
    1455                 :            : 
    1456   [ #  #  #  # ]:          0 :         rte_memcpy(dptr, sm2->message.data, message_len);
    1457                 :          0 :         dptr += m_align;
    1458                 :            : 
    1459   [ #  #  #  # ]:          0 :         rte_memcpy(dptr, ec_grp->consta.data, prime_len);
    1460                 :          0 :         dptr += p_align;
    1461                 :            : 
    1462   [ #  #  #  # ]:          0 :         rte_memcpy(dptr, ec_grp->constb.data, prime_len);
    1463                 :          0 :         dptr += p_align;
    1464                 :            : 
    1465                 :            :         /* Setup opcodes */
    1466                 :          0 :         w4.s.opcode_major = ROC_AE_MAJOR_OP_EC;
    1467                 :          0 :         w4.s.opcode_minor = ROC_AE_MINOR_OP_EC_SIGN;
    1468                 :            : 
    1469                 :            :         /* prime length of SM2 curve is same as that of P256. */
    1470                 :          0 :         w4.s.param1 = ROC_AE_EC_ID_P256 |
    1471                 :          0 :                 ROC_AE_EC_PARAM1_SM2 | ROC_AE_EC_PARAM1_NONNIST | (message_len << 8);
    1472                 :          0 :         w4.s.param2 = (p_align << 8) | k_len;
    1473                 :          0 :         w4.s.dlen = dlen;
    1474                 :            : 
    1475                 :          0 :         inst->w4.u64 = w4.u64;
    1476                 :          0 :         inst->rptr = (uintptr_t)dptr;
    1477                 :          0 : }
    1478                 :            : 
    1479                 :            : static __rte_always_inline void
    1480                 :            : cnxk_ae_sm2_verify_prep(struct rte_crypto_sm2_op_param *sm2,
    1481                 :            :                           struct roc_ae_buf_ptr *meta_buf,
    1482                 :            :                           uint64_t fpm_table_iova,
    1483                 :            :                           struct roc_ae_ec_group *ec_grp, struct cnxk_ae_sess *sess,
    1484                 :            :                           struct cpt_inst_s *inst)
    1485                 :            : {
    1486                 :          0 :         uint32_t message_len = sm2->message.length;
    1487                 :            :         uint16_t o_offset, r_offset, s_offset;
    1488                 :          0 :         uint16_t qx_len = sess->ec_ctx.q.x.length;
    1489                 :          0 :         uint16_t qy_len = sess->ec_ctx.q.y.length;
    1490                 :          0 :         uint16_t r_len = sm2->r.length;
    1491                 :          0 :         uint16_t s_len = sm2->s.length;
    1492                 :            :         uint16_t order_len, prime_len;
    1493                 :            :         uint16_t qx_offset, qy_offset;
    1494                 :            :         uint16_t p_align, m_align;
    1495                 :            :         union cpt_inst_w4 w4;
    1496                 :            :         uint16_t dlen;
    1497                 :            :         uint8_t *dptr;
    1498                 :            : 
    1499                 :          0 :         prime_len = ec_grp->prime.length;
    1500                 :            :         if (prime_len > ROC_AE_EC_DATA_MAX)
    1501                 :            :                 prime_len = ROC_AE_EC_DATA_MAX;
    1502                 :          0 :         order_len = ec_grp->order.length;
    1503                 :            :         if (order_len > ROC_AE_EC_DATA_MAX)
    1504                 :            :                 order_len = ROC_AE_EC_DATA_MAX;
    1505                 :            : 
    1506                 :            :         if (qx_len > ROC_AE_EC_DATA_MAX)
    1507                 :            :                 qx_len = ROC_AE_EC_DATA_MAX;
    1508                 :            : 
    1509                 :            :         if (qy_len > ROC_AE_EC_DATA_MAX)
    1510                 :            :                 qy_len = ROC_AE_EC_DATA_MAX;
    1511                 :            : 
    1512                 :            :         /* Truncate input length to curve prime length */
    1513                 :          0 :         if (message_len > prime_len)
    1514                 :            :                 message_len = prime_len;
    1515                 :            : 
    1516                 :          0 :         m_align = RTE_ALIGN_CEIL(message_len, 8);
    1517                 :          0 :         p_align = RTE_ALIGN_CEIL(prime_len, 8);
    1518                 :            : 
    1519                 :            :         /* Set write offset for sign, order and public key coordinates */
    1520                 :          0 :         o_offset = prime_len - order_len;
    1521                 :          0 :         qx_offset = prime_len - qx_len;
    1522                 :          0 :         qy_offset = prime_len - qy_len;
    1523                 :          0 :         r_offset = prime_len - r_len;
    1524                 :          0 :         s_offset = prime_len - s_len;
    1525                 :            : 
    1526                 :            :         /* Input buffer */
    1527                 :            :         dptr = meta_buf->vaddr;
    1528                 :          0 :         inst->dptr = (uintptr_t)dptr;
    1529                 :            : 
    1530                 :            :         /*
    1531                 :            :          * Set dlen = sum(sizeof(fpm address), ROUNDUP8(message len),
    1532                 :            :          * ROUNDUP8(sign len(r and s), public key len(x and y coordinates),
    1533                 :            :          * prime len, order len)).
    1534                 :            :          * Please note sign, public key and order can not exceed prime length
    1535                 :            :          * i.e. 6 * p_align
    1536                 :            :          */
    1537                 :          0 :         dlen = sizeof(fpm_table_iova) + m_align + (8 * p_align);
    1538                 :            : 
    1539                 :          0 :         memset(dptr, 0, dlen);
    1540                 :            : 
    1541                 :          0 :         *(uint64_t *)dptr = fpm_table_iova;
    1542                 :          0 :         dptr += sizeof(fpm_table_iova);
    1543                 :            : 
    1544   [ #  #  #  # ]:          0 :         rte_memcpy(dptr + r_offset, sm2->r.data, r_len);
    1545                 :          0 :         dptr += p_align;
    1546                 :            : 
    1547   [ #  #  #  # ]:          0 :         rte_memcpy(dptr + s_offset, sm2->s.data, s_len);
    1548                 :          0 :         dptr += p_align;
    1549                 :            : 
    1550   [ #  #  #  # ]:          0 :         rte_memcpy(dptr, sm2->message.data, message_len);
    1551                 :          0 :         dptr += m_align;
    1552                 :            : 
    1553   [ #  #  #  # ]:          0 :         rte_memcpy(dptr + o_offset, ec_grp->order.data, order_len);
    1554                 :          0 :         dptr += p_align;
    1555                 :            : 
    1556   [ #  #  #  # ]:          0 :         rte_memcpy(dptr, ec_grp->prime.data, prime_len);
    1557                 :          0 :         dptr += p_align;
    1558                 :            : 
    1559   [ #  #  #  # ]:          0 :         rte_memcpy(dptr + qx_offset, sess->ec_ctx.q.x.data, qx_len);
    1560                 :          0 :         dptr += p_align;
    1561                 :            : 
    1562   [ #  #  #  # ]:          0 :         rte_memcpy(dptr + qy_offset, sess->ec_ctx.q.y.data, qy_len);
    1563                 :          0 :         dptr += p_align;
    1564                 :            : 
    1565   [ #  #  #  # ]:          0 :         rte_memcpy(dptr, ec_grp->consta.data, prime_len);
    1566                 :          0 :         dptr += p_align;
    1567                 :            : 
    1568   [ #  #  #  # ]:          0 :         rte_memcpy(dptr, ec_grp->constb.data, prime_len);
    1569                 :          0 :         dptr += p_align;
    1570                 :            : 
    1571                 :            :         /* Setup opcodes */
    1572                 :          0 :         w4.s.opcode_major = ROC_AE_MAJOR_OP_EC;
    1573                 :          0 :         w4.s.opcode_minor = ROC_AE_MINOR_OP_EC_VERIFY;
    1574                 :            : 
    1575                 :            :         /* prime length of SM2 curve is same as that of P256. */
    1576                 :          0 :         w4.s.param1 = ROC_AE_EC_ID_P256 |
    1577                 :          0 :                 ROC_AE_EC_PARAM1_SM2 | ROC_AE_EC_PARAM1_NONNIST | (message_len << 8);
    1578                 :          0 :         w4.s.param2 = 0;
    1579                 :          0 :         w4.s.dlen = dlen;
    1580                 :            : 
    1581                 :          0 :         inst->w4.u64 = w4.u64;
    1582                 :          0 :         inst->rptr = (uintptr_t)dptr;
    1583                 :          0 : }
    1584                 :            : 
    1585                 :            : static __rte_always_inline int __rte_hot
    1586                 :            : cnxk_ae_enqueue_sm2_op(struct rte_crypto_op *op,
    1587                 :            :                          struct roc_ae_buf_ptr *meta_buf,
    1588                 :            :                          struct cnxk_ae_sess *sess, uint64_t *fpm_iova,
    1589                 :            :                          struct roc_ae_ec_group **ec_grp,
    1590                 :            :                          struct cpt_inst_s *inst)
    1591                 :            : {
    1592                 :            :         struct rte_crypto_sm2_op_param *sm2 = &op->asym->sm2;
    1593                 :          0 :         uint8_t curveid = sess->ec_ctx.curveid;
    1594                 :            : 
    1595                 :          0 :         if (sm2->op_type == RTE_CRYPTO_ASYM_OP_SIGN)
    1596                 :          0 :                 cnxk_ae_sm2_sign_prep(sm2, meta_buf, fpm_iova[curveid],
    1597   [ #  #  #  # ]:          0 :                                         ec_grp[curveid], sess, inst);
    1598   [ #  #  #  # ]:          0 :         else if (sm2->op_type == RTE_CRYPTO_ASYM_OP_VERIFY)
    1599                 :          0 :                 cnxk_ae_sm2_verify_prep(sm2, meta_buf, fpm_iova[curveid],
    1600   [ #  #  #  # ]:          0 :                                           ec_grp[curveid], sess, inst);
    1601                 :            :         else {
    1602                 :          0 :                 op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
    1603                 :          0 :                 return -EINVAL;
    1604                 :            :         }
    1605                 :            :         return 0;
    1606                 :            : }
    1607                 :            : 
    1608                 :            : static __rte_always_inline int
    1609                 :            : cnxk_ae_ecfpm_prep(rte_crypto_param *scalar,
    1610                 :            :                    struct roc_ae_buf_ptr *meta_buf, uint64_t *fpm_iova,
    1611                 :            :                    struct roc_ae_ec_group *ec_grp, uint8_t curveid,
    1612                 :            :                    struct cpt_inst_s *inst)
    1613                 :            : {
    1614                 :            :         uint16_t scalar_align, p_align;
    1615                 :            :         uint16_t dlen, prime_len;
    1616                 :            :         uint64_t fpm_table_iova;
    1617                 :            :         union cpt_inst_w4 w4;
    1618                 :            :         uint8_t *dptr;
    1619                 :            : 
    1620                 :          0 :         prime_len = ec_grp->prime.length;
    1621                 :          0 :         fpm_table_iova = (uint64_t)fpm_iova[curveid];
    1622                 :            : 
    1623                 :            :         /* Input buffer */
    1624                 :            :         dptr = meta_buf->vaddr;
    1625                 :          0 :         inst->dptr = (uintptr_t)dptr;
    1626                 :            : 
    1627                 :          0 :         p_align = RTE_ALIGN_CEIL(prime_len, 8);
    1628                 :          0 :         scalar_align = RTE_ALIGN_CEIL(scalar->length, 8);
    1629                 :            : 
    1630                 :            :         /*
    1631                 :            :          * Set dlen = sum(ROUNDUP8(input point(x and y coordinates), prime,
    1632                 :            :          * scalar length),
    1633                 :            :          * Please note point length is equivalent to prime of the curve
    1634                 :            :          */
    1635                 :          0 :         dlen = sizeof(fpm_table_iova) + 3 * p_align + scalar_align;
    1636                 :            : 
    1637                 :          0 :         memset(dptr, 0, dlen);
    1638                 :            : 
    1639                 :          0 :         *(uint64_t *)dptr = fpm_table_iova;
    1640                 :          0 :         dptr += sizeof(fpm_table_iova);
    1641                 :            : 
    1642                 :            :         /* Copy scalar, prime */
    1643                 :          0 :         memcpy(dptr, scalar->data, scalar->length);
    1644                 :          0 :         dptr += scalar_align;
    1645                 :          0 :         memcpy(dptr, ec_grp->prime.data, ec_grp->prime.length);
    1646                 :          0 :         dptr += p_align;
    1647                 :          0 :         memcpy(dptr, ec_grp->consta.data, ec_grp->consta.length);
    1648                 :          0 :         dptr += p_align;
    1649                 :          0 :         memcpy(dptr, ec_grp->constb.data, ec_grp->constb.length);
    1650                 :          0 :         dptr += p_align;
    1651                 :            : 
    1652                 :            :         /* Setup opcodes */
    1653                 :          0 :         w4.s.opcode_major = ROC_AE_MAJOR_OP_ECC;
    1654                 :          0 :         w4.s.opcode_minor = ROC_AE_MINOR_OP_ECC_FPM;
    1655                 :            : 
    1656                 :          0 :         w4.s.param1 = curveid | (1 << 8);
    1657                 :          0 :         w4.s.param2 = scalar->length;
    1658                 :          0 :         w4.s.dlen = dlen;
    1659                 :            : 
    1660                 :          0 :         inst->w4.u64 = w4.u64;
    1661                 :          0 :         inst->rptr = (uintptr_t)dptr;
    1662                 :            : 
    1663                 :          0 :         return 0;
    1664                 :            : }
    1665                 :            : 
    1666                 :            : static __rte_always_inline int
    1667                 :            : cnxk_ae_edfpm_prep(rte_crypto_param *scalar, struct roc_ae_buf_ptr *meta_buf, uint64_t *fpm_iova,
    1668                 :            :                    struct roc_ae_ec_group *ec_grp, uint8_t curveid, struct cpt_inst_s *inst)
    1669                 :            : {
    1670                 :          0 :         const uint8_t iv_sha512[] = {
    1671                 :            :                 0x6a, 0x09, 0xe6, 0x67, 0xf3, 0xbc, 0xc9, 0x08,
    1672                 :            :                 0xbb, 0x67, 0xae, 0x85, 0x84, 0xca, 0xa7, 0x3b,
    1673                 :            :                 0x3c, 0x6e, 0xf3, 0x72, 0xfe, 0x94, 0xf8, 0x2b,
    1674                 :            :                 0xa5, 0x4f, 0xf5, 0x3a, 0x5f, 0x1d, 0x36, 0xf1,
    1675                 :            :                 0x51, 0x0e, 0x52, 0x7f, 0xad, 0xe6, 0x82, 0xd1,
    1676                 :            :                 0x9b, 0x05, 0x68, 0x8c, 0x2b, 0x3e, 0x6c, 0x1f,
    1677                 :            :                 0x1f, 0x83, 0xd9, 0xab, 0xfb, 0x41, 0xbd, 0x6b,
    1678                 :            :                 0x5b, 0xe0, 0xcd, 0x19, 0x13, 0x7e, 0x21, 0x79};
    1679                 :            :         uint16_t dlen, prime_len, order_len, iv_len;
    1680                 :            :         uint64_t fpm_table_iova;
    1681                 :            :         uint16_t scalar_align;
    1682                 :            :         union cpt_inst_w4 w4;
    1683                 :            :         uint16_t prime_bit;
    1684                 :            :         uint8_t *dptr;
    1685                 :            : 
    1686                 :          0 :         if (curveid == ROC_AE_EC_ID_ED25519) {
    1687                 :            :                 prime_bit = ROC_AE_ED_PARAM1_25519;
    1688                 :            :                 iv_len = sizeof(iv_sha512);
    1689                 :            :         } else {
    1690                 :            :                 prime_bit = ROC_AE_ED_PARAM1_448;
    1691                 :            :                 iv_len = 0;
    1692                 :            :         }
    1693                 :            : 
    1694                 :          0 :         prime_len = ec_grp->prime.length;
    1695                 :          0 :         order_len = ec_grp->order.length;
    1696                 :          0 :         fpm_table_iova = (uint64_t)fpm_iova[curveid];
    1697                 :            : 
    1698                 :            :         /* Input buffer */
    1699                 :            :         dptr = meta_buf->vaddr;
    1700                 :          0 :         inst->dptr = (uintptr_t)dptr;
    1701                 :            : 
    1702                 :          0 :         scalar_align = RTE_ALIGN_CEIL(scalar->length, 8);
    1703                 :            : 
    1704                 :            :         /*
    1705                 :            :          * Set dlen = sum(sizeof(fpm address), ROUNDUP8(prime len, order len, constant,
    1706                 :            :          * private key len and iv len (if ED25519))).
    1707                 :            :          */
    1708                 :          0 :         dlen = sizeof(fpm_table_iova) + 3 * prime_len + scalar_align + iv_len;
    1709                 :            : 
    1710                 :          0 :         *(uint64_t *)dptr = fpm_table_iova;
    1711                 :          0 :         dptr += sizeof(fpm_table_iova);
    1712                 :            : 
    1713   [ #  #  #  # ]:          0 :         memcpy(dptr, ec_grp->prime.data, prime_len);
    1714                 :          0 :         dptr += prime_len;
    1715                 :          0 :         memcpy(dptr, ec_grp->order.data, order_len);
    1716                 :          0 :         dptr += prime_len;
    1717                 :          0 :         memcpy(dptr, ec_grp->consta.data, prime_len);
    1718                 :          0 :         dptr += prime_len;
    1719                 :            : 
    1720                 :            :         memcpy(dptr, scalar->data, scalar->length);
    1721                 :          0 :         dptr += scalar_align;
    1722   [ #  #  #  # ]:          0 :         if (curveid == ROC_AE_EC_ID_ED25519) {
    1723                 :            :                 memcpy(dptr, iv_sha512, sizeof(iv_sha512));
    1724                 :          0 :                 dptr += iv_len;
    1725                 :            :         }
    1726                 :            : 
    1727                 :            :         /* Setup opcodes */
    1728                 :          0 :         w4.s.opcode_major = ROC_AE_MAJOR_OP_EDDSA;
    1729                 :          0 :         w4.s.opcode_minor = ROC_AE_MINOR_OP_ED_KEYGEN;
    1730                 :            : 
    1731                 :          0 :         w4.s.param1 = prime_bit;
    1732                 :          0 :         w4.s.param2 = 0;
    1733                 :          0 :         w4.s.dlen = dlen;
    1734                 :            : 
    1735                 :          0 :         inst->w4.u64 = w4.u64;
    1736                 :          0 :         inst->rptr = (uintptr_t)dptr;
    1737                 :            : 
    1738                 :          0 :         return 0;
    1739                 :            : }
    1740                 :            : 
    1741                 :            : static __rte_always_inline int
    1742                 :            : cnxk_ae_ecpm_prep(rte_crypto_param *scalar, struct rte_crypto_ec_point *p,
    1743                 :            :                   struct roc_ae_buf_ptr *meta_buf,
    1744                 :            :                   struct roc_ae_ec_group *ec_grp, uint8_t curveid,
    1745                 :            :                   struct cpt_inst_s *inst)
    1746                 :            : {
    1747                 :          0 :         uint16_t x1_len = p->x.length;
    1748                 :          0 :         uint16_t y1_len = p->y.length;
    1749                 :            :         uint16_t scalar_align, p_align;
    1750                 :            :         uint16_t x1_offset, y1_offset;
    1751                 :            :         uint16_t dlen, prime_len;
    1752                 :            :         union cpt_inst_w4 w4;
    1753                 :            :         uint8_t *dptr;
    1754                 :            : 
    1755                 :          0 :         prime_len = ec_grp->prime.length;
    1756                 :            : 
    1757                 :            :         /* Input buffer */
    1758                 :            :         dptr = meta_buf->vaddr;
    1759                 :          0 :         inst->dptr = (uintptr_t)dptr;
    1760                 :            : 
    1761                 :          0 :         p_align = RTE_ALIGN_CEIL(prime_len, 8);
    1762                 :          0 :         scalar_align = RTE_ALIGN_CEIL(scalar->length, 8);
    1763                 :            : 
    1764                 :            :         /*
    1765                 :            :          * Set dlen = sum(ROUNDUP8(input point(x and y coordinates), prime,
    1766                 :            :          * scalar length),
    1767                 :            :          * Please note point length is equivalent to prime of the curve
    1768                 :            :          */
    1769                 :          0 :         dlen = 5 * p_align + scalar_align;
    1770                 :            : 
    1771                 :          0 :         x1_offset = prime_len - x1_len;
    1772                 :          0 :         y1_offset = prime_len - y1_len;
    1773                 :            : 
    1774                 :          0 :         memset(dptr, 0, dlen);
    1775                 :            : 
    1776                 :            :         /* Copy input point, scalar, prime */
    1777                 :          0 :         memcpy(dptr + x1_offset, p->x.data, x1_len);
    1778                 :          0 :         dptr += p_align;
    1779                 :          0 :         memcpy(dptr + y1_offset, p->y.data, y1_len);
    1780                 :          0 :         dptr += p_align;
    1781                 :          0 :         memcpy(dptr, scalar->data, scalar->length);
    1782                 :          0 :         dptr += scalar_align;
    1783                 :          0 :         memcpy(dptr, ec_grp->prime.data, ec_grp->prime.length);
    1784                 :          0 :         dptr += p_align;
    1785                 :          0 :         memcpy(dptr, ec_grp->consta.data, ec_grp->consta.length);
    1786                 :          0 :         dptr += p_align;
    1787                 :          0 :         memcpy(dptr, ec_grp->constb.data, ec_grp->constb.length);
    1788                 :          0 :         dptr += p_align;
    1789                 :            : 
    1790                 :            :         /* Setup opcodes */
    1791                 :          0 :         w4.s.opcode_major = ROC_AE_MAJOR_OP_ECC;
    1792                 :          0 :         w4.s.opcode_minor = ROC_AE_MINOR_OP_ECC_UMP;
    1793                 :            : 
    1794                 :          0 :         w4.s.param1 = curveid;
    1795                 :          0 :         w4.s.param2 = scalar->length;
    1796                 :          0 :         w4.s.dlen = dlen;
    1797                 :            : 
    1798                 :          0 :         inst->w4.u64 = w4.u64;
    1799                 :          0 :         inst->rptr = (uintptr_t)dptr;
    1800                 :            : 
    1801                 :          0 :         return 0;
    1802                 :            : }
    1803                 :            : 
    1804                 :            : static __rte_always_inline int
    1805                 :            : cnxk_ae_random_prep(uint16_t len, struct roc_ae_buf_ptr *meta_buf,
    1806                 :            :                    struct cpt_inst_s *inst)
    1807                 :            : {
    1808                 :            :         union cpt_inst_w4 w4;
    1809                 :            :         uint8_t *dptr;
    1810                 :            : 
    1811                 :            :         /* Input buffer */
    1812                 :            :         dptr = meta_buf->vaddr;
    1813                 :          0 :         inst->dptr = (uintptr_t)dptr;
    1814                 :            : 
    1815                 :            :         /* Setup opcodes */
    1816                 :          0 :         w4.s.opcode_major = ROC_AE_MAJOR_OP_RANDOM;
    1817                 :          0 :         w4.s.opcode_minor = ROC_AE_MINOR_OP_RANDOM;
    1818                 :            : 
    1819                 :          0 :         w4.s.param1 = len;
    1820                 :          0 :         w4.s.param2 = 0;
    1821                 :          0 :         w4.s.dlen = 0;
    1822                 :            : 
    1823                 :          0 :         inst->w4.u64 = w4.u64;
    1824                 :          0 :         inst->rptr = (uintptr_t)dptr;
    1825                 :            : 
    1826                 :          0 :         return 0;
    1827                 :            : }
    1828                 :            : 
    1829                 :            : static __rte_always_inline int __rte_hot
    1830                 :            : cnxk_ae_enqueue_ecdh_op(struct rte_crypto_op *op,
    1831                 :            :                          struct roc_ae_buf_ptr *meta_buf,
    1832                 :            :                          struct cnxk_ae_sess *sess, uint64_t *fpm_iova,
    1833                 :            :                          struct roc_ae_ec_group **ec_grp,
    1834                 :            :                          struct cpt_inst_s *inst)
    1835                 :            : {
    1836                 :            :         struct rte_crypto_ecdh_op_param *ecdh = &op->asym->ecdh;
    1837                 :          0 :         uint8_t curveid = sess->ec_ctx.curveid;
    1838                 :            :         struct rte_crypto_ec_point point;
    1839                 :            :         rte_crypto_uint scalar;
    1840                 :            :         int ret = 0;
    1841                 :            : 
    1842                 :          0 :         switch (ecdh->ke_type) {
    1843                 :          0 :         case RTE_CRYPTO_ASYM_KE_PRIV_KEY_GENERATE:
    1844                 :          0 :                 cnxk_ae_random_prep(ecdh->priv_key.length, meta_buf, inst);
    1845                 :            :                 break;
    1846                 :          0 :         case RTE_CRYPTO_ASYM_KE_PUB_KEY_GENERATE:
    1847                 :          0 :                 scalar.data = sess->ec_ctx.pkey.data;
    1848                 :          0 :                 scalar.length = sess->ec_ctx.pkey.length;
    1849   [ #  #  #  # ]:          0 :                 if (curveid == ROC_AE_EC_ID_ED25519 || curveid == ROC_AE_EC_ID_ED448)
    1850   [ #  #  #  # ]:          0 :                         cnxk_ae_edfpm_prep(&scalar, meta_buf, fpm_iova, ec_grp[curveid],
    1851                 :            :                                 curveid, inst);
    1852                 :            :                 else
    1853                 :          0 :                         cnxk_ae_ecfpm_prep(&scalar, meta_buf, fpm_iova, ec_grp[curveid],
    1854                 :            :                                 curveid, inst);
    1855                 :            :                 break;
    1856                 :          0 :         case RTE_CRYPTO_ASYM_KE_PUB_KEY_VERIFY:
    1857                 :          0 :                 scalar.data = ec_grp[curveid]->order.data;
    1858                 :          0 :                 scalar.length = ec_grp[curveid]->order.length;
    1859                 :            :                 cnxk_ae_ecpm_prep(&scalar, &ecdh->pub_key, meta_buf,
    1860                 :            :                         ec_grp[curveid], curveid, inst);
    1861                 :            :                 break;
    1862                 :          0 :         case RTE_CRYPTO_ASYM_KE_SHARED_SECRET_COMPUTE:
    1863                 :          0 :                 scalar.data = sess->ec_ctx.pkey.data;
    1864                 :          0 :                 scalar.length = sess->ec_ctx.pkey.length;
    1865                 :          0 :                 point.x.data = sess->ec_ctx.q.x.data;
    1866                 :          0 :                 point.x.length = sess->ec_ctx.q.x.length;
    1867                 :          0 :                 point.y.data = sess->ec_ctx.q.y.data;
    1868                 :          0 :                 point.y.length = sess->ec_ctx.q.y.length;
    1869                 :          0 :                 cnxk_ae_ecpm_prep(&scalar, &point, meta_buf,
    1870                 :          0 :                         ec_grp[curveid], curveid, inst);
    1871                 :            :                 break;
    1872                 :          0 :         default:
    1873                 :          0 :                 op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
    1874                 :            :                 ret = -EINVAL;
    1875                 :            :         }
    1876                 :            : 
    1877                 :            :         return ret;
    1878                 :            : }
    1879                 :            : 
    1880                 :            : static __rte_always_inline void
    1881                 :            : cnxk_ae_dequeue_rsa_op(struct rte_crypto_op *cop, uint8_t *rptr,
    1882                 :            :                        struct rte_crypto_rsa_xform *rsa_ctx)
    1883                 :            : {
    1884                 :            :         struct rte_crypto_rsa_op_param *rsa = &cop->asym->rsa;
    1885                 :            : 
    1886                 :          0 :         switch (rsa->op_type) {
    1887                 :          0 :         case RTE_CRYPTO_ASYM_OP_ENCRYPT:
    1888                 :          0 :                 rsa->cipher.length = rsa_ctx->n.length;
    1889                 :          0 :                 memcpy(rsa->cipher.data, rptr, rsa->cipher.length);
    1890                 :            :                 break;
    1891                 :          0 :         case RTE_CRYPTO_ASYM_OP_DECRYPT:
    1892         [ #  # ]:          0 :                 if (rsa_ctx->padding.type == RTE_CRYPTO_RSA_PADDING_NONE) {
    1893                 :          0 :                         rsa->message.length = rsa_ctx->n.length;
    1894                 :          0 :                         memcpy(rsa->message.data, rptr, rsa->message.length);
    1895                 :            :                 } else {
    1896                 :            :                         /* Get length of decrypted output */
    1897                 :          0 :                         rsa->message.length =
    1898         [ #  # ]:          0 :                                 rte_cpu_to_be_16(*((uint16_t *)rptr));
    1899                 :            :                         /*
    1900                 :            :                          * Offset output data pointer by length field
    1901                 :            :                          * (2 bytes) and copy decrypted data.
    1902                 :            :                          */
    1903                 :          0 :                         memcpy(rsa->message.data, rptr + 2,
    1904                 :            :                                rsa->message.length);
    1905                 :            :                 }
    1906                 :            :                 break;
    1907                 :          0 :         case RTE_CRYPTO_ASYM_OP_SIGN:
    1908                 :          0 :                 rsa->sign.length = rsa_ctx->n.length;
    1909                 :          0 :                 memcpy(rsa->sign.data, rptr, rsa->sign.length);
    1910                 :            :                 break;
    1911                 :          0 :         case RTE_CRYPTO_ASYM_OP_VERIFY:
    1912         [ #  # ]:          0 :                 if (rsa_ctx->padding.type == RTE_CRYPTO_RSA_PADDING_NONE) {
    1913                 :            :                         /* Application compares decrypted data with message for SW padding schemes
    1914                 :            :                          */
    1915                 :          0 :                         rsa->cipher.length = rsa_ctx->n.length;
    1916                 :          0 :                         memcpy(rsa->cipher.data, rptr, rsa->cipher.length);
    1917                 :            :                 } else {
    1918                 :            :                         /* Get length of signed output */
    1919         [ #  # ]:          0 :                         rsa->sign.length = rte_cpu_to_be_16(*((uint16_t *)rptr));
    1920                 :            :                         /*
    1921                 :            :                          * Offset output data pointer by length field
    1922                 :            :                          * (2 bytes) and compare signed data.
    1923                 :            :                          */
    1924         [ #  # ]:          0 :                         if (memcmp(rptr + 2, rsa->message.data, rsa->message.length))
    1925                 :          0 :                                 cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
    1926                 :            :                 }
    1927                 :            :                 break;
    1928                 :          0 :         default:
    1929                 :          0 :                 cop->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
    1930                 :          0 :                 break;
    1931                 :            :         }
    1932                 :            : }
    1933                 :            : 
    1934                 :            : static __rte_always_inline void
    1935                 :            : cnxk_ae_dequeue_ecdsa_op(struct rte_crypto_ecdsa_op_param *ecdsa, uint8_t *rptr,
    1936                 :            :                          struct roc_ae_ec_ctx *ec,
    1937                 :            :                          struct roc_ae_ec_group **ec_grp)
    1938                 :            : {
    1939                 :          0 :         int prime_len = ec_grp[ec->curveid]->prime.length;
    1940                 :            : 
    1941                 :          0 :         if (ecdsa->op_type == RTE_CRYPTO_ASYM_OP_VERIFY)
    1942                 :            :                 return;
    1943                 :            : 
    1944                 :            :         /* Separate out sign r and s components */
    1945                 :          0 :         memcpy(ecdsa->r.data, rptr, prime_len);
    1946                 :          0 :         memcpy(ecdsa->s.data, rptr + RTE_ALIGN_CEIL(prime_len, 8), prime_len);
    1947                 :          0 :         ecdsa->r.length = prime_len;
    1948                 :          0 :         ecdsa->s.length = prime_len;
    1949                 :            : }
    1950                 :            : 
    1951                 :            : static __rte_always_inline void
    1952                 :            : cnxk_ae_dequeue_eddsa_op(struct rte_crypto_eddsa_op_param *eddsa, uint8_t *rptr)
    1953                 :            : {
    1954                 :          0 :         if (eddsa->op_type == RTE_CRYPTO_ASYM_OP_VERIFY)
    1955                 :            :                 return;
    1956                 :            : 
    1957                 :            :         /* Separate out sign r and s components */
    1958         [ #  # ]:          0 :         if (eddsa->instance == RTE_CRYPTO_EDCURVE_25519 ||
    1959                 :            :                 eddsa->instance == RTE_CRYPTO_EDCURVE_25519CTX ||
    1960                 :            :                 eddsa->instance == RTE_CRYPTO_EDCURVE_25519PH) {
    1961                 :          0 :                 eddsa->sign.length = 64;
    1962                 :          0 :                 memcpy(eddsa->sign.data, rptr, eddsa->sign.length);
    1963                 :            :         } else {
    1964                 :          0 :                 eddsa->sign.length = 114;
    1965                 :          0 :                 memcpy(eddsa->sign.data, rptr, 57);
    1966                 :          0 :                 memcpy(eddsa->sign.data + 57, rptr + 64, 57);
    1967                 :            :         }
    1968                 :            : }
    1969                 :            : 
    1970                 :            : static __rte_always_inline void
    1971                 :            : cnxk_ae_dequeue_sm2_op(struct rte_crypto_sm2_op_param *sm2, uint8_t *rptr,
    1972                 :            :                          struct roc_ae_ec_ctx *ec,
    1973                 :            :                          struct roc_ae_ec_group **ec_grp)
    1974                 :            : {
    1975                 :          0 :         int prime_len = ec_grp[ec->curveid]->prime.length;
    1976                 :            : 
    1977                 :          0 :         if (sm2->op_type == RTE_CRYPTO_ASYM_OP_VERIFY)
    1978                 :            :                 return;
    1979                 :            : 
    1980                 :            :         /* Separate out sign r and s components */
    1981         [ #  # ]:          0 :         rte_memcpy(sm2->r.data, rptr, prime_len);
    1982         [ #  # ]:          0 :         rte_memcpy(sm2->s.data, rptr + RTE_ALIGN_CEIL(prime_len, 8), prime_len);
    1983                 :          0 :         sm2->r.length = prime_len;
    1984                 :          0 :         sm2->s.length = prime_len;
    1985                 :            : }
    1986                 :            : 
    1987                 :            : static __rte_always_inline void
    1988                 :            : cnxk_ae_dequeue_ecpm_op(struct rte_crypto_ecpm_op_param *ecpm, uint8_t *rptr,
    1989                 :            :                         struct roc_ae_ec_ctx *ec,
    1990                 :            :                         struct roc_ae_ec_group **ec_grp)
    1991                 :            : {
    1992                 :          0 :         int prime_len = ec_grp[ec->curveid]->prime.length;
    1993                 :            : 
    1994                 :          0 :         memcpy(ecpm->r.x.data, rptr, prime_len);
    1995                 :          0 :         memcpy(ecpm->r.y.data, rptr + RTE_ALIGN_CEIL(prime_len, 8), prime_len);
    1996                 :          0 :         ecpm->r.x.length = prime_len;
    1997                 :          0 :         ecpm->r.y.length = prime_len;
    1998                 :          0 : }
    1999                 :            : 
    2000                 :            : static __rte_always_inline void
    2001                 :            : cnxk_ae_dequeue_ecdh_op(struct rte_crypto_ecdh_op_param *ecdh, uint8_t *rptr,
    2002                 :            :                         struct roc_ae_ec_ctx *ec,
    2003                 :            :                         struct roc_ae_ec_group **ec_grp, uint16_t flags)
    2004                 :            : {
    2005                 :          0 :         int prime_len = ec_grp[ec->curveid]->prime.length;
    2006                 :            : 
    2007                 :          0 :         switch (ecdh->ke_type) {
    2008                 :          0 :         case RTE_CRYPTO_ASYM_KE_PRIV_KEY_GENERATE:
    2009                 :          0 :                 memcpy(ecdh->priv_key.data, rptr, prime_len);
    2010                 :          0 :                 ecdh->priv_key.length = prime_len;
    2011                 :          0 :                 break;
    2012                 :          0 :         case RTE_CRYPTO_ASYM_KE_PUB_KEY_GENERATE:
    2013         [ #  # ]:          0 :                 memcpy(ecdh->pub_key.x.data, rptr, prime_len);
    2014                 :          0 :                 ecdh->pub_key.x.length = prime_len;
    2015         [ #  # ]:          0 :                 if (!(flags & RTE_CRYPTO_ASYM_FLAG_PUB_KEY_COMPRESSED)) {
    2016                 :          0 :                         memcpy(ecdh->pub_key.y.data, rptr + RTE_ALIGN_CEIL(prime_len, 8),
    2017                 :            :                                 prime_len);
    2018                 :          0 :                         ecdh->pub_key.y.length = prime_len;
    2019                 :            :                 }
    2020                 :            :                 break;
    2021                 :            :         case RTE_CRYPTO_ASYM_KE_PUB_KEY_VERIFY:
    2022                 :            :                 break;
    2023                 :          0 :         case RTE_CRYPTO_ASYM_KE_SHARED_SECRET_COMPUTE:
    2024                 :          0 :                 memcpy(ecdh->shared_secret.x.data, rptr, prime_len);
    2025                 :          0 :                 memcpy(ecdh->shared_secret.y.data, rptr + RTE_ALIGN_CEIL(prime_len, 8), prime_len);
    2026                 :          0 :                 ecdh->shared_secret.x.length = prime_len;
    2027                 :          0 :                 ecdh->shared_secret.y.length = prime_len;
    2028                 :          0 :                 break;
    2029                 :            :         default:
    2030                 :            :                 break;
    2031                 :            :         }
    2032                 :            : }
    2033                 :            : 
    2034                 :            : static __rte_always_inline void
    2035                 :            : cnxk_ae_dequeue_mlkem_op(struct rte_crypto_ml_kem_op *mlkem, uint8_t *rptr,
    2036                 :            :         enum rte_crypto_ml_kem_type type)
    2037                 :            : {
    2038                 :          0 :         switch (mlkem->op) {
    2039                 :          0 :         case RTE_CRYPTO_ML_KEM_OP_KEYGEN:
    2040                 :          0 :                 mlkem->keygen.dk.length = rte_crypto_ml_kem_privkey_size[type];
    2041                 :          0 :                 memcpy(mlkem->keygen.dk.data, rptr, mlkem->keygen.dk.length);
    2042                 :          0 :                 mlkem->keygen.ek.length = rte_crypto_ml_kem_pubkey_size[type];
    2043                 :          0 :                 memcpy(mlkem->keygen.ek.data, rptr + 384 * (type + 1), mlkem->keygen.ek.length);
    2044                 :            :                 break;
    2045                 :          0 :         case RTE_CRYPTO_ML_KEM_OP_ENCAP:
    2046                 :          0 :                 mlkem->encap.sk.length = 32;
    2047                 :          0 :                 memcpy(mlkem->encap.sk.data, rptr, mlkem->encap.sk.length);
    2048                 :          0 :                 mlkem->encap.cipher.length = rte_crypto_ml_kem_cipher_size[type];
    2049                 :          0 :                 memcpy(mlkem->encap.cipher.data, rptr + 32, mlkem->encap.cipher.length);
    2050                 :            :                 break;
    2051                 :          0 :         case RTE_CRYPTO_ML_KEM_OP_DECAP:
    2052                 :          0 :                 mlkem->decap.sk.length = 32;
    2053                 :          0 :                 memcpy(mlkem->decap.sk.data, rptr, mlkem->decap.sk.length);
    2054                 :            :                 break;
    2055                 :            :         default:
    2056                 :            :                 break;
    2057                 :            :         }
    2058                 :            : }
    2059                 :            : 
    2060                 :            : static __rte_always_inline void
    2061                 :            : cnxk_ae_dequeue_mldsa_op(struct rte_crypto_ml_dsa_op *mldsa, uint8_t *rptr,
    2062                 :            :         enum rte_crypto_ml_dsa_type type)
    2063                 :            : {
    2064                 :          0 :         switch (mldsa->op) {
    2065                 :          0 :         case RTE_CRYPTO_ML_DSA_OP_KEYGEN:
    2066                 :          0 :                 mldsa->keygen.pubkey.length = rte_crypto_ml_dsa_pubkey_size[type];
    2067                 :          0 :                 memcpy(mldsa->keygen.pubkey.data, rptr, mldsa->keygen.pubkey.length);
    2068                 :          0 :                 mldsa->keygen.privkey.length = rte_crypto_ml_dsa_privkey_size[type];
    2069                 :          0 :                 memcpy(mldsa->keygen.privkey.data, rptr + mldsa->keygen.pubkey.length,
    2070                 :            :                        mldsa->keygen.privkey.length);
    2071                 :            :                 break;
    2072                 :          0 :         case RTE_CRYPTO_ML_DSA_OP_SIGN:
    2073                 :          0 :                 mldsa->siggen.sign.length = rte_crypto_ml_dsa_sign_size[type];
    2074                 :          0 :                 memcpy(mldsa->siggen.sign.data, rptr, mldsa->siggen.sign.length);
    2075                 :            :                 break;
    2076                 :            :         case RTE_CRYPTO_ML_DSA_OP_VERIFY:
    2077                 :            :                 break;
    2078                 :            :         default:
    2079                 :            :                 break;
    2080                 :            :         }
    2081                 :            : }
    2082                 :            : 
    2083                 :            : static __rte_always_inline void *
    2084                 :            : cnxk_ae_alloc_meta(struct roc_ae_buf_ptr *buf,
    2085                 :            :                    struct rte_mempool *cpt_meta_pool,
    2086                 :            :                    struct cpt_inflight_req *infl_req)
    2087                 :            : {
    2088                 :            :         uint8_t *mdata;
    2089                 :            : 
    2090   [ #  #  #  # ]:          0 :         if (unlikely(rte_mempool_get(cpt_meta_pool, (void **)&mdata) < 0))
    2091                 :            :                 return NULL;
    2092                 :            : 
    2093                 :          0 :         buf->vaddr = mdata;
    2094                 :            : 
    2095                 :          0 :         infl_req->mdata = mdata;
    2096                 :          0 :         infl_req->op_flags |= CPT_OP_FLAGS_METABUF;
    2097                 :            : 
    2098                 :            :         return mdata;
    2099                 :            : }
    2100                 :            : 
    2101                 :            : static __rte_always_inline int32_t __rte_hot
    2102                 :            : cnxk_ae_enqueue(struct cnxk_cpt_qp *qp, struct rte_crypto_op *op,
    2103                 :            :                 struct cpt_inflight_req *infl_req, struct cpt_inst_s *inst,
    2104                 :            :                 struct cnxk_ae_sess *sess)
    2105                 :            : {
    2106                 :            :         struct cpt_qp_meta_info *minfo = &qp->meta_info;
    2107                 :            :         struct rte_crypto_asym_op *asym_op = op->asym;
    2108                 :            :         struct roc_ae_buf_ptr meta_buf;
    2109                 :            :         uint64_t *mop;
    2110                 :            :         void *mdata;
    2111                 :            :         int ret;
    2112                 :            : 
    2113   [ #  #  #  # ]:          0 :         mdata = cnxk_ae_alloc_meta(&meta_buf, minfo->pool, infl_req);
    2114   [ #  #  #  # ]:          0 :         if (mdata == NULL)
    2115                 :            :                 return -ENOMEM;
    2116                 :            : 
    2117                 :            :         /* Reserve 8B for RPTR */
    2118                 :          0 :         meta_buf.vaddr = PLT_PTR_ADD(mdata, sizeof(uint64_t));
    2119                 :            : 
    2120   [ #  #  #  #  :          0 :         switch (sess->xfrm_type) {
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
                #  #  # ]
    2121   [ #  #  #  # ]:          0 :         case RTE_CRYPTO_ASYM_XFORM_MODEX:
    2122                 :            :                 ret = cnxk_ae_modex_prep(op, &meta_buf, &sess->mod_ctx, inst);
    2123                 :          0 :                 break;
    2124                 :            :         case RTE_CRYPTO_ASYM_XFORM_RSA:
    2125                 :            :                 ret = cnxk_ae_enqueue_rsa_op(op, &meta_buf, sess, inst);
    2126                 :            :                 break;
    2127                 :          0 :         case RTE_CRYPTO_ASYM_XFORM_ECDSA:
    2128   [ #  #  #  # ]:          0 :                 ret = cnxk_ae_enqueue_ecdsa_op(op, &meta_buf, sess,
    2129                 :            :                                                sess->cnxk_fpm_iova,
    2130                 :            :                                                sess->ec_grp, inst);
    2131                 :            :                 break;
    2132                 :          0 :         case RTE_CRYPTO_ASYM_XFORM_EDDSA:
    2133   [ #  #  #  # ]:          0 :                 ret = cnxk_ae_enqueue_eddsa_op(op, &meta_buf, sess,
    2134                 :            :                                                sess->cnxk_fpm_iova,
    2135                 :            :                                                sess->ec_grp, inst);
    2136                 :            :                 break;
    2137                 :          0 :         case RTE_CRYPTO_ASYM_XFORM_SM2:
    2138   [ #  #  #  # ]:          0 :                 ret = cnxk_ae_enqueue_sm2_op(op, &meta_buf, sess,
    2139                 :            :                                                sess->cnxk_fpm_iova,
    2140                 :            :                                                sess->ec_grp, inst);
    2141                 :            :                 break;
    2142                 :          0 :         case RTE_CRYPTO_ASYM_XFORM_ECPM:
    2143                 :          0 :                 ret = cnxk_ae_ecpm_prep(&asym_op->ecpm.scalar, &asym_op->ecpm.p, &meta_buf,
    2144                 :          0 :                                         sess->ec_grp[sess->ec_ctx.curveid],
    2145                 :          0 :                                         sess->ec_ctx.curveid, inst);
    2146                 :          0 :                 break;
    2147                 :          0 :         case RTE_CRYPTO_ASYM_XFORM_ECFPM:
    2148                 :          0 :                 ret = cnxk_ae_ecfpm_prep(&asym_op->ecpm.scalar, &meta_buf,
    2149                 :            :                                          sess->cnxk_fpm_iova,
    2150                 :          0 :                                          sess->ec_grp[sess->ec_ctx.curveid],
    2151                 :          0 :                                          sess->ec_ctx.curveid, inst);
    2152                 :          0 :                 break;
    2153                 :          0 :         case RTE_CRYPTO_ASYM_XFORM_ECDH:
    2154   [ #  #  #  #  :          0 :                 ret = cnxk_ae_enqueue_ecdh_op(op, &meta_buf, sess,
          #  #  #  #  #  
                      # ]
    2155                 :            :                                                sess->cnxk_fpm_iova,
    2156                 :            :                                                sess->ec_grp, inst);
    2157                 :            :                 break;
    2158                 :            :         case RTE_CRYPTO_ASYM_XFORM_ML_KEM:
    2159                 :            :                 ret = cnxk_ae_enqueue_ml_kem_op(op, &meta_buf, sess, inst);
    2160                 :          0 :                 break;
    2161                 :            :         case RTE_CRYPTO_ASYM_XFORM_ML_DSA:
    2162                 :            :                 ret = cnxk_ae_enqueue_ml_dsa_op(op, &meta_buf, sess, inst);
    2163                 :          0 :                 break;
    2164                 :          0 :         default:
    2165                 :          0 :                 op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
    2166                 :            :                 ret = -EINVAL;
    2167                 :          0 :                 goto req_fail;
    2168                 :            :         }
    2169                 :            : 
    2170   [ #  #  #  # ]:          0 :         if (unlikely(ret))
    2171                 :          0 :                 goto req_fail;
    2172                 :            : 
    2173                 :            :         mop = mdata;
    2174                 :          0 :         mop[0] = inst->rptr;
    2175                 :          0 :         return 0;
    2176                 :            : 
    2177                 :          0 : req_fail:
    2178   [ #  #  #  # ]:          0 :         rte_mempool_put(minfo->pool, infl_req->mdata);
    2179                 :          0 :         return ret;
    2180                 :            : }
    2181                 :            : 
    2182                 :            : static __rte_always_inline void
    2183                 :            : cnxk_ae_post_process(struct rte_crypto_op *cop, struct cnxk_ae_sess *sess,
    2184                 :            :                      uint8_t *rptr)
    2185                 :            : {
    2186                 :            :         struct rte_crypto_asym_op *op = cop->asym;
    2187                 :            : 
    2188   [ #  #  #  #  :          0 :         switch (sess->xfrm_type) {
          #  #  #  #  #  
                      # ]
    2189   [ #  #  #  #  :          0 :         case RTE_CRYPTO_ASYM_XFORM_RSA:
                      # ]
    2190                 :            :                 cnxk_ae_dequeue_rsa_op(cop, rptr, &sess->rsa_ctx);
    2191                 :            :                 break;
    2192                 :          0 :         case RTE_CRYPTO_ASYM_XFORM_MODEX:
    2193                 :          0 :                 op->modex.result.length = sess->mod_ctx.modulus.length;
    2194                 :          0 :                 memcpy(op->modex.result.data, rptr, op->modex.result.length);
    2195                 :            :                 break;
    2196                 :          0 :         case RTE_CRYPTO_ASYM_XFORM_ECDSA:
    2197         [ #  # ]:          0 :                 cnxk_ae_dequeue_ecdsa_op(&op->ecdsa, rptr, &sess->ec_ctx,
    2198                 :            :                                          sess->ec_grp);
    2199                 :            :                 break;
    2200         [ #  # ]:          0 :         case RTE_CRYPTO_ASYM_XFORM_EDDSA:
    2201                 :            :                 cnxk_ae_dequeue_eddsa_op(&op->eddsa, rptr);
    2202                 :            :                 break;
    2203                 :          0 :         case RTE_CRYPTO_ASYM_XFORM_SM2:
    2204         [ #  # ]:          0 :                 cnxk_ae_dequeue_sm2_op(&op->sm2, rptr, &sess->ec_ctx,
    2205                 :            :                                          sess->ec_grp);
    2206                 :            :                 break;
    2207                 :          0 :         case RTE_CRYPTO_ASYM_XFORM_ECPM:
    2208                 :            :         case RTE_CRYPTO_ASYM_XFORM_ECFPM:
    2209                 :          0 :                 cnxk_ae_dequeue_ecpm_op(&op->ecpm, rptr, &sess->ec_ctx,
    2210                 :            :                                         sess->ec_grp);
    2211                 :            :                 break;
    2212                 :          0 :         case RTE_CRYPTO_ASYM_XFORM_ECDH:
    2213                 :          0 :                 cnxk_ae_dequeue_ecdh_op(&op->ecdh, rptr, &sess->ec_ctx,
    2214   [ #  #  #  # ]:          0 :                                         sess->ec_grp, op->flags);
    2215                 :            :                 break;
    2216                 :          0 :         case RTE_CRYPTO_ASYM_XFORM_ML_KEM:
    2217   [ #  #  #  # ]:          0 :                 cnxk_ae_dequeue_mlkem_op(&op->mlkem, rptr, sess->ml_kem_ctx.type);
    2218                 :            :                 break;
    2219                 :          0 :         case RTE_CRYPTO_ASYM_XFORM_ML_DSA:
    2220      [ #  #  # ]:          0 :                 cnxk_ae_dequeue_mldsa_op(&op->mldsa, rptr, sess->ml_dsa_ctx.type);
    2221                 :            :                 break;
    2222                 :          0 :         default:
    2223                 :          0 :                 cop->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
    2224                 :          0 :                 break;
    2225                 :            :         }
    2226                 :            : }
    2227                 :            : #endif /* _CNXK_AE_H_ */

Generated by: LCOV version 1.14