|
Packit |
534379 |
// Copyright(c) 2018-2020, Intel Corporation
|
|
Packit |
534379 |
//
|
|
Packit |
534379 |
// Redistribution and use in source and binary forms, with or without
|
|
Packit |
534379 |
// modification, are permitted provided that the following conditions are met:
|
|
Packit |
534379 |
//
|
|
Packit |
534379 |
// * Redistributions of source code must retain the above copyright notice,
|
|
Packit |
534379 |
// this list of conditions and the following disclaimer.
|
|
Packit |
534379 |
// * Redistributions in binary form must reproduce the above copyright notice,
|
|
Packit |
534379 |
// this list of conditions and the following disclaimer in the documentation
|
|
Packit |
534379 |
// and/or other materials provided with the distribution.
|
|
Packit |
534379 |
// * Neither the name of Intel Corporation nor the names of its contributors
|
|
Packit |
534379 |
// may be used to endorse or promote products derived from this software
|
|
Packit |
534379 |
// without specific prior written permission.
|
|
Packit |
534379 |
//
|
|
Packit |
534379 |
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
Packit |
534379 |
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
Packit |
534379 |
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
Packit |
534379 |
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
Packit |
534379 |
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
Packit |
534379 |
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
Packit |
534379 |
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
Packit |
534379 |
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
Packit |
534379 |
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
Packit |
534379 |
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
Packit |
534379 |
// POSSIBILITY OF SUCH DAMAGE.
|
|
Packit |
534379 |
|
|
Packit |
534379 |
/**
|
|
Packit |
534379 |
* \file metrics_int.h
|
|
Packit |
534379 |
* \brief fpga metrics utils functions
|
|
Packit |
534379 |
*/
|
|
Packit |
534379 |
|
|
Packit |
534379 |
#ifndef __FPGA_METRICS_INT_H__
|
|
Packit |
534379 |
#define __FPGA_METRICS_INT_H__
|
|
Packit |
534379 |
|
|
Packit |
534379 |
#include "vector.h"
|
|
Packit |
534379 |
#include "opae/metrics.h"
|
|
Packit |
534379 |
#include "metrics_metadata.h"
|
|
Packit |
534379 |
#include "metrics/bmc/bmc.h"
|
|
Packit |
534379 |
#include "types_int.h"
|
|
Packit |
534379 |
// Power,Thermal & Performance definations
|
|
Packit |
534379 |
|
|
Packit |
534379 |
#define PERF "*perf"
|
|
Packit |
534379 |
|
|
Packit |
534379 |
|
|
Packit |
534379 |
#define PWRMGMT "power_mgmt"
|
|
Packit |
534379 |
#define THERLGMT "thermal_mgmt"
|
|
Packit |
534379 |
#define REVISION "revision"
|
|
Packit |
534379 |
#define PERF_FREEZE "freeze"
|
|
Packit |
534379 |
#define PERF_ENABLE "enable"
|
|
Packit |
534379 |
#define PERF_CACHE "cache"
|
|
Packit |
534379 |
#define PERF_FABRIC "fabric"
|
|
Packit |
534379 |
#define PERF_IOMMU "iommu"
|
|
Packit |
534379 |
#define PERFORMANCE "performance"
|
|
Packit |
534379 |
#define FPGA_LIMIT "fpga_limit"
|
|
Packit |
534379 |
#define XEON_LIMIT "xeon_limit"
|
|
Packit |
534379 |
#define TEMP "Centigrade"
|
|
Packit |
534379 |
|
|
Packit |
534379 |
#define TEMPERATURE "Temperature"
|
|
Packit |
534379 |
#define VOLTAGE "Voltage"
|
|
Packit |
534379 |
#define CURRENT "Current"
|
|
Packit |
534379 |
#define POWER "Power"
|
|
Packit |
534379 |
#define CLOCK "Clock"
|
|
Packit |
534379 |
|
|
Packit |
534379 |
|
|
Packit |
534379 |
#define TEMPERATURE_UNITS "Celsius"
|
|
Packit |
534379 |
#define VOLTAGE_UNITS "Volts"
|
|
Packit |
534379 |
#define CURRENT_UNITS "Amps"
|
|
Packit |
534379 |
#define POWER_UNITS "Watts"
|
|
Packit |
534379 |
#define CLOCK_UNITS "Hz"
|
|
Packit |
534379 |
|
|
Packit |
534379 |
#define MAX10_SYSFS_PATH "spi-*/spi_master/spi*/spi*.*"
|
|
Packit |
534379 |
#define MAX10_SENSOR_SYSFS_PATH "spi-*/spi_master/spi*/spi*.*/sensor*"
|
|
Packit |
534379 |
|
|
Packit |
534379 |
#define SENSOR_SYSFS_NAME "name"
|
|
Packit |
534379 |
#define SENSOR_SYSFS_TYPE "type"
|
|
Packit |
534379 |
#define SENSOR_SYSFS_ID "id"
|
|
Packit |
534379 |
#define SENSOR_SYSFS_VALUE "value"
|
|
Packit |
534379 |
#define MILLI 1000
|
|
Packit |
534379 |
|
|
Packit |
534379 |
#define FPGA_DISCRETE_VC_DEVICEID 0x0B30
|
|
Packit |
534379 |
|
|
Packit |
534379 |
#define FPGA_DISCRETE_DC_DEVICEID 0x0B2B
|
|
Packit |
534379 |
|
|
Packit |
534379 |
#define BMC_LIB "libmodbmc.so"
|
|
Packit |
534379 |
|
|
Packit |
534379 |
// AFU DFH Struct
|
|
Packit |
534379 |
struct DFH {
|
|
Packit |
534379 |
union {
|
|
Packit |
534379 |
uint64_t csr;
|
|
Packit |
534379 |
struct {
|
|
Packit |
534379 |
uint64_t id:12;
|
|
Packit |
534379 |
uint64_t revision:4;
|
|
Packit |
534379 |
uint64_t next_header_offset:24;
|
|
Packit |
534379 |
uint64_t eol:1;
|
|
Packit |
534379 |
uint64_t reserved:19;
|
|
Packit |
534379 |
uint64_t type:4;
|
|
Packit |
534379 |
};
|
|
Packit |
534379 |
};
|
|
Packit |
534379 |
};
|
|
Packit |
534379 |
|
|
Packit |
534379 |
struct NEXT_AFU {
|
|
Packit |
534379 |
union {
|
|
Packit |
534379 |
uint64_t csr;
|
|
Packit |
534379 |
struct {
|
|
Packit |
534379 |
uint32_t next_afu:24;
|
|
Packit |
534379 |
uint64_t reserved:40;
|
|
Packit |
534379 |
};
|
|
Packit |
534379 |
};
|
|
Packit |
534379 |
};
|
|
Packit |
534379 |
|
|
Packit |
534379 |
typedef struct {
|
|
Packit |
534379 |
struct DFH dfh;
|
|
Packit |
534379 |
uint64_t guid[2];
|
|
Packit |
534379 |
struct NEXT_AFU next_afu;
|
|
Packit |
534379 |
} feature_definition;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
// metric group csr
|
|
Packit |
534379 |
struct metric_bbb_group {
|
|
Packit |
534379 |
union {
|
|
Packit |
534379 |
uint64_t csr;
|
|
Packit |
534379 |
struct {
|
|
Packit |
534379 |
uint64_t reserved:28;
|
|
Packit |
534379 |
uint64_t units:8;
|
|
Packit |
534379 |
uint64_t group_id:8;
|
|
Packit |
534379 |
uint64_t eol:1;
|
|
Packit |
534379 |
uint64_t next_group_offset:16;
|
|
Packit |
534379 |
uint64_t reset:1;
|
|
Packit |
534379 |
uint64_t reset_access:2;
|
|
Packit |
534379 |
};
|
|
Packit |
534379 |
};
|
|
Packit |
534379 |
};
|
|
Packit |
534379 |
|
|
Packit |
534379 |
// metric value csr
|
|
Packit |
534379 |
struct metric_bbb_value {
|
|
Packit |
534379 |
union {
|
|
Packit |
534379 |
uint64_t csr;
|
|
Packit |
534379 |
struct {
|
|
Packit |
534379 |
uint64_t reserved:7;
|
|
Packit |
534379 |
uint64_t eol:1;
|
|
Packit |
534379 |
uint64_t counter_id:8;
|
|
Packit |
534379 |
uint64_t value:48;
|
|
Packit |
534379 |
};
|
|
Packit |
534379 |
};
|
|
Packit |
534379 |
};
|
|
Packit |
534379 |
|
|
Packit |
534379 |
// Metrics utils functions
|
|
Packit |
534379 |
fpga_result metric_sysfs_path_is_file(const char *path);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result metric_sysfs_path_is_dir(const char *path);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result add_metric_vector(fpga_metric_vector *vector,
|
|
Packit |
534379 |
uint64_t metric_id,
|
|
Packit |
534379 |
const char *qualifier_name,
|
|
Packit |
534379 |
const char *group_name,
|
|
Packit |
534379 |
const char *group_sysfs,
|
|
Packit |
534379 |
const char *metric_name,
|
|
Packit |
534379 |
const char *metric_sysfs,
|
|
Packit |
534379 |
const char *metric_units,
|
|
Packit |
534379 |
enum fpga_metric_datatype metric_datatype,
|
|
Packit |
534379 |
enum fpga_metric_type metric_type,
|
|
Packit |
534379 |
enum fpga_hw_type hw_type,
|
|
Packit |
534379 |
uint64_t mmio_offset);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result enum_thermalmgmt_metrics(fpga_metric_vector *vector,
|
|
Packit |
534379 |
uint64_t *metric_id,
|
|
Packit |
534379 |
const char *sysfspath,
|
|
Packit |
534379 |
enum fpga_hw_type hw_type);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result enum_powermgmt_metrics(fpga_metric_vector *vector,
|
|
Packit |
534379 |
uint64_t *metric_id,
|
|
Packit |
534379 |
const char *sysfspath,
|
|
Packit |
534379 |
enum fpga_hw_type hw_type);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result enum_perf_counter_items(fpga_metric_vector *vector,
|
|
Packit |
534379 |
uint64_t *metric_id,
|
|
Packit |
534379 |
const char *qualifier_name,
|
|
Packit |
534379 |
const char *sysfspath,
|
|
Packit |
534379 |
const char *sysfs_name,
|
|
Packit |
534379 |
enum fpga_metric_type metric_type,
|
|
Packit |
534379 |
enum fpga_hw_type hw_type);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result enum_perf_counter_metrics(fpga_metric_vector *vector,
|
|
Packit |
534379 |
uint64_t *metric_id,
|
|
Packit |
534379 |
const char *sysfspath,
|
|
Packit |
534379 |
enum fpga_hw_type hw_type);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result enum_fpga_metrics(fpga_handle handle);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result get_fme_metric_value(fpga_handle handle,
|
|
Packit |
534379 |
fpga_metric_vector *enum_vector,
|
|
Packit |
534379 |
uint64_t metric_id,
|
|
Packit |
534379 |
struct fpga_metric *fpga_metric);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result add_metric_info(struct _fpga_enum_metric *_enum_metrics,
|
|
Packit |
534379 |
struct fpga_metric_info *fpga_metric_info);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result free_fpga_enum_metrics_vector(struct _fpga_handle *_handle);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result parse_metric_num_name(const char *search_string,
|
|
Packit |
534379 |
fpga_metric_vector *fpga_enum_metrics_vector,
|
|
Packit |
534379 |
uint64_t *metric_num);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result enum_bmc_metrics_info(struct _fpga_handle *_handle,
|
|
Packit |
534379 |
fpga_metric_vector *vector,
|
|
Packit |
534379 |
uint64_t *metric_id,
|
|
Packit |
534379 |
enum fpga_hw_type hw_type);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result get_fpga_object_type(fpga_handle handle, fpga_objtype *objtype);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result get_pwr_thermal_value(const char *sysfs_path, uint64_t *value);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result clear_cached_values(fpga_handle handle);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result get_performance_counter_value(const char *group_sysfs,
|
|
Packit |
534379 |
const char *metric_sysfs,
|
|
Packit |
534379 |
uint64_t *value);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result get_bmc_metrics_values(fpga_handle handle,
|
|
Packit |
534379 |
struct _fpga_enum_metric *_fpga_enum_metric,
|
|
Packit |
534379 |
struct fpga_metric *fpga_metric);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
// AFU Metric
|
|
Packit |
534379 |
fpga_result enum_afu_metrics(fpga_handle handle,
|
|
Packit |
534379 |
fpga_metric_vector *vector,
|
|
Packit |
534379 |
uint64_t *metric_id,
|
|
Packit |
534379 |
uint64_t metrics_offset);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result get_afu_metric_value(fpga_handle handle,
|
|
Packit |
534379 |
fpga_metric_vector *enum_vector,
|
|
Packit |
534379 |
uint64_t metric_num,
|
|
Packit |
534379 |
struct fpga_metric *fpga_metric);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result add_afu_metrics_vector(fpga_metric_vector *vector,
|
|
Packit |
534379 |
uint64_t *metric_id,
|
|
Packit |
534379 |
uint64_t group_value,
|
|
Packit |
534379 |
uint64_t metric_value,
|
|
Packit |
534379 |
uint64_t metric_offset);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result discover_afu_metrics_feature(fpga_handle handle, uint64_t *offset);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result get_metric_data_info(const char *group_name,
|
|
Packit |
534379 |
const char *metric_name,
|
|
Packit |
534379 |
fpga_metric_metadata *metric_data_search,
|
|
Packit |
534379 |
uint64_t size,
|
|
Packit |
534379 |
fpga_metric_metadata *metric_data);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result xfpga_bmcLoadSDRs(struct _fpga_handle *_handle,
|
|
Packit |
534379 |
bmc_sdr_handle *records,
|
|
Packit |
534379 |
uint32_t *num_sensors);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result xfpga_bmcDestroySDRs(struct _fpga_handle *_handle,
|
|
Packit |
534379 |
bmc_sdr_handle *records);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result xfpga_bmcReadSensorValues(struct _fpga_handle *_handle,
|
|
Packit |
534379 |
bmc_sdr_handle records,
|
|
Packit |
534379 |
bmc_values_handle *values,
|
|
Packit |
534379 |
uint32_t *num_values);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result xfpga_bmcDestroySensorValues(struct _fpga_handle *_handle,
|
|
Packit |
534379 |
bmc_values_handle *values);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result xfpga_bmcGetSensorReading(struct _fpga_handle *_handle,
|
|
Packit |
534379 |
bmc_values_handle values,
|
|
Packit |
534379 |
uint32_t sensor_number,
|
|
Packit |
534379 |
uint32_t *is_valid,
|
|
Packit |
534379 |
double *value);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result xfpga_bmcGetSDRDetails(struct _fpga_handle *_handle,
|
|
Packit |
534379 |
bmc_values_handle values,
|
|
Packit |
534379 |
uint32_t sensor_number,
|
|
Packit |
534379 |
sdr_details *details);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
void *metrics_load_bmc_lib(void);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
#endif // __FPGA_METRICS_INT_H__
|