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