18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* Copyright (c) 2019 HiSilicon Limited. */ 38c2ecf20Sopenharmony_ci#ifndef __HISI_HPRE_H 48c2ecf20Sopenharmony_ci#define __HISI_HPRE_H 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci#include <linux/list.h> 78c2ecf20Sopenharmony_ci#include "../qm.h" 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#define HPRE_SQE_SIZE sizeof(struct hpre_sqe) 108c2ecf20Sopenharmony_ci#define HPRE_PF_DEF_Q_NUM 64 118c2ecf20Sopenharmony_ci#define HPRE_PF_DEF_Q_BASE 0 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_cienum { 148c2ecf20Sopenharmony_ci HPRE_CLUSTER0, 158c2ecf20Sopenharmony_ci HPRE_CLUSTER1, 168c2ecf20Sopenharmony_ci HPRE_CLUSTER2, 178c2ecf20Sopenharmony_ci HPRE_CLUSTER3, 188c2ecf20Sopenharmony_ci HPRE_CLUSTERS_NUM, 198c2ecf20Sopenharmony_ci}; 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_cienum hpre_ctrl_dbgfs_file { 228c2ecf20Sopenharmony_ci HPRE_CURRENT_QM, 238c2ecf20Sopenharmony_ci HPRE_CLEAR_ENABLE, 248c2ecf20Sopenharmony_ci HPRE_CLUSTER_CTRL, 258c2ecf20Sopenharmony_ci HPRE_DEBUG_FILE_NUM, 268c2ecf20Sopenharmony_ci}; 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_cienum hpre_dfx_dbgfs_file { 298c2ecf20Sopenharmony_ci HPRE_SEND_CNT, 308c2ecf20Sopenharmony_ci HPRE_RECV_CNT, 318c2ecf20Sopenharmony_ci HPRE_SEND_FAIL_CNT, 328c2ecf20Sopenharmony_ci HPRE_SEND_BUSY_CNT, 338c2ecf20Sopenharmony_ci HPRE_OVER_THRHLD_CNT, 348c2ecf20Sopenharmony_ci HPRE_OVERTIME_THRHLD, 358c2ecf20Sopenharmony_ci HPRE_INVALID_REQ_CNT, 368c2ecf20Sopenharmony_ci HPRE_DFX_FILE_NUM 378c2ecf20Sopenharmony_ci}; 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci#define HPRE_DEBUGFS_FILE_NUM (HPRE_DEBUG_FILE_NUM + HPRE_CLUSTERS_NUM - 1) 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_cistruct hpre_debugfs_file { 428c2ecf20Sopenharmony_ci int index; 438c2ecf20Sopenharmony_ci enum hpre_ctrl_dbgfs_file type; 448c2ecf20Sopenharmony_ci spinlock_t lock; 458c2ecf20Sopenharmony_ci struct hpre_debug *debug; 468c2ecf20Sopenharmony_ci}; 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_cistruct hpre_dfx { 498c2ecf20Sopenharmony_ci atomic64_t value; 508c2ecf20Sopenharmony_ci enum hpre_dfx_dbgfs_file type; 518c2ecf20Sopenharmony_ci}; 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci/* 548c2ecf20Sopenharmony_ci * One HPRE controller has one PF and multiple VFs, some global configurations 558c2ecf20Sopenharmony_ci * which PF has need this structure. 568c2ecf20Sopenharmony_ci * Just relevant for PF. 578c2ecf20Sopenharmony_ci */ 588c2ecf20Sopenharmony_cistruct hpre_debug { 598c2ecf20Sopenharmony_ci struct hpre_dfx dfx[HPRE_DFX_FILE_NUM]; 608c2ecf20Sopenharmony_ci struct hpre_debugfs_file files[HPRE_DEBUGFS_FILE_NUM]; 618c2ecf20Sopenharmony_ci}; 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_cistruct hpre { 648c2ecf20Sopenharmony_ci struct hisi_qm qm; 658c2ecf20Sopenharmony_ci struct hpre_debug debug; 668c2ecf20Sopenharmony_ci unsigned long status; 678c2ecf20Sopenharmony_ci}; 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_cienum hpre_alg_type { 708c2ecf20Sopenharmony_ci HPRE_ALG_NC_NCRT = 0x0, 718c2ecf20Sopenharmony_ci HPRE_ALG_NC_CRT = 0x1, 728c2ecf20Sopenharmony_ci HPRE_ALG_KG_STD = 0x2, 738c2ecf20Sopenharmony_ci HPRE_ALG_KG_CRT = 0x3, 748c2ecf20Sopenharmony_ci HPRE_ALG_DH_G2 = 0x4, 758c2ecf20Sopenharmony_ci HPRE_ALG_DH = 0x5, 768c2ecf20Sopenharmony_ci}; 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_cistruct hpre_sqe { 798c2ecf20Sopenharmony_ci __le32 dw0; 808c2ecf20Sopenharmony_ci __u8 task_len1; 818c2ecf20Sopenharmony_ci __u8 task_len2; 828c2ecf20Sopenharmony_ci __u8 mrttest_num; 838c2ecf20Sopenharmony_ci __u8 resv1; 848c2ecf20Sopenharmony_ci __le64 key; 858c2ecf20Sopenharmony_ci __le64 in; 868c2ecf20Sopenharmony_ci __le64 out; 878c2ecf20Sopenharmony_ci __le16 tag; 888c2ecf20Sopenharmony_ci __le16 resv2; 898c2ecf20Sopenharmony_ci#define _HPRE_SQE_ALIGN_EXT 7 908c2ecf20Sopenharmony_ci __le32 rsvd1[_HPRE_SQE_ALIGN_EXT]; 918c2ecf20Sopenharmony_ci}; 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_cistruct hisi_qp *hpre_create_qp(void); 948c2ecf20Sopenharmony_ciint hpre_algs_register(void); 958c2ecf20Sopenharmony_civoid hpre_algs_unregister(void); 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_ci#endif 98