summaryrefslogtreecommitdiffstats
path: root/drivers/crypto/intel/qat/qat_common/adf_gen4_tl.h
blob: 32df4163beb9f098664b5be8fcd3b0440a5db53c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/* SPDX-License-Identifier: GPL-2.0-only */
/* Copyright (c) 2023 Intel Corporation. */
#ifndef ADF_GEN4_TL_H
#define ADF_GEN4_TL_H

#include <linux/stddef.h>
#include <linux/types.h>

struct adf_tl_hw_data;

/* Computation constants. */
#define ADF_GEN4_CPP_NS_PER_CYCLE		2
#define ADF_GEN4_TL_BW_HW_UNITS_TO_BYTES	64

/* Maximum aggregation time. Value in milliseconds. */
#define ADF_GEN4_TL_MAX_AGGR_TIME_MS		4000
/* Num of buffers to store historic values. */
#define ADF_GEN4_TL_NUM_HIST_BUFFS \
	(ADF_GEN4_TL_MAX_AGGR_TIME_MS / ADF_TL_DATA_WR_INTERVAL_MS)

/* Max number of HW resources of one type. */
#define ADF_GEN4_TL_MAX_SLICES_PER_TYPE		24

/* Max number of simultaneously monitored ring pairs. */
#define ADF_GEN4_TL_MAX_RP_NUM			4

/**
 * struct adf_gen4_tl_slice_data_regs - HW slice data as populated by FW.
 * @reg_tm_slice_exec_cnt: Slice execution count.
 * @reg_tm_slice_util: Slice utilization.
 */
struct adf_gen4_tl_slice_data_regs {
	__u32 reg_tm_slice_exec_cnt;
	__u32 reg_tm_slice_util;
};

#define ADF_GEN4_TL_SLICE_REG_SZ sizeof(struct adf_gen4_tl_slice_data_regs)

/**
 * struct adf_gen4_tl_device_data_regs - This structure stores device telemetry
 * counter values as are being populated periodically by device.
 * @reg_tl_rd_lat_acc: read latency accumulator
 * @reg_tl_gp_lat_acc: get-put latency accumulator
 * @reg_tl_at_page_req_lat_acc: AT/DevTLB page request latency accumulator
 * @reg_tl_at_trans_lat_acc: DevTLB transaction latency accumulator
 * @reg_tl_re_acc: accumulated ring empty time
 * @reg_tl_pci_trans_cnt: PCIe partial transactions
 * @reg_tl_rd_lat_max: maximum logged read latency
 * @reg_tl_rd_cmpl_cnt: read requests completed count
 * @reg_tl_gp_lat_max: maximum logged get to put latency
 * @reg_tl_ae_put_cnt: Accelerator Engine put counts across all rings
 * @reg_tl_bw_in: PCIe write bandwidth
 * @reg_tl_bw_out: PCIe read bandwidth
 * @reg_tl_at_page_req_cnt: DevTLB page requests count
 * @reg_tl_at_trans_lat_cnt: DevTLB transaction latency samples count
 * @reg_tl_at_max_tlb_used: maximum uTLB used
 * @reg_tl_re_cnt: ring empty time samples count
 * @reserved: reserved
 * @ath_slices: array of Authentication slices utilization registers
 * @cph_slices: array of Cipher slices utilization registers
 * @cpr_slices: array of Compression slices utilization registers
 * @xlt_slices: array of Translator slices utilization registers
 * @dcpr_slices: array of Decompression slices utilization registers
 * @pke_slices: array of PKE slices utilization registers
 * @ucs_slices: array of UCS slices utilization registers
 * @wat_slices: array of Wireless Authentication slices utilization registers
 * @wcp_slices: array of Wireless Cipher slices utilization registers
 */
