More general solution to api support hwmon mapping

This solution takes into account that some hwmons use
label files to map sensor types. The previous solution
did not take this into account.

Change-Id: I1d6204573cefa8197b2cfe0ffb412b545df3d80a
This commit is contained in:
Chris Freehill
2020-03-14 15:09:11 -05:00
förälder 1d8e16bff2
incheckning 324c0ca0e5
7 ändrade filer med 96 tillägg och 39 borttagningar
+2 -1
Visa fil
@@ -326,7 +326,8 @@ typedef enum {
//!< temperature
RSMI_TEMP_TYPE_MEMORY, //!< VRAM temperature
RSMI_TEMP_TYPE_LAST = RSMI_TEMP_TYPE_MEMORY
RSMI_TEMP_TYPE_LAST = RSMI_TEMP_TYPE_MEMORY,
RSMI_TEMP_TYPE_INVALID = 0xFFFFFFFF //!< Invalid type
} rsmi_temperature_type_t;
/**
+4
Visa fil
@@ -93,6 +93,10 @@ struct RocmSMI_env_vars {
const char *path_power_root_override;
};
// Use this bit offset to store the label-mapped file index
#define MONITOR_TYPE_BIT_POSITION 16
#define MONITOR_IND_BIT_MASK ((1 << MONITOR_TYPE_BIT_POSITION) - 1)
// Support information data structures
typedef std::vector<uint64_t> SubVariant;
typedef SubVariant::const_iterator SubVariantIt;
+11 -1
Visa fil
@@ -93,7 +93,8 @@ class Monitor {
int readMonitor(MonitorTypes type, uint32_t sensor_ind, std::string *val);
int writeMonitor(MonitorTypes type, uint32_t sensor_ind, std::string val);
uint32_t setSensorLabelMap(void);
uint32_t getSensorIndex(rsmi_temperature_type_t type);
uint32_t getTempSensorIndex(rsmi_temperature_type_t type);
rsmi_temperature_type_t getTempSensorEnum(uint64_t ind);
void fillSupportedFuncs(SupportedFuncMap *supported_funcs);
private:
@@ -101,6 +102,15 @@ class Monitor {
std::string path_;
const RocmSMI_env_vars *env_;
std::map<rsmi_temperature_type_t, uint32_t> temp_type_index_map_;
// This map uses a 64b index instead of 32b (unlike temp_type_index_map_)
// for flexibility and simplicity. Currently, some parts of the
// implementation store both the RSMI api index and the file index into a
// single value. 32 bits is enough to store both, but we are using 64
// bits for simpler integration with existing implementation, which uses
// a 64b value. Also, if we need to encode anything else, 64b will give
// us more room to do so, without excessive changes.
std::map<uint64_t, rsmi_temperature_type_t> index_temp_type_map_;
};
} // namespace smi