// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) #include "counts.h" #include "debug.h" #include "evsel.h" #include "hashmap.h" #include "hwmon_pmu.h" #include "pmu.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /** Strings that correspond to enum hwmon_type. */ static const char * const hwmon_type_strs[HWMON_TYPE_MAX] = { NULL, "cpu", "curr", "energy", "fan", "humidity", "in", "intrusion", "power", "pwm", "temp", }; #define LONGEST_HWMON_TYPE_STR "intrusion" /** Strings that correspond to enum hwmon_item. */ static const char * const hwmon_item_strs[HWMON_ITEM__MAX] = { NULL, "accuracy", "alarm", "auto_channels_temp", "average", "average_highest", "average_interval", "average_interval_max", "average_interval_min", "average_lowest", "average_max", "average_min", "beep", "cap", "cap_hyst", "cap_max", "cap_min", "crit", "crit_hyst", "div", "emergency", "emergency_hist", "enable", "fault", "freq", "highest", "input", "label", "lcrit", "lcrit_hyst", "lowest", "max", "max_hyst", "min", "min_hyst", "mod", "offset", "pulses", "rated_max", "rated_min", "reset_history", "target", "type", "vid", }; #define LONGEST_HWMON_ITEM_STR "average_interval_max" static const char *const hwmon_units[HWMON_TYPE_MAX] = { NULL, "V", /* cpu */ "A", /* curr */ "J", /* energy */ "rpm", /* fan */ "%", /* humidity */ "V", /* in */ "", /* intrusion */ "W", /* power */ "Hz", /* pwm */ "'C", /* temp */ }; struct hwmon_pmu { struct perf_pmu pmu; struct hashmap events; int hwmon_dir_fd; }; /** * union hwmon_pmu_event_key: Key for hwmon_pmu->events as such each key * represents an event. * * Related hwmon files start that this key represents. */ union hwmon_pmu_event_key { long type_and_num; struct { int num :16; enum hwmon_type type :8; }; }; /** * struct hwmon_pmu_event_value: Value in hwmon_pmu->events. * * Hwmon files are of the form _ and may have a suffix * _alarm. */ struct hwmon_pmu_event_value { /** @items: which item files are present. */ DECLARE_BITMAP(items, HWMON_ITEM__MAX); /** @alarm_items: which item files are present. */ DECLARE_BITMAP(alarm_items, HWMON_ITEM__MAX); /** @label: contents of _label if present. */ char *label; /** @name: name computed from label of the form _