^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 __PERF_CONFIG_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #define __PERF_CONFIG_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <stdbool.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) struct perf_config_item {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) char *value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) bool from_system_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) struct list_head node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) struct perf_config_section {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) struct list_head items;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) bool from_system_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) struct list_head node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) struct perf_config_set {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) struct list_head sections;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) extern const char *config_exclusive_filename;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) typedef int (*config_fn_t)(const char *, const char *, void *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) int perf_config_from_file(config_fn_t fn, const char *filename, void *data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) int perf_default_config(const char *, const char *, void *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) int perf_config(config_fn_t fn, void *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) int perf_config_int(int *dest, const char *, const char *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) int perf_config_u8(u8 *dest, const char *name, const char *value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) int perf_config_u64(u64 *dest, const char *, const char *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) int perf_config_bool(const char *, const char *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) int config_error_nonbool(const char *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) const char *perf_etc_perfconfig(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) struct perf_config_set *perf_config_set__new(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) void perf_config_set__delete(struct perf_config_set *set);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) int perf_config_set__collect(struct perf_config_set *set, const char *file_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) const char *var, const char *value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) void perf_config__exit(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) void perf_config__refresh(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) * perf_config_sections__for_each - iterate thru all the sections
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) * @list: list_head instance to iterate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) * @section: struct perf_config_section iterator
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) #define perf_config_sections__for_each_entry(list, section) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) list_for_each_entry(section, list, node)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) * perf_config_items__for_each - iterate thru all the items
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) * @list: list_head instance to iterate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) * @item: struct perf_config_item iterator
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) #define perf_config_items__for_each_entry(list, item) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) list_for_each_entry(item, list, node)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) * perf_config_set__for_each - iterate thru all the config section-item pairs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) * @set: evlist instance to iterate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) * @section: struct perf_config_section iterator
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) * @item: struct perf_config_item iterator
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) #define perf_config_set__for_each_entry(set, section, item) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) perf_config_sections__for_each_entry(&set->sections, section) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) perf_config_items__for_each_entry(§ion->items, item)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) #endif /* __PERF_CONFIG_H */