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

Generated by: LCOV version 1.14