xref: /linux/drivers/crypto/intel/qat/qat_common/adf_tl_debugfs.h (revision eed4edda910fe34dfae8c6bfbcf57f4593a54295)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* Copyright (c) 2023 Intel Corporation. */
3 #ifndef ADF_TL_DEBUGFS_H
4 #define ADF_TL_DEBUGFS_H
5 
6 #include <linux/types.h>
7 
8 struct adf_accel_dev;
9 
10 #define MAX_COUNT_NAME_SIZE	32
11 #define SNAPSHOT_CNT_MSG	"sample_cnt"
12 #define RP_NUM_INDEX		"rp_num"
13 #define PCI_TRANS_CNT_NAME	"pci_trans_cnt"
14 #define MAX_RD_LAT_NAME		"max_rd_lat"
15 #define RD_LAT_ACC_NAME		"rd_lat_acc_avg"
16 #define MAX_LAT_NAME		"max_gp_lat"
17 #define LAT_ACC_NAME		"gp_lat_acc_avg"
18 #define BW_IN_NAME		"bw_in"
19 #define BW_OUT_NAME		"bw_out"
20 #define PAGE_REQ_LAT_NAME	"at_page_req_lat_avg"
21 #define AT_TRANS_LAT_NAME	"at_trans_lat_avg"
22 #define AT_MAX_UTLB_USED_NAME	"at_max_tlb_used"
23 #define AT_GLOB_DTLB_HIT_NAME	"at_glob_devtlb_hit"
24 #define AT_GLOB_DTLB_MISS_NAME	"at_glob_devtlb_miss"
25 #define AT_PAYLD_DTLB_HIT_NAME	"tl_at_payld_devtlb_hit"
26 #define AT_PAYLD_DTLB_MISS_NAME	"tl_at_payld_devtlb_miss"
27 #define RP_SERVICE_TYPE		"service_type"
28 
29 #define ADF_TL_DBG_RP_ALPHA_INDEX(index) ((index) + 'A')
30 #define ADF_TL_DBG_RP_INDEX_ALPHA(alpha) ((alpha) - 'A')
31 
32 #define ADF_TL_RP_REGS_FNAME		"rp_%c_data"
33 #define ADF_TL_RP_REGS_FNAME_SIZE		16
34 
35 #define ADF_TL_DATA_REG_OFF(reg, qat_gen)	\
36 	offsetof(struct adf_##qat_gen##_tl_layout, reg)
37 
38 #define ADF_TL_DEV_REG_OFF(reg, qat_gen)			\
39 	(ADF_TL_DATA_REG_OFF(tl_device_data_regs, qat_gen) +	\
40 	offsetof(struct adf_##qat_gen##_tl_device_data_regs, reg))
41 
42 #define ADF_TL_SLICE_REG_OFF(slice, reg, qat_gen)		\
43 	(ADF_TL_DEV_REG_OFF(slice##_slices[0], qat_gen) +	\
44 	offsetof(struct adf_##qat_gen##_tl_slice_data_regs, reg))
45 
46 #define ADF_TL_RP_REG_OFF(reg, qat_gen)					\
47 	(ADF_TL_DATA_REG_OFF(tl_ring_pairs_data_regs[0], qat_gen) +	\
48 	offsetof(struct adf_##qat_gen##_tl_ring_pair_data_regs, reg))
49 
50 /**
51  * enum adf_tl_counter_type - telemetry counter types
52  * @ADF_TL_COUNTER_UNSUPPORTED: unsupported counter
53  * @ADF_TL_SIMPLE_COUNT: simple counter
54  * @ADF_TL_COUNTER_NS: latency counter, value in ns
55  * @ADF_TL_COUNTER_NS_AVG: accumulated average latency counter, value in ns
56  * @ADF_TL_COUNTER_MBPS: bandwidth, value in MBps
57  */
58 enum adf_tl_counter_type {
59 	ADF_TL_COUNTER_UNSUPPORTED,
60 	ADF_TL_SIMPLE_COUNT,
61 	ADF_TL_COUNTER_NS,
62 	ADF_TL_COUNTER_NS_AVG,
63 	ADF_TL_COUNTER_MBPS,
64 };
65 
66 /**
67  * struct adf_tl_dbg_counter - telemetry counter definition
68  * @name: name of the counter as printed in the report
69  * @adf_tl_counter_type: type of the counter
70  * @offset1: offset of 1st register
71  * @offset2: offset of 2nd optional register
72  */
73 struct adf_tl_dbg_counter {
74 	const char *name;
75 	enum adf_tl_counter_type type;
76 	size_t offset1;
77 	size_t offset2;
78 };
79 
80 #define ADF_TL_COUNTER(_name, _type, _offset)	\
81 {	.name =		_name,			\
82 	.type =		_type,			\
83 	.offset1 =	_offset			\
84 }
85 
86 #define ADF_TL_COUNTER_LATENCY(_name, _type, _offset1, _offset2)	\
87 {	.name =		_name,						\
88 	.type =		_type,						\
89 	.offset1 =	_offset1,					\
90 	.offset2 =	_offset2					\
91 }
92 
93 /* Telemetry counter aggregated values. */
94 struct adf_tl_dbg_aggr_values {
95 	u64 curr;
96 	u64 min;
97 	u64 max;
98 	u64 avg;
99 };
100 
101 /**
102  * adf_tl_dbgfs_add() - Add telemetry's debug fs entries.
103  * @accel_dev: Pointer to acceleration device.
104  *
105  * Creates telemetry's debug fs folder and attributes in QAT debug fs root.
106  */
107 void adf_tl_dbgfs_add(struct adf_accel_dev *accel_dev);
108 
109 /**
110  * adf_tl_dbgfs_rm() - Remove telemetry's debug fs entries.
111  * @accel_dev: Pointer to acceleration device.
112  *
113  * Removes telemetry's debug fs folder and attributes from QAT debug fs root.
114  */
115 void adf_tl_dbgfs_rm(struct adf_accel_dev *accel_dev);
116 
117 #endif /* ADF_TL_DEBUGFS_H */
118