common/cnxk: add EC vectors for asymmetric crypto

EC group static vectors are required for CPT asymmetric
crypto operations.

Signed-off-by: Anoob Joseph <anoobj@marvell.com>
Signed-off-by: Kiran Kumar K <kirankumark@marvell.com>
Acked-by: Akhil Goyal <gakhil@marvell.com>
This commit is contained in:
Kiran Kumar K 2021-06-25 11:06:47 +05:30 committed by Akhil Goyal
parent 9514771ed9
commit 80ab347db4
4 changed files with 152 additions and 0 deletions

View File

@ -11,6 +11,7 @@ endif
config_flag_fmt = 'RTE_LIBRTE_@0@_COMMON'
deps = ['eal', 'pci', 'bus_pci', 'mbuf']
sources = files(
'roc_ae.c',
'roc_ae_fpm_tables.c',
'roc_bphy.c',
'roc_bphy_cgx.c',

View File

@ -0,0 +1,142 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright(C) 2021 Marvell.
*/
#include "roc_api.h"
#define AE_EC_GRP_TBL_NAME "ae_ec_grp_tbl"
struct ae_ec_grp_tbl {
uint64_t refcount;
uint8_t ec_grp_tbl[];
};
const struct roc_ae_ec_group ae_ec_grp[ROC_AE_EC_ID_PMAX] = {
{
.prime = {.data = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
.length = 24},
.order = {.data = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0x99, 0xDE, 0xF8, 0x36, 0x14, 0x6B,
0xC9, 0xB1, 0xB4, 0xD2, 0x28, 0x31},
.length = 24},
},
{
.prime = {.data = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01},
.length = 28},
.order = {.data = {0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF,
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF,
0X16, 0XA2, 0XE0, 0XB8, 0XF0, 0X3E, 0X13,
0XDD, 0X29, 0X45, 0X5C, 0X5C, 0X2A, 0X3D},
.length = 28},
},
{
.prime = {.data = {0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF},
.length = 32},
.order = {.data = {0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00,
0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xBC, 0xE6, 0xFA, 0xAD, 0xA7,
0x17, 0x9E, 0x84, 0xF3, 0xB9, 0xCA, 0xC2,
0xFC, 0x63, 0x25, 0x51},
.length = 32},
},
{.prime = {.data = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE,
0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF},
.length = 48},
.order = {.data = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0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= AE_EC_GRP_TBL_NAME;
struct ae_ec_grp_tbl *ec_grp;
const struct plt_memzone *mz;
int i, len = 0;
uint8_t *data;
if (tbl == NULL)
return -EINVAL;
len = sizeof(ae_ec_grp);
mz = plt_memzone_lookup(name);
if (mz == NULL) {
/* Create memzone first time */
mz = plt_memzone_reserve_cache_align(
name, len + sizeof(struct ae_ec_grp_tbl));
if (mz == NULL)
return -ENOMEM;
}
ec_grp = mz->addr;
if (__atomic_fetch_add(&ec_grp->refcount, 1, __ATOMIC_SEQ_CST) != 0)
return 0;
data = PLT_PTR_ADD(mz->addr, sizeof(uint64_t));
for (i = 0; i < ROC_AE_EC_ID_PMAX; i++) {
memcpy(data, &ae_ec_grp[i], sizeof(struct roc_ae_ec_group));
tbl[i] = (struct roc_ae_ec_group *)data;
data += sizeof(struct roc_ae_ec_group);
}
return 0;
}
void
roc_ae_ec_grp_put(void)
{
const char name[] = AE_EC_GRP_TBL_NAME;
const struct plt_memzone *mz;
struct ae_ec_grp_tbl *ec_grp;
mz = plt_memzone_lookup(name);
if (mz == NULL)
return;
ec_grp = mz->addr;
/* Decrement number of devices using EC grp table */
if (__atomic_sub_fetch(&ec_grp->refcount, 1, __ATOMIC_SEQ_CST) == 0)
plt_memzone_free(mz);
}

View File

@ -53,4 +53,11 @@ struct roc_ae_ec_ctx {
uint8_t curveid;
};
/* Buffer pointer */
struct roc_ae_buf_ptr {
void *vaddr;
};
int __roc_api roc_ae_ec_grp_get(struct roc_ae_ec_group **tbl);
void __roc_api roc_ae_ec_grp_put(void);
#endif /* __ROC_AE_H__ */

View File

@ -10,6 +10,8 @@ INTERNAL {
cnxk_logtype_sso;
cnxk_logtype_tim;
cnxk_logtype_tm;
roc_ae_ec_grp_get;
roc_ae_ec_grp_put;
roc_ae_fpm_get;
roc_ae_fpm_put;
roc_bphy_cgx_dev_fini;