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 }; 19 20 enum hpre_ctrl_dbgfs_file { 21 HPRE_CURRENT_QM, 22 HPRE_CLEAR_ENABLE, 23 HPRE_CLUSTER_CTRL, 24 HPRE_DEBUG_FILE_NUM, 25 }; 26 27 enum hpre_dfx_dbgfs_file { 28 HPRE_SEND_CNT, 29 HPRE_RECV_CNT, 30 HPRE_SEND_FAIL_CNT, 31 HPRE_SEND_BUSY_CNT, 32 HPRE_OVER_THRHLD_CNT, 33 HPRE_OVERTIME_THRHLD, 34 HPRE_INVALID_REQ_CNT, 35 HPRE_DFX_FILE_NUM 36 }; 37 38 #define HPRE_CLUSTERS_NUM_V2 (HPRE_CLUSTER3 + 1) 39 #define HPRE_CLUSTERS_NUM_V3 1 40 #define HPRE_CLUSTERS_NUM_MAX HPRE_CLUSTERS_NUM_V2 41 #define HPRE_DEBUGFS_FILE_NUM (HPRE_DEBUG_FILE_NUM + HPRE_CLUSTERS_NUM_MAX - 1) 42 43 struct hpre_debugfs_file { 44 int index; 45 enum hpre_ctrl_dbgfs_file type; 46 spinlock_t lock; 47 struct hpre_debug *debug; 48 }; 49 50 struct hpre_dfx { 51 atomic64_t value; 52 enum hpre_dfx_dbgfs_file type; 53 }; 54 55 /* 56 * One HPRE controller has one PF and multiple VFs, some global configurations 57 * which PF has need this structure. 58 * Just relevant for PF. 59 */ 60 struct hpre_debug { 61 struct hpre_dfx dfx[HPRE_DFX_FILE_NUM]; 62 struct hpre_debugfs_file files[HPRE_DEBUGFS_FILE_NUM]; 63 }; 64 65 struct hpre { 66 struct hisi_qm qm; 67 struct hpre_debug debug; 68 unsigned long status; 69 }; 70 71 enum hpre_alg_type { 72 HPRE_ALG_NC_NCRT = 0x0, 73 HPRE_ALG_NC_CRT = 0x1, 74 HPRE_ALG_KG_STD = 0x2, 75 HPRE_ALG_KG_CRT = 0x3, 76 HPRE_ALG_DH_G2 = 0x4, 77 HPRE_ALG_DH = 0x5, 78 }; 79 80 struct hpre_sqe { 81 __le32 dw0; 82 __u8 task_len1; 83 __u8 task_len2; 84 __u8 mrttest_num; 85 __u8 resv1; 86 __le64 key; 87 __le64 in; 88 __le64 out; 89 __le16 tag; 90 __le16 resv2; 91 #define _HPRE_SQE_ALIGN_EXT 7 92 __le32 rsvd1[_HPRE_SQE_ALIGN_EXT]; 93 }; 94 95 struct hisi_qp *hpre_create_qp(void); 96 int hpre_algs_register(void); 97 void hpre_algs_unregister(void); 98 99 #endif 100