geopm  3.1.1.dev272+gdfb40a8d
GEOPM - Global Extensible Open Power Manager
DrmSysfsDriver.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 - 2024 Intel Corporation
3  * SPDX-License-Identifier: BSD-3-Clause
4  */
5 
6 #ifndef DRMSYSFSDRIVER_HPP_INCLUDE
7 #define DRMSYSFSDRIVER_HPP_INCLUDE
8 
9 #include <map>
10 #include <vector>
11 
12 #include "geopm_topo.h"
13 
14 #include "DrmGpuTopo.hpp"
15 #include "SysfsDriver.hpp"
16 
17 namespace geopm
18 {
19  class IOGroup;
20  class PlatformTopo;
21 
24  {
25  public:
26  DrmSysfsDriver() = delete;
27  DrmSysfsDriver(const std::string &drm_directory,
28  const std::string &driver_signal_prefix);
29  virtual ~DrmSysfsDriver() = default;
30  int domain_type(const std::string &name) const override;
31  std::string attribute_path(const std::string &name,
32  int domain_idx) override;
33  std::function<double(const std::string&)> signal_parse(const std::string &signal_name) const override;
34  std::function<std::string(double)> control_gen(const std::string &control_name) const override;
35  std::string driver(void) const override;
36  std::map<std::string, SysfsDriver::properties_s> properties(void) const override;
37 
38  static std::string plugin_name_drm(void);
39  static std::unique_ptr<IOGroup> make_plugin_drm(void);
40 
41  static std::string plugin_name_accel(void);
42  static std::unique_ptr<IOGroup> make_plugin_accel(void);
43  private:
44  DrmGpuTopo m_drm_topo;
45  // Prefix to use at the start of signal names exported by this SysfsDriver
46  // E.g., "DRM" or "ACCEL"
47  const std::string M_DRIVER_SIGNAL_PREFIX;
48  // Map of signal names to sysfs signal properties
49  const std::map<std::string, SysfsDriver::properties_s> M_PROPERTIES;
50  // Map of (GEOPM signal domain, GEOPM signal index) pairs to hwmon sysfs directory paths symlinked via drm paths
51  const std::map<std::pair<geopm_domain_e, int>, std::string> M_DRM_HWMON_DIR_BY_GEOPM_DOMAIN;
52  };
53 }
54 
55 #endif
Definition: DrmGpuTopo.hpp:18
Class used to implement the DrmSysfsDriverGroup.
Definition: DrmSysfsDriver.hpp:24
std::function< double(const std::string &)> signal_parse(const std::string &signal_name) const override
Get function to convert contents of sysfs file into signal.
Definition: DrmSysfsDriver.cpp:165
static std::unique_ptr< IOGroup > make_plugin_drm(void)
Definition: DrmSysfsDriver.cpp:214
static std::unique_ptr< IOGroup > make_plugin_accel(void)
Definition: DrmSysfsDriver.cpp:224
std::string attribute_path(const std::string &name, int domain_idx) override
Get the path to the sysfs entry for signal.
Definition: DrmSysfsDriver.cpp:135
static std::string plugin_name_accel(void)
Definition: DrmSysfsDriver.cpp:219
std::function< std::string(double)> control_gen(const std::string &control_name) const override
Get a function to convert a control into a sysfs string.
Definition: DrmSysfsDriver.cpp:186
int domain_type(const std::string &name) const override
Get the PlatformTopo domain type for an named attribute.
Definition: DrmSysfsDriver.cpp:123
virtual ~DrmSysfsDriver()=default
std::string driver(void) const override
Definition: DrmSysfsDriver.cpp:199
std::map< std::string, SysfsDriver::properties_s > properties(void) const override
Query the meta data about a signal or control.
Definition: DrmSysfsDriver.cpp:204
static std::string plugin_name_drm(void)
Definition: DrmSysfsDriver.cpp:209
Class used to implement the SysfsIOGroup base class.
Definition: SysfsDriver.hpp:23
Definition: Agg.cpp:20