cc_buffer_mgr.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright (C) 2012-2019 ARM Limited (or its affiliates). */
  3. /* \file cc_buffer_mgr.h
  4. * Buffer Manager
  5. */
  6. #ifndef __CC_BUFFER_MGR_H__
  7. #define __CC_BUFFER_MGR_H__
  8. #include <crypto/algapi.h>
  9. #include "cc_driver.h"
  10. enum cc_req_dma_buf_type {
  11. CC_DMA_BUF_NULL = 0,
  12. CC_DMA_BUF_DLLI,
  13. CC_DMA_BUF_MLLI
  14. };
  15. enum cc_sg_cpy_direct {
  16. CC_SG_TO_BUF = 0,
  17. CC_SG_FROM_BUF = 1
  18. };
  19. struct cc_mlli {
  20. cc_sram_addr_t sram_addr;
  21. unsigned int mapped_nents;
  22. unsigned int nents; //sg nents
  23. unsigned int mlli_nents; //mlli nents might be different than the above
  24. };
  25. struct mlli_params {
  26. struct dma_pool *curr_pool;
  27. u8 *mlli_virt_addr;
  28. dma_addr_t mlli_dma_addr;
  29. u32 mlli_len;
  30. };
  31. int cc_buffer_mgr_init(struct cc_drvdata *drvdata);
  32. int cc_buffer_mgr_fini(struct cc_drvdata *drvdata);
  33. int cc_map_cipher_request(struct cc_drvdata *drvdata, void *ctx,
  34. unsigned int ivsize, unsigned int nbytes,
  35. void *info, struct scatterlist *src,
  36. struct scatterlist *dst, gfp_t flags);
  37. void cc_unmap_cipher_request(struct device *dev, void *ctx, unsigned int ivsize,
  38. struct scatterlist *src, struct scatterlist *dst);
  39. int cc_map_aead_request(struct cc_drvdata *drvdata, struct aead_request *req);
  40. void cc_unmap_aead_request(struct device *dev, struct aead_request *req);
  41. int cc_map_hash_request_final(struct cc_drvdata *drvdata, void *ctx,
  42. struct scatterlist *src, unsigned int nbytes,
  43. bool do_update, gfp_t flags);
  44. int cc_map_hash_request_update(struct cc_drvdata *drvdata, void *ctx,
  45. struct scatterlist *src, unsigned int nbytes,
  46. unsigned int block_size, gfp_t flags);
  47. void cc_unmap_hash_request(struct device *dev, void *ctx,
  48. struct scatterlist *src, bool do_revert);
  49. void cc_copy_sg_portion(struct device *dev, u8 *dest, struct scatterlist *sg,
  50. u32 to_skip, u32 end, enum cc_sg_cpy_direct direct);
  51. #endif /*__BUFFER_MGR_H__*/