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