1 /* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */
9 struct perf_thread_map;
14 * As described in Documentation/hwmon/sysfs-interface.rst hwmon events are
15 * defined over multiple files of the form <type><num>_<item>. This enum
16 * captures potential <type> values.
18 * This enum is exposed for testing.
40 * Similar to enum hwmon_type but describes the item part of a a sysfs filename.
42 * This enum is exposed for testing.
49 HWMON_ITEM_AUTO_CHANNELS_TEMP,
51 HWMON_ITEM_AVERAGE_HIGHEST,
52 HWMON_ITEM_AVERAGE_INTERVAL,
53 HWMON_ITEM_AVERAGE_INTERVAL_MAX,
54 HWMON_ITEM_AVERAGE_INTERVAL_MIN,
55 HWMON_ITEM_AVERAGE_LOWEST,
56 HWMON_ITEM_AVERAGE_MAX,
57 HWMON_ITEM_AVERAGE_MIN,
67 HWMON_ITEM_EMERGENCY_HIST,
75 HWMON_ITEM_LCRIT_HYST,
86 HWMON_ITEM_RESET_HISTORY,
94 bool perf_pmu__is_hwmon(const struct perf_pmu *pmu);
95 bool evsel__is_hwmon(const struct evsel *evsel);
98 * parse_hwmon_filename() - Parse filename into constituent parts.
100 * @filename: To be parsed, of the form <type><number>_<item>.
101 * @type: The type defined from the parsed file name.
102 * @number: The number of the type, for example there may be more than 1 fan.
103 * @item: A hwmon <type><number> may have multiple associated items.
104 * @alarm: Is the filename for an alarm value?
106 * An example of a hwmon filename is "temp1_input". The type is temp for a
107 * temperature value. The number is 1. The item within the file is an input
108 * value - the temperature itself. This file doesn't contain an alarm value.
110 * Exposed for testing.
112 bool parse_hwmon_filename(const char *filename,
113 enum hwmon_type *type,
115 enum hwmon_item *item,
119 * hwmon_pmu__new() - Allocate and construct a hwmon PMU.
121 * @pmus: The list of PMUs to be added to.
122 * @hwmon_dir: An O_DIRECTORY file descriptor for a hwmon directory.
123 * @sysfs_name: Name of the hwmon sysfs directory like hwmon0.
124 * @name: The contents of the "name" file in the hwmon directory.
126 * Exposed for testing. Regular construction should happen via
127 * perf_pmus__read_hwmon_pmus.
129 struct perf_pmu *hwmon_pmu__new(struct list_head *pmus, int hwmon_dir,
130 const char *sysfs_name, const char *name);
131 void hwmon_pmu__exit(struct perf_pmu *pmu);
133 int hwmon_pmu__for_each_event(struct perf_pmu *pmu, void *state, pmu_event_callback cb);
134 size_t hwmon_pmu__num_events(struct perf_pmu *pmu);
135 bool hwmon_pmu__have_event(struct perf_pmu *pmu, const char *name);
136 int hwmon_pmu__config_terms(const struct perf_pmu *pmu,
137 struct perf_event_attr *attr,
138 struct parse_events_terms *terms,
139 struct parse_events_error *err);
140 int hwmon_pmu__check_alias(struct parse_events_terms *terms, struct perf_pmu_info *info,
141 struct parse_events_error *err);
143 int perf_pmus__read_hwmon_pmus(struct list_head *pmus);
146 int evsel__hwmon_pmu_open(struct evsel *evsel,
147 struct perf_thread_map *threads,
148 int start_cpu_map_idx, int end_cpu_map_idx);
149 int evsel__hwmon_pmu_read(struct evsel *evsel, int cpu_map_idx, int thread);
151 #endif /* __HWMON_PMU_H */