Path: blob/master/drivers/crypto/marvell/octeontx/otx_cptpf_ucode.h
26285 views
/* SPDX-License-Identifier: GPL-2.01* Marvell OcteonTX CPT driver2*3* Copyright (C) 2019 Marvell International Ltd.4*5* This program is free software; you can redistribute it and/or modify6* it under the terms of the GNU General Public License version 2 as7* published by the Free Software Foundation.8*/910#ifndef __OTX_CPTPF_UCODE_H11#define __OTX_CPTPF_UCODE_H1213#include <linux/pci.h>14#include <linux/types.h>15#include <linux/module.h>16#include "otx_cpt_hw_types.h"1718/* CPT ucode name maximum length */19#define OTX_CPT_UCODE_NAME_LENGTH 6420/*21* On OcteonTX 83xx platform, only one type of engines is allowed to be22* attached to an engine group.23*/24#define OTX_CPT_MAX_ETYPES_PER_GRP 12526/* Default tar archive file names */27#define OTX_CPT_UCODE_TAR_FILE_NAME "cpt8x-mc.tar"2829/* CPT ucode alignment */30#define OTX_CPT_UCODE_ALIGNMENT 1283132/* CPT ucode signature size */33#define OTX_CPT_UCODE_SIGN_LEN 2563435/* Microcode version string length */36#define OTX_CPT_UCODE_VER_STR_SZ 443738/* Maximum number of supported engines/cores on OcteonTX 83XX platform */39#define OTX_CPT_MAX_ENGINES 644041#define OTX_CPT_ENGS_BITMASK_LEN (OTX_CPT_MAX_ENGINES/(BITS_PER_BYTE * \42sizeof(unsigned long)))4344/* Microcode types */45enum otx_cpt_ucode_type {46OTX_CPT_AE_UC_TYPE = 1, /* AE-MAIN */47OTX_CPT_SE_UC_TYPE1 = 20, /* SE-MAIN - combination of 21 and 22 */48OTX_CPT_SE_UC_TYPE2 = 21, /* Fast Path IPSec + AirCrypto */49OTX_CPT_SE_UC_TYPE3 = 22, /*50* Hash + HMAC + FlexiCrypto + RNG + Full51* Feature IPSec + AirCrypto + Kasumi52*/53};5455struct otx_cpt_bitmap {56unsigned long bits[OTX_CPT_ENGS_BITMASK_LEN];57int size;58};5960struct otx_cpt_engines {61int type;62int count;63};6465/* Microcode version number */66struct otx_cpt_ucode_ver_num {67u8 nn;68u8 xx;69u8 yy;70u8 zz;71};7273struct otx_cpt_ucode_hdr {74struct otx_cpt_ucode_ver_num ver_num;75u8 ver_str[OTX_CPT_UCODE_VER_STR_SZ];76__be32 code_length;77u32 padding[3];78};7980struct otx_cpt_ucode {81u8 ver_str[OTX_CPT_UCODE_VER_STR_SZ];/*82* ucode version in readable format83*/84struct otx_cpt_ucode_ver_num ver_num;/* ucode version number */85char filename[OTX_CPT_UCODE_NAME_LENGTH]; /* ucode filename */86dma_addr_t dma; /* phys address of ucode image */87dma_addr_t align_dma; /* aligned phys address of ucode image */88void *va; /* virt address of ucode image */89void *align_va; /* aligned virt address of ucode image */90u32 size; /* ucode image size */91int type; /* ucode image type SE or AE */92};9394struct tar_ucode_info_t {95struct list_head list;96struct otx_cpt_ucode ucode;/* microcode information */97const u8 *ucode_ptr; /* pointer to microcode in tar archive */98};99100/* Maximum and current number of engines available for all engine groups */101struct otx_cpt_engs_available {102int max_se_cnt;103int max_ae_cnt;104int se_cnt;105int ae_cnt;106};107108/* Engines reserved to an engine group */109struct otx_cpt_engs_rsvd {110int type; /* engine type */111int count; /* number of engines attached */112int offset; /* constant offset of engine type in the bitmap */113unsigned long *bmap; /* attached engines bitmap */114struct otx_cpt_ucode *ucode; /* ucode used by these engines */115};116117struct otx_cpt_mirror_info {118int is_ena; /*119* is mirroring enabled, it is set only for engine120* group which mirrors another engine group121*/122int idx; /*123* index of engine group which is mirrored by this124* group, set only for engine group which mirrors125* another group126*/127int ref_count; /*128* number of times this engine group is mirrored by129* other groups, this is set only for engine group130* which is mirrored by other group(s)131*/132};133134struct otx_cpt_eng_grp_info {135struct otx_cpt_eng_grps *g; /* pointer to engine_groups structure */136struct device_attribute info_attr; /* group info entry attr */137/* engines attached */138struct otx_cpt_engs_rsvd engs[OTX_CPT_MAX_ETYPES_PER_GRP];139/* Microcode information */140struct otx_cpt_ucode ucode[OTX_CPT_MAX_ETYPES_PER_GRP];141/* sysfs info entry name */142char sysfs_info_name[OTX_CPT_UCODE_NAME_LENGTH];143/* engine group mirroring information */144struct otx_cpt_mirror_info mirror;145int idx; /* engine group index */146bool is_enabled; /*147* is engine group enabled, engine group is enabled148* when it has engines attached and ucode loaded149*/150};151152struct otx_cpt_eng_grps {153struct otx_cpt_eng_grp_info grp[OTX_CPT_MAX_ENGINE_GROUPS];154struct device_attribute ucode_load_attr;/* ucode load attr */155struct otx_cpt_engs_available avail;156struct mutex lock;157void *obj;158int engs_num; /* total number of engines supported */159int eng_types_supported; /* engine types supported SE, AE */160u8 eng_ref_cnt[OTX_CPT_MAX_ENGINES];/* engines reference count */161bool is_ucode_load_created; /* is ucode_load sysfs entry created */162bool is_first_try; /* is this first try to create kcrypto engine grp */163bool is_rdonly; /* do engine groups configuration can be modified */164};165166int otx_cpt_init_eng_grps(struct pci_dev *pdev,167struct otx_cpt_eng_grps *eng_grps, int pf_type);168void otx_cpt_cleanup_eng_grps(struct pci_dev *pdev,169struct otx_cpt_eng_grps *eng_grps);170int otx_cpt_try_create_default_eng_grps(struct pci_dev *pdev,171struct otx_cpt_eng_grps *eng_grps,172int pf_type);173void otx_cpt_set_eng_grps_is_rdonly(struct otx_cpt_eng_grps *eng_grps,174bool is_rdonly);175int otx_cpt_uc_supports_eng_type(struct otx_cpt_ucode *ucode, int eng_type);176177#endif /* __OTX_CPTPF_UCODE_H */178179180