Path: blob/master/drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.h
26292 views
/* SPDX-License-Identifier: GPL-2.0-only1* Copyright (C) 2020 Marvell.2*/34#ifndef __OTX2_CPTPF_UCODE_H5#define __OTX2_CPTPF_UCODE_H67#include <linux/pci.h>8#include <linux/types.h>9#include <linux/module.h>10#include "otx2_cpt_hw_types.h"11#include "otx2_cpt_common.h"1213/*14* On OcteonTX2 platform IPSec ucode can use both IE and SE engines therefore15* IE and SE engines can be attached to the same engine group.16*/17#define OTX2_CPT_MAX_ETYPES_PER_GRP 21819/* CPT ucode signature size */20#define OTX2_CPT_UCODE_SIGN_LEN 2562122/* Microcode version string length */23#define OTX2_CPT_UCODE_VER_STR_SZ 442425/* Maximum number of supported engines/cores on OcteonTX2/CN10K platform */26#define OTX2_CPT_MAX_ENGINES 1442728#define OTX2_CPT_ENGS_BITMASK_LEN BITS_TO_LONGS(OTX2_CPT_MAX_ENGINES)2930#define OTX2_CPT_UCODE_SZ (64 * 1024)3132/* Microcode types */33enum otx2_cpt_ucode_type {34OTX2_CPT_AE_UC_TYPE = 1, /* AE-MAIN */35OTX2_CPT_SE_UC_TYPE1 = 20,/* SE-MAIN - combination of 21 and 22 */36OTX2_CPT_SE_UC_TYPE2 = 21,/* Fast Path IPSec + AirCrypto */37OTX2_CPT_SE_UC_TYPE3 = 22,/*38* Hash + HMAC + FlexiCrypto + RNG +39* Full Feature IPSec + AirCrypto + Kasumi40*/41OTX2_CPT_IE_UC_TYPE1 = 30, /* IE-MAIN - combination of 31 and 32 */42OTX2_CPT_IE_UC_TYPE2 = 31, /* Fast Path IPSec */43OTX2_CPT_IE_UC_TYPE3 = 32, /*44* Hash + HMAC + FlexiCrypto + RNG +45* Full Future IPSec46*/47};4849struct otx2_cpt_bitmap {50unsigned long bits[OTX2_CPT_ENGS_BITMASK_LEN];51int size;52};5354struct otx2_cpt_engines {55int type;56int count;57};5859/* Microcode version number */60struct otx2_cpt_ucode_ver_num {61u8 nn;62u8 xx;63u8 yy;64u8 zz;65};6667struct otx2_cpt_ucode_hdr {68struct otx2_cpt_ucode_ver_num ver_num;69u8 ver_str[OTX2_CPT_UCODE_VER_STR_SZ];70__be32 code_length;71u32 padding[3];72};7374struct otx2_cpt_ucode {75u8 ver_str[OTX2_CPT_UCODE_VER_STR_SZ + 1];/*76* ucode version in readable77* format78*/79struct otx2_cpt_ucode_ver_num ver_num;/* ucode version number */80char filename[OTX2_CPT_NAME_LENGTH];/* ucode filename */81dma_addr_t dma; /* phys address of ucode image */82void *va; /* virt address of ucode image */83u32 size; /* ucode image size */84int type; /* ucode image type SE, IE, AE or SE+IE */85};8687struct otx2_cpt_uc_info_t {88struct list_head list;89struct otx2_cpt_ucode ucode;/* microcode information */90const struct firmware *fw;91};9293/* Maximum and current number of engines available for all engine groups */94struct otx2_cpt_engs_available {95int max_se_cnt;96int max_ie_cnt;97int max_ae_cnt;98int se_cnt;99int ie_cnt;100int ae_cnt;101};102103/* Engines reserved to an engine group */104struct otx2_cpt_engs_rsvd {105int type; /* engine type */106int count; /* number of engines attached */107int offset; /* constant offset of engine type in the bitmap */108unsigned long *bmap; /* attached engines bitmap */109struct otx2_cpt_ucode *ucode; /* ucode used by these engines */110};111112struct otx2_cpt_mirror_info {113int is_ena; /*114* is mirroring enabled, it is set only for engine115* group which mirrors another engine group116*/117int idx; /*118* index of engine group which is mirrored by this119* group, set only for engine group which mirrors120* another group121*/122int ref_count; /*123* number of times this engine group is mirrored by124* other groups, this is set only for engine group125* which is mirrored by other group(s)126*/127};128129struct otx2_cpt_eng_grp_info {130struct otx2_cpt_eng_grps *g; /* pointer to engine_groups structure */131/* engines attached */132struct otx2_cpt_engs_rsvd engs[OTX2_CPT_MAX_ETYPES_PER_GRP];133/* ucodes information */134struct otx2_cpt_ucode ucode[OTX2_CPT_MAX_ETYPES_PER_GRP];135/* engine group mirroring information */136struct otx2_cpt_mirror_info mirror;137int idx; /* engine group index */138bool is_enabled; /*139* is engine group enabled, engine group is enabled140* when it has engines attached and ucode loaded141*/142};143144struct otx2_cpt_eng_grps {145struct mutex lock;146struct otx2_cpt_eng_grp_info grp[OTX2_CPT_MAX_ENGINE_GROUPS];147struct otx2_cpt_engs_available avail;148void *obj; /* device specific data */149int engs_num; /* total number of engines supported */150u8 eng_ref_cnt[OTX2_CPT_MAX_ENGINES];/* engines reference count */151bool is_grps_created; /* Is the engine groups are already created */152u16 rid;153};154struct otx2_cptpf_dev;155int otx2_cpt_init_eng_grps(struct pci_dev *pdev,156struct otx2_cpt_eng_grps *eng_grps);157void otx2_cpt_cleanup_eng_grps(struct pci_dev *pdev,158struct otx2_cpt_eng_grps *eng_grps);159int otx2_cpt_create_eng_grps(struct otx2_cptpf_dev *cptpf,160struct otx2_cpt_eng_grps *eng_grps);161int otx2_cpt_disable_all_cores(struct otx2_cptpf_dev *cptpf);162int otx2_cpt_get_eng_grp(struct otx2_cpt_eng_grps *eng_grps, int eng_type);163int otx2_cpt_discover_eng_capabilities(struct otx2_cptpf_dev *cptpf);164int otx2_cpt_dl_custom_egrp_create(struct otx2_cptpf_dev *cptpf,165struct devlink_param_gset_ctx *ctx);166int otx2_cpt_dl_custom_egrp_delete(struct otx2_cptpf_dev *cptpf,167struct devlink_param_gset_ctx *ctx);168struct otx2_cpt_engs_rsvd *find_engines_by_type(169struct otx2_cpt_eng_grp_info *eng_grp,170int eng_type);171#endif /* __OTX2_CPTPF_UCODE_H */172173174