hpre.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright (c) 2019 HiSilicon Limited. */
  3. #ifndef __HISI_HPRE_H
  4. #define __HISI_HPRE_H
  5. #include <linux/list.h>
  6. #include <linux/hisi_acc_qm.h>
  7. #define HPRE_SQE_SIZE sizeof(struct hpre_sqe)
  8. #define HPRE_PF_DEF_Q_NUM 64
  9. #define HPRE_PF_DEF_Q_BASE 0
  10. /*
  11. * type used in qm sqc DW6.
  12. * 0 - Algorithm which has been supported in V2, like RSA, DH and so on;
  13. * 1 - ECC algorithm in V3.
  14. */
  15. #define HPRE_V2_ALG_TYPE 0
  16. #define HPRE_V3_ECC_ALG_TYPE 1
  17. enum {
  18. HPRE_CLUSTER0,
  19. HPRE_CLUSTER1,
  20. HPRE_CLUSTER2,
  21. HPRE_CLUSTER3,
  22. HPRE_CLUSTERS_NUM_MAX
  23. };
  24. enum hpre_ctrl_dbgfs_file {
  25. HPRE_CLEAR_ENABLE,
  26. HPRE_CLUSTER_CTRL,
  27. HPRE_DEBUG_FILE_NUM,
  28. };
  29. enum hpre_dfx_dbgfs_file {
  30. HPRE_SEND_CNT,
  31. HPRE_RECV_CNT,
  32. HPRE_SEND_FAIL_CNT,
  33. HPRE_SEND_BUSY_CNT,
  34. HPRE_OVER_THRHLD_CNT,
  35. HPRE_OVERTIME_THRHLD,
  36. HPRE_INVALID_REQ_CNT,
  37. HPRE_DFX_FILE_NUM
  38. };
  39. #define HPRE_DEBUGFS_FILE_NUM (HPRE_DEBUG_FILE_NUM + HPRE_CLUSTERS_NUM_MAX - 1)
  40. struct hpre_debugfs_file {
  41. int index;
  42. enum hpre_ctrl_dbgfs_file type;
  43. spinlock_t lock;
  44. struct hpre_debug *debug;
  45. };
  46. struct hpre_dfx {
  47. atomic64_t value;
  48. enum hpre_dfx_dbgfs_file type;
  49. };
  50. /*
  51. * One HPRE controller has one PF and multiple VFs, some global configurations
  52. * which PF has need this structure.
  53. * Just relevant for PF.
  54. */
  55. struct hpre_debug {
  56. struct hpre_dfx dfx[HPRE_DFX_FILE_NUM];
  57. struct hpre_debugfs_file files[HPRE_DEBUGFS_FILE_NUM];
  58. };
  59. struct hpre {
  60. struct hisi_qm qm;
  61. struct hpre_debug debug;
  62. unsigned long status;
  63. };
  64. enum hpre_alg_type {
  65. HPRE_ALG_NC_NCRT = 0x0,
  66. HPRE_ALG_NC_CRT = 0x1,
  67. HPRE_ALG_KG_STD = 0x2,
  68. HPRE_ALG_KG_CRT = 0x3,
  69. HPRE_ALG_DH_G2 = 0x4,
  70. HPRE_ALG_DH = 0x5,
  71. HPRE_ALG_ECC_MUL = 0xD,
  72. /* shared by x25519 and x448, but x448 is not supported now */
  73. HPRE_ALG_CURVE25519_MUL = 0x10,
  74. };
  75. struct hpre_sqe {
  76. __le32 dw0;
  77. __u8 task_len1;
  78. __u8 task_len2;
  79. __u8 mrttest_num;
  80. __u8 resv1;
  81. __le64 key;
  82. __le64 in;
  83. __le64 out;
  84. __le16 tag;
  85. __le16 resv2;
  86. #define _HPRE_SQE_ALIGN_EXT 7
  87. __le32 rsvd1[_HPRE_SQE_ALIGN_EXT];
  88. };
  89. struct hisi_qp *hpre_create_qp(u8 type);
  90. int hpre_algs_register(struct hisi_qm *qm);
  91. void hpre_algs_unregister(struct hisi_qm *qm);
  92. bool hpre_check_alg_support(struct hisi_qm *qm, u32 alg);
  93. #endif