Path: blob/master/drivers/crypto/intel/keembay/ocs-hcu.h
29278 views
/* SPDX-License-Identifier: GPL-2.0-only */1/*2* Intel Keem Bay OCS HCU Crypto Driver.3*4* Copyright (C) 2018-2020 Intel Corporation5*/67#include <linux/dma-mapping.h>89#ifndef _CRYPTO_OCS_HCU_H10#define _CRYPTO_OCS_HCU_H1112#define OCS_HCU_DMA_BIT_MASK DMA_BIT_MASK(32)1314#define OCS_HCU_HW_KEY_LEN 641516struct ocs_hcu_dma_list;1718enum ocs_hcu_algo {19OCS_HCU_ALGO_SHA256 = 2,20OCS_HCU_ALGO_SHA224 = 3,21OCS_HCU_ALGO_SHA384 = 4,22OCS_HCU_ALGO_SHA512 = 5,23OCS_HCU_ALGO_SM3 = 6,24};2526/**27* struct ocs_hcu_dev - OCS HCU device context.28* @list: List of device contexts.29* @dev: OCS HCU device.30* @io_base: Base address of OCS HCU registers.31* @engine: Crypto engine for the device.32* @irq: IRQ number.33* @irq_done: Completion for IRQ.34* @irq_err: Flag indicating an IRQ error has happened.35*/36struct ocs_hcu_dev {37struct list_head list;38struct device *dev;39void __iomem *io_base;40struct crypto_engine *engine;41int irq;42struct completion irq_done;43bool irq_err;44};4546/**47* struct ocs_hcu_idata - Intermediate data generated by the HCU.48* @msg_len_lo: Length of data the HCU has operated on in bits, low 32b.49* @msg_len_hi: Length of data the HCU has operated on in bits, high 32b.50* @digest: The digest read from the HCU. If the HCU is terminated, it will51* contain the actual hash digest. Otherwise it is the intermediate52* state.53*/54struct ocs_hcu_idata {55u32 msg_len_lo;56u32 msg_len_hi;57u8 digest[SHA512_DIGEST_SIZE];58};5960/**61* struct ocs_hcu_hash_ctx - Context for OCS HCU hashing operation.62* @algo: The hashing algorithm being used.63* @idata: The current intermediate data.64*/65struct ocs_hcu_hash_ctx {66enum ocs_hcu_algo algo;67struct ocs_hcu_idata idata;68};6970irqreturn_t ocs_hcu_irq_handler(int irq, void *dev_id);7172struct ocs_hcu_dma_list *ocs_hcu_dma_list_alloc(struct ocs_hcu_dev *hcu_dev,73int max_nents);7475void ocs_hcu_dma_list_free(struct ocs_hcu_dev *hcu_dev,76struct ocs_hcu_dma_list *dma_list);7778int ocs_hcu_dma_list_add_tail(struct ocs_hcu_dev *hcu_dev,79struct ocs_hcu_dma_list *dma_list,80dma_addr_t addr, u32 len);8182int ocs_hcu_hash_init(struct ocs_hcu_hash_ctx *ctx, enum ocs_hcu_algo algo);8384int ocs_hcu_hash_update(struct ocs_hcu_dev *hcu_dev,85struct ocs_hcu_hash_ctx *ctx,86const struct ocs_hcu_dma_list *dma_list);8788int ocs_hcu_hash_finup(struct ocs_hcu_dev *hcu_dev,89const struct ocs_hcu_hash_ctx *ctx,90const struct ocs_hcu_dma_list *dma_list,91u8 *dgst, size_t dgst_len);9293int ocs_hcu_hash_final(struct ocs_hcu_dev *hcu_dev,94const struct ocs_hcu_hash_ctx *ctx, u8 *dgst,95size_t dgst_len);9697int ocs_hcu_digest(struct ocs_hcu_dev *hcu_dev, enum ocs_hcu_algo algo,98void *data, size_t data_len, u8 *dgst, size_t dgst_len);99100int ocs_hcu_hmac(struct ocs_hcu_dev *hcu_dev, enum ocs_hcu_algo algo,101const u8 *key, size_t key_len,102const struct ocs_hcu_dma_list *dma_list,103u8 *dgst, size_t dgst_len);104105#endif /* _CRYPTO_OCS_HCU_H */106107108