Skip to content

Commit

Permalink
xfpga: metrics: fix check for metric limits
Browse files Browse the repository at this point in the history
The DFL_* metric constants are lower case and intended to be compared
against the sysfs path of a metric, not its mixed case label. Add a
default branch that ensures these checks are in fact carried out.

Signed-off-by: Peter Colberg <peter.colberg@intel.com>
  • Loading branch information
pcolberg committed May 22, 2024
1 parent 4415105 commit 72e291b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions libraries/plugins/xfpga/metrics/metrics_max10.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,26 +387,29 @@ fpga_result read_max10_value(struct _fpga_enum_metric *_fpga_enum_metric,
*dvalue = ((double)value / MILLI);

// Check for limits
if (strstr(_fpga_enum_metric->metric_name, DFL_POWER)) {
if (strstr(_fpga_enum_metric->metric_sysfs, DFL_POWER)) {

if (*dvalue < POWER_LOW_LIMIT || *dvalue > POWER_HIGH_LIMIT)
result = FPGA_EXCEPTION;

} else if (strstr(_fpga_enum_metric->metric_name, DFL_VOLTAGE)) {
} else if (strstr(_fpga_enum_metric->metric_sysfs, DFL_VOLTAGE)) {

if (*dvalue < VOLTAMP_LOW_LIMIT || *dvalue > VOLTAMP_HIGH_LIMIT)
result = FPGA_EXCEPTION;

} else if (strstr(_fpga_enum_metric->metric_name, DFL_CURRENT)) {
} else if (strstr(_fpga_enum_metric->metric_sysfs, DFL_CURRENT)) {

if (*dvalue < VOLTAMP_LOW_LIMIT || *dvalue > VOLTAMP_HIGH_LIMIT)
result = FPGA_EXCEPTION;

} else if (strstr(_fpga_enum_metric->metric_name, DFL_TEMPERATURE)) {
} else if (strstr(_fpga_enum_metric->metric_sysfs, DFL_TEMPERATURE)) {

if (*dvalue < THERMAL_LOW_LIMIT || *dvalue > THERMAL_HIGH_LIMIT)
result = FPGA_EXCEPTION;

} else {
OPAE_ERR("Unknown metric: %s", _fpga_enum_metric->metric_sysfs);
result = FPGA_EXCEPTION;
}

return result;
Expand Down

0 comments on commit 72e291b

Please sign in to comment.