xref: /OK3568_Linux_fs/kernel/arch/powerpc/perf/hv-24x7.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun #ifndef LINUX_POWERPC_PERF_HV_24X7_H_
3*4882a593Smuzhiyun #define LINUX_POWERPC_PERF_HV_24X7_H_
4*4882a593Smuzhiyun 
5*4882a593Smuzhiyun #include <linux/types.h>
6*4882a593Smuzhiyun 
7*4882a593Smuzhiyun enum hv_perf_domains {
8*4882a593Smuzhiyun #define DOMAIN(n, v, x, c) HV_PERF_DOMAIN_##n = v,
9*4882a593Smuzhiyun #include "hv-24x7-domains.h"
10*4882a593Smuzhiyun #undef DOMAIN
11*4882a593Smuzhiyun 	HV_PERF_DOMAIN_MAX,
12*4882a593Smuzhiyun };
13*4882a593Smuzhiyun 
14*4882a593Smuzhiyun #define H24x7_REQUEST_SIZE(iface_version)	(iface_version == 1 ? 16 : 32)
15*4882a593Smuzhiyun 
16*4882a593Smuzhiyun struct hv_24x7_request {
17*4882a593Smuzhiyun 	/* PHYSICAL domains require enabling via phyp/hmc. */
18*4882a593Smuzhiyun 	__u8 performance_domain;
19*4882a593Smuzhiyun 	__u8 reserved[0x1];
20*4882a593Smuzhiyun 
21*4882a593Smuzhiyun 	/* bytes to read starting at @data_offset. must be a multiple of 8 */
22*4882a593Smuzhiyun 	__be16 data_size;
23*4882a593Smuzhiyun 
24*4882a593Smuzhiyun 	/*
25*4882a593Smuzhiyun 	 * byte offset within the perf domain to read from. must be 8 byte
26*4882a593Smuzhiyun 	 * aligned
27*4882a593Smuzhiyun 	 */
28*4882a593Smuzhiyun 	__be32 data_offset;
29*4882a593Smuzhiyun 
30*4882a593Smuzhiyun 	/*
31*4882a593Smuzhiyun 	 * only valid for VIRTUAL_PROCESSOR domains, ignored for others.
32*4882a593Smuzhiyun 	 * -1 means "current partition only"
33*4882a593Smuzhiyun 	 *  Enabling via phyp/hmc required for non-"-1" values. 0 forbidden
34*4882a593Smuzhiyun 	 *  unless requestor is 0.
35*4882a593Smuzhiyun 	 */
36*4882a593Smuzhiyun 	__be16 starting_lpar_ix;
37*4882a593Smuzhiyun 
38*4882a593Smuzhiyun 	/*
39*4882a593Smuzhiyun 	 * Ignored when @starting_lpar_ix == -1
40*4882a593Smuzhiyun 	 * Ignored when @performance_domain is not VIRTUAL_PROCESSOR_*
41*4882a593Smuzhiyun 	 * -1 means "infinite" or all
42*4882a593Smuzhiyun 	 */
43*4882a593Smuzhiyun 	__be16 max_num_lpars;
44*4882a593Smuzhiyun 
45*4882a593Smuzhiyun 	/* chip, core, or virtual processor based on @performance_domain */
46*4882a593Smuzhiyun 	__be16 starting_ix;
47*4882a593Smuzhiyun 	__be16 max_ix;
48*4882a593Smuzhiyun 
49*4882a593Smuzhiyun 	/* The following fields were added in v2 of the 24x7 interface. */
50*4882a593Smuzhiyun 
51*4882a593Smuzhiyun 	__u8 starting_thread_group_ix;
52*4882a593Smuzhiyun 
53*4882a593Smuzhiyun 	/* -1 means all thread groups starting at @starting_thread_group_ix */
54*4882a593Smuzhiyun 	__u8 max_num_thread_groups;
55*4882a593Smuzhiyun 
56*4882a593Smuzhiyun 	__u8 reserved2[0xE];
57*4882a593Smuzhiyun } __packed;
58*4882a593Smuzhiyun 
59*4882a593Smuzhiyun struct hv_24x7_request_buffer {
60*4882a593Smuzhiyun 	/* 0 - ? */
61*4882a593Smuzhiyun 	/* 1 - ? */
62*4882a593Smuzhiyun 	__u8 interface_version;
63*4882a593Smuzhiyun 	__u8 num_requests;
64*4882a593Smuzhiyun 	__u8 reserved[0xE];
65*4882a593Smuzhiyun 	struct hv_24x7_request requests[];
66*4882a593Smuzhiyun } __packed;
67*4882a593Smuzhiyun 
68*4882a593Smuzhiyun struct hv_24x7_result_element_v1 {
69*4882a593Smuzhiyun 	__be16 lpar_ix;
70*4882a593Smuzhiyun 
71*4882a593Smuzhiyun 	/*
72*4882a593Smuzhiyun 	 * represents the core, chip, or virtual processor based on the
73*4882a593Smuzhiyun 	 * request's @performance_domain
74*4882a593Smuzhiyun 	 */
75*4882a593Smuzhiyun 	__be16 domain_ix;
76*4882a593Smuzhiyun 
77*4882a593Smuzhiyun 	/* -1 if @performance_domain does not refer to a virtual processor */
78*4882a593Smuzhiyun 	__be32 lpar_cfg_instance_id;
79*4882a593Smuzhiyun 
80*4882a593Smuzhiyun 	/* size = @result_element_data_size of containing result. */
81*4882a593Smuzhiyun 	__u64 element_data[];
82*4882a593Smuzhiyun } __packed;
83*4882a593Smuzhiyun 
84*4882a593Smuzhiyun /*
85*4882a593Smuzhiyun  * We need a separate struct for v2 because the offset of @element_data changed
86*4882a593Smuzhiyun  * between versions.
87*4882a593Smuzhiyun  */
88*4882a593Smuzhiyun struct hv_24x7_result_element_v2 {
89*4882a593Smuzhiyun 	__be16 lpar_ix;
90*4882a593Smuzhiyun 
91*4882a593Smuzhiyun 	/*
92*4882a593Smuzhiyun 	 * represents the core, chip, or virtual processor based on the
93*4882a593Smuzhiyun 	 * request's @performance_domain
94*4882a593Smuzhiyun 	 */
95*4882a593Smuzhiyun 	__be16 domain_ix;
96*4882a593Smuzhiyun 
97*4882a593Smuzhiyun 	/* -1 if @performance_domain does not refer to a virtual processor */
98*4882a593Smuzhiyun 	__be32 lpar_cfg_instance_id;
99*4882a593Smuzhiyun 
100*4882a593Smuzhiyun 	__u8 thread_group_ix;
101*4882a593Smuzhiyun 
102*4882a593Smuzhiyun 	__u8 reserved[7];
103*4882a593Smuzhiyun 
104*4882a593Smuzhiyun 	/* size = @result_element_data_size of containing result. */
105*4882a593Smuzhiyun 	__u64 element_data[];
106*4882a593Smuzhiyun } __packed;
107*4882a593Smuzhiyun 
108*4882a593Smuzhiyun struct hv_24x7_result {
109*4882a593Smuzhiyun 	/*
110*4882a593Smuzhiyun 	 * The index of the 24x7 Request Structure in the 24x7 Request Buffer
111*4882a593Smuzhiyun 	 * used to request this result.
112*4882a593Smuzhiyun 	 */
113*4882a593Smuzhiyun 	__u8 result_ix;
114*4882a593Smuzhiyun 
115*4882a593Smuzhiyun 	/*
116*4882a593Smuzhiyun 	 * 0 = not all result elements fit into the buffer, additional requests
117*4882a593Smuzhiyun 	 *     required
118*4882a593Smuzhiyun 	 * 1 = all result elements were returned
119*4882a593Smuzhiyun 	 */
120*4882a593Smuzhiyun 	__u8 results_complete;
121*4882a593Smuzhiyun 	__be16 num_elements_returned;
122*4882a593Smuzhiyun 
123*4882a593Smuzhiyun 	/*
124*4882a593Smuzhiyun 	 * This is a copy of @data_size from the corresponding hv_24x7_request
125*4882a593Smuzhiyun 	 *
126*4882a593Smuzhiyun 	 * Warning: to obtain the size of each element in @elements you have
127*4882a593Smuzhiyun 	 * to add the size of the other members of the result_element struct.
128*4882a593Smuzhiyun 	 */
129*4882a593Smuzhiyun 	__be16 result_element_data_size;
130*4882a593Smuzhiyun 	__u8 reserved[0x2];
131*4882a593Smuzhiyun 
132*4882a593Smuzhiyun 	/*
133*4882a593Smuzhiyun 	 * Either
134*4882a593Smuzhiyun 	 *	struct hv_24x7_result_element_v1[@num_elements_returned]
135*4882a593Smuzhiyun 	 * or
136*4882a593Smuzhiyun 	 *	struct hv_24x7_result_element_v2[@num_elements_returned]
137*4882a593Smuzhiyun 	 *
138*4882a593Smuzhiyun 	 * depending on the interface_version field of the
139*4882a593Smuzhiyun 	 * struct hv_24x7_data_result_buffer containing this result.
140*4882a593Smuzhiyun 	 */
141*4882a593Smuzhiyun 	char elements[];
142*4882a593Smuzhiyun } __packed;
143*4882a593Smuzhiyun 
144*4882a593Smuzhiyun struct hv_24x7_data_result_buffer {
145*4882a593Smuzhiyun 	/* See versioning for request buffer */
146*4882a593Smuzhiyun 	__u8 interface_version;
147*4882a593Smuzhiyun 
148*4882a593Smuzhiyun 	__u8 num_results;
149*4882a593Smuzhiyun 	__u8 reserved[0x1];
150*4882a593Smuzhiyun 	__u8 failing_request_ix;
151*4882a593Smuzhiyun 	__be32 detailed_rc;
152*4882a593Smuzhiyun 	__be64 cec_cfg_instance_id;
153*4882a593Smuzhiyun 	__be64 catalog_version_num;
154*4882a593Smuzhiyun 	__u8 reserved2[0x8];
155*4882a593Smuzhiyun 	/* WARNING: only valid for the first result due to variable sizes of
156*4882a593Smuzhiyun 	 *	    results */
157*4882a593Smuzhiyun 	struct hv_24x7_result results[]; /* [@num_results] */
158*4882a593Smuzhiyun } __packed;
159*4882a593Smuzhiyun 
160*4882a593Smuzhiyun #endif
161