struct adf_gen4_tl_device_data_regs {
	__u64 reg_tl_rd_lat_acc;
	__u64 reg_tl_gp_lat_acc;
	__u64 reg_tl_at_page_req_lat_acc;
	__u64 reg_tl_at_trans_lat_acc;
	__u64 reg_tl_re_acc;
	__u32 reg_tl_pci_trans_cnt;
	__u32 reg_tl_rd_lat_max;
	__u32 reg_tl_rd_cmpl_cnt;
	__u32 reg_tl_gp_lat_max;
	__u32 reg_tl_ae_put_cnt;
	__u32 reg_tl_bw_in;
	__u32 reg_tl_bw_out;
	__u32 reg_tl_at_page_req_cnt;
	__u32 reg_tl_at_trans_lat_cnt;
	__u32 reg_tl_at_max_tlb_used;
	__u32 reg_tl_re_cnt;
	__u32 reserved;
	struct adf_gen4_tl_slice_data_regs ath_slices[ADF_GEN4_TL_MAX_SLICES_PER_TYPE];
	struct adf_gen4_tl_slice_data_regs cph_slices[ADF_GEN4_TL_MAX_SLICES_PER_TYPE];
	struct adf_gen4_tl_slice_data_regs cpr_slices[ADF_GEN4_TL_MAX_SLICES_PER_TYPE];
	struct adf_gen4_tl_slice_data_regs xlt_slices[ADF_GEN4_TL_MAX_SLICES_PER_TYPE];
	struct adf_gen4_tl_slice_data_regs dcpr_slices[ADF_GEN4_TL_MAX_SLICES_PER_TYPE];
	struct adf_gen4_tl_slice_data_regs pke_slices[ADF_GEN4_TL_MAX_SLICES_PER_TYPE];
	struct adf_gen4_tl_slice_data_regs ucs_slices[ADF_GEN4_TL_MAX_SLICES_PER_TYPE];
	struct adf_gen4_tl_slice_data_regs wat_slices[ADF_GEN4_TL_MAX_SLICES_PER_TYPE];
	struct adf_gen4_tl_slice_data_regs wcp_slices[ADF_GEN4_TL_MAX_SLICES_PER_TYPE];
};

/**
 * struct adf_gen4_tl_ring_pair_data_regs - This structure stores Ring Pair
 * telemetry counter values as are being populated periodically by device.
 * @reg_tl_gp_lat_acc: get-put latency accumulator
 * @reserved: reserved
 * @reg_tl_pci_trans_cnt: PCIe partial transactions
 * @reg_tl_ae_put_cnt: Accelerator Engine put counts across all rings
 * @reg_tl_bw_in: PCIe write bandwidth
 * @reg_tl_bw_out: PCIe read bandwidth
 * @reg_tl_at_glob_devtlb_hit: Message descriptor DevTLB hit rate
 * @reg_tl_at_glob_devtlb_miss: Message descriptor DevTLB miss rate
 * @reg_tl_at_payld_devtlb_hit: Payload DevTLB hit rate
 * @reg_tl_at_payld_devtlb_miss: Payload DevTLB miss rate
 * @reg_tl_re_cnt: ring empty time samples count
 * @reserved1: reserved
 */
struct adf_gen4_tl_ring_pair_data_regs {
	__u64 reg_tl_gp_lat_acc;
	__u64 reserved;
	__u32 reg_tl_pci_trans_cnt;
	__u32 reg_tl_ae_put_cnt;
	__u32 reg_tl_bw_in;
	__u32 reg_tl_bw_out;
	__u32 reg_tl_at_glob_devtlb_hit;
	__u32 reg_tl_at_glob_devtlb_miss;
	__u32 reg_tl_at_payld_devtlb_hit;
	__u32 reg_tl_at_payld_devtlb_miss;
	__u32 reg_tl_re_cnt;
	__u32 reserved1;
};

#define ADF_GEN4_TL_RP_REG_SZ sizeof(struct adf_gen4_tl_ring_pair_data_regs)

/**
 * struct adf_gen4_tl_layout - This structure represents entire telemetry
 * counters data: Device + 4 Ring Pairs as are being populated periodically
 * by device.
 * @tl_device_data_regs: structure of device telemetry registers
 * @tl_ring_pairs_data_regs: array of ring pairs telemetry registers
 * @reg_tl_msg_cnt: telemetry messages counter
 * @reserved: reserved
 */
struct adf_gen4_tl_layout {
	struct adf_gen4_tl_device_data_regs tl_device_data_regs;
	struct adf_gen4_tl_ring_pair_data_regs
			tl_ring_pairs_data_regs[ADF_GEN4_TL_MAX_RP_NUM];
	__u32 reg_tl_msg_cnt;
	__u32 reserved;
};

#define ADF_GEN4_TL_LAYOUT_SZ	sizeof(struct adf_gen4_tl_layout)
#define ADF_GEN4_TL_MSG_CNT_OFF	offsetof(struct adf_gen4_tl_layout, reg_tl_msg_cnt)

#ifdef CONFIG_DEBUG_FS
void adf_gen4_init_tl_data(struct adf_tl_hw_data *tl_data);
#else
static inline void adf_gen4_init_tl_data(struct adf_tl_hw_data *tl_data)
{
}
#endif /* CONFIG_DEBUG_FS */
#endif /* ADF_GEN4_TL_H */