|
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.c
|
|
Packit |
534379 |
* \brief xfpgs fpga metrics API
|
|
Packit |
534379 |
*/
|
|
Packit |
534379 |
|
|
Packit |
534379 |
#ifdef HAVE_CONFIG_H
|
|
Packit |
534379 |
#include <config.h>
|
|
Packit |
534379 |
#endif // HAVE_CONFIG_H
|
|
Packit |
534379 |
|
|
Packit |
534379 |
#include "opae/access.h"
|
|
Packit |
534379 |
#include "opae/utils.h"
|
|
Packit |
534379 |
#include "common_int.h"
|
|
Packit |
534379 |
#include "types_int.h"
|
|
Packit |
534379 |
#include "opae/metrics.h"
|
|
Packit |
534379 |
#include "metrics/vector.h"
|
|
Packit |
534379 |
#include "metrics/metrics_int.h"
|
|
Packit |
534379 |
|
|
Packit |
534379 |
//Wrong search string invalid array index
|
|
Packit |
534379 |
#define METRIC_ARRAY_INVALID_INDEX 0xFFFFFF
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result __XFPGA_API__ xfpga_fpgaGetNumMetrics(fpga_handle handle,
|
|
Packit |
534379 |
uint64_t *num_metrics)
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
fpga_result result = FPGA_OK;
|
|
Packit |
534379 |
struct _fpga_handle *_handle = (struct _fpga_handle *)handle;
|
|
Packit |
534379 |
int err = 0;
|
|
Packit |
534379 |
uint64_t num_enun_metrics = 0;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
if (_handle == NULL) {
|
|
Packit |
534379 |
OPAE_ERR("NULL fpga handle");
|
|
Packit |
534379 |
return FPGA_INVALID_PARAM;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
result = handle_check_and_lock(_handle);
|
|
Packit |
534379 |
if (result)
|
|
Packit |
534379 |
return result;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
if (_handle->fddev < 0) {
|
|
Packit |
534379 |
OPAE_ERR("Invalid handle file descriptor");
|
|
Packit |
534379 |
result = FPGA_INVALID_PARAM;
|
|
Packit |
534379 |
goto out_unlock;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
if (num_metrics == NULL) {
|
|
Packit |
534379 |
OPAE_ERR("Invalid Input parameters");
|
|
Packit |
534379 |
result = FPGA_INVALID_PARAM;
|
|
Packit |
534379 |
goto out_unlock;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
result = enum_fpga_metrics(handle);
|
|
Packit |
534379 |
if (result != FPGA_OK) {
|
|
Packit |
534379 |
OPAE_ERR("Failed to Discover Metrics");
|
|
Packit |
534379 |
result = FPGA_NOT_FOUND;
|
|
Packit |
534379 |
goto out_unlock;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
result = fpga_vector_total(&(_handle->fpga_enum_metric_vector), &num_enun_metrics);
|
|
Packit |
534379 |
if (result != FPGA_OK) {
|
|
Packit |
534379 |
OPAE_ERR("Failed to get metric total");
|
|
Packit |
534379 |
goto out_unlock;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
|
|
Packit |
534379 |
if (num_enun_metrics == 0)
|
|
Packit |
534379 |
result = FPGA_NOT_FOUND;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
*num_metrics = num_enun_metrics;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
out_unlock:
|
|
Packit |
534379 |
err = pthread_mutex_unlock(&_handle->lock);
|
|
Packit |
534379 |
if (err) {
|
|
Packit |
534379 |
OPAE_ERR("pthread_mutex_unlock() failed: %s", strerror(err));
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
return result;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result __XFPGA_API__ xfpga_fpgaGetMetricsInfo(fpga_handle handle,
|
|
Packit |
534379 |
fpga_metric_info *metric_info,
|
|
Packit |
534379 |
uint64_t *num_metrics)
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result result = FPGA_OK;
|
|
Packit |
534379 |
struct _fpga_handle *_handle = (struct _fpga_handle *)handle;
|
|
Packit |
534379 |
int err = 0;
|
|
Packit |
534379 |
uint64_t i = 0;
|
|
Packit |
534379 |
uint64_t num_enun_metrics = 0;
|
|
Packit |
534379 |
struct _fpga_enum_metric *fpga_enum_metric = NULL;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
if (_handle == NULL) {
|
|
Packit |
534379 |
OPAE_ERR("NULL fpga handle");
|
|
Packit |
534379 |
return FPGA_INVALID_PARAM;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
result = handle_check_and_lock(_handle);
|
|
Packit |
534379 |
if (result)
|
|
Packit |
534379 |
return result;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
if (_handle->fddev < 0) {
|
|
Packit |
534379 |
OPAE_ERR("Invalid handle file descriptor");
|
|
Packit |
534379 |
result = FPGA_INVALID_PARAM;
|
|
Packit |
534379 |
goto out_unlock;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
if (metric_info == NULL ||
|
|
Packit |
534379 |
num_metrics == NULL) {
|
|
Packit |
534379 |
OPAE_ERR("Invalid Input parameters");
|
|
Packit |
534379 |
result = FPGA_INVALID_PARAM;
|
|
Packit |
534379 |
goto out_unlock;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
result = enum_fpga_metrics(handle);
|
|
Packit |
534379 |
if (result != FPGA_OK) {
|
|
Packit |
534379 |
OPAE_ERR("Failed to enum Metrics");
|
|
Packit |
534379 |
result = FPGA_NOT_FOUND;
|
|
Packit |
534379 |
goto out_unlock;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
result = fpga_vector_total(&(_handle->fpga_enum_metric_vector), &num_enun_metrics);
|
|
Packit |
534379 |
if (result != FPGA_OK) {
|
|
Packit |
534379 |
OPAE_ERR("Failed to get metric total");
|
|
Packit |
534379 |
goto out_unlock;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
// get metric info
|
|
Packit |
534379 |
for (i = 0; i < *num_metrics; i++) {
|
|
Packit |
534379 |
|
|
Packit |
534379 |
if (*num_metrics <= num_enun_metrics) {
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_enum_metric = (struct _fpga_enum_metric *) fpga_vector_get(&(_handle->fpga_enum_metric_vector), i);
|
|
Packit |
534379 |
result = add_metric_info(fpga_enum_metric, &metric_info[i]);
|
|
Packit |
534379 |
if (result != FPGA_OK) {
|
|
Packit |
534379 |
OPAE_MSG("Failed to add metric info");
|
|
Packit |
534379 |
continue;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
out_unlock:
|
|
Packit |
534379 |
err = pthread_mutex_unlock(&_handle->lock);
|
|
Packit |
534379 |
if (err) {
|
|
Packit |
534379 |
OPAE_ERR("pthread_mutex_unlock() failed: %s", strerror(err));
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
return result;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result __XFPGA_API__ xfpga_fpgaGetMetricsByIndex(fpga_handle handle,
|
|
Packit |
534379 |
uint64_t *metric_num,
|
|
Packit |
534379 |
uint64_t num_metric_indexes,
|
|
Packit |
534379 |
fpga_metric *metrics)
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
fpga_result result = FPGA_OK;
|
|
Packit |
534379 |
uint64_t found = 0;
|
|
Packit |
534379 |
struct _fpga_handle *_handle = (struct _fpga_handle *)handle;
|
|
Packit |
534379 |
int err = 0;
|
|
Packit |
534379 |
uint64_t i = 0;
|
|
Packit |
534379 |
fpga_objtype objtype;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
if (_handle == NULL) {
|
|
Packit |
534379 |
OPAE_ERR("NULL fpga handle");
|
|
Packit |
534379 |
return FPGA_INVALID_PARAM;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
result = handle_check_and_lock(_handle);
|
|
Packit |
534379 |
if (result)
|
|
Packit |
534379 |
return result;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
if (_handle->fddev < 0) {
|
|
Packit |
534379 |
OPAE_ERR("Invalid handle file descriptor");
|
|
Packit |
534379 |
result = FPGA_INVALID_PARAM;
|
|
Packit |
534379 |
goto out_unlock;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
if (metrics == NULL ||
|
|
Packit |
534379 |
metric_num == NULL) {
|
|
Packit |
534379 |
OPAE_ERR("Invalid Input parameters");
|
|
Packit |
534379 |
result = FPGA_INVALID_PARAM;
|
|
Packit |
534379 |
goto out_unlock;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
result = enum_fpga_metrics(handle);
|
|
Packit |
534379 |
if (result != FPGA_OK) {
|
|
Packit |
534379 |
OPAE_ERR("Failed to Discover Metrics");
|
|
Packit |
534379 |
result = FPGA_NOT_FOUND;
|
|
Packit |
534379 |
goto out_unlock;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
result = get_fpga_object_type(handle, &objtype);
|
|
Packit |
534379 |
if (result != FPGA_OK) {
|
|
Packit |
534379 |
OPAE_ERR("Failed to init vector");
|
|
Packit |
534379 |
result = FPGA_INVALID_PARAM;
|
|
Packit |
534379 |
goto out_unlock;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
if (objtype == FPGA_ACCELERATOR) {
|
|
Packit |
534379 |
// get AFU metrics
|
|
Packit |
534379 |
for (i = 0; i < num_metric_indexes; i++) {
|
|
Packit |
534379 |
|
|
Packit |
534379 |
result = get_afu_metric_value(handle,
|
|
Packit |
534379 |
&(_handle->fpga_enum_metric_vector),
|
|
Packit |
534379 |
metric_num[i],
|
|
Packit |
534379 |
&metrics[i]);
|
|
Packit |
534379 |
if (result != FPGA_OK) {
|
|
Packit |
534379 |
OPAE_MSG("Failed to get metric value at Index = %ld", metric_num[i]);
|
|
Packit |
534379 |
metrics[i].metric_num = metric_num[i];
|
|
Packit |
534379 |
continue;
|
|
Packit |
534379 |
} else {
|
|
Packit |
534379 |
// found metrics num
|
|
Packit |
534379 |
found++;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
// API returns not found if doesnot found any metric
|
|
Packit |
534379 |
if (found == 0 || num_metric_indexes == 0) {
|
|
Packit |
534379 |
result = FPGA_NOT_FOUND;
|
|
Packit |
534379 |
} else {
|
|
Packit |
534379 |
result = FPGA_OK;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
} else if (objtype == FPGA_DEVICE) {
|
|
Packit |
534379 |
// get FME metrics
|
|
Packit |
534379 |
for (i = 0; i < num_metric_indexes; i++) {
|
|
Packit |
534379 |
|
|
Packit |
534379 |
result = get_fme_metric_value(handle,
|
|
Packit |
534379 |
&(_handle->fpga_enum_metric_vector),
|
|
Packit |
534379 |
metric_num[i],
|
|
Packit |
534379 |
&metrics[i]);
|
|
Packit |
534379 |
if (result != FPGA_OK) {
|
|
Packit |
534379 |
OPAE_MSG("Failed to get metric value at Index = %ld", metric_num[i]);
|
|
Packit |
534379 |
metrics[i].metric_num = metric_num[i];
|
|
Packit |
534379 |
continue;
|
|
Packit |
534379 |
} else {
|
|
Packit |
534379 |
// found metrics num
|
|
Packit |
534379 |
found++;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
// API returns not found if doesnot found any metric
|
|
Packit |
534379 |
if (found == 0 || num_metric_indexes == 0) {
|
|
Packit |
534379 |
result = FPGA_NOT_FOUND;
|
|
Packit |
534379 |
} else {
|
|
Packit |
534379 |
result = FPGA_OK;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
} else {
|
|
Packit |
534379 |
result = FPGA_INVALID_PARAM;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
out_unlock:
|
|
Packit |
534379 |
|
|
Packit |
534379 |
clear_cached_values(_handle);
|
|
Packit |
534379 |
err = pthread_mutex_unlock(&_handle->lock);
|
|
Packit |
534379 |
if (err) {
|
|
Packit |
534379 |
OPAE_ERR("pthread_mutex_unlock() failed: %s", strerror(err));
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
return result;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result __XFPGA_API__ xfpga_fpgaGetMetricsByName(fpga_handle handle,
|
|
Packit |
534379 |
char **metrics_names,
|
|
Packit |
534379 |
uint64_t num_metric_names,
|
|
Packit |
534379 |
fpga_metric *metrics)
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
fpga_result result = FPGA_OK;
|
|
Packit |
534379 |
uint64_t found = 0;
|
|
Packit |
534379 |
struct _fpga_handle *_handle = (struct _fpga_handle *)handle;
|
|
Packit |
534379 |
int err = 0;
|
|
Packit |
534379 |
uint64_t i = 0;
|
|
Packit |
534379 |
uint64_t metric_num = 0;
|
|
Packit |
534379 |
fpga_objtype objtype;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
if (_handle == NULL) {
|
|
Packit |
534379 |
OPAE_ERR("NULL fpga handle");
|
|
Packit |
534379 |
return FPGA_INVALID_PARAM;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
result = handle_check_and_lock(_handle);
|
|
Packit |
534379 |
if (result)
|
|
Packit |
534379 |
return result;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
if (_handle->fddev < 0) {
|
|
Packit |
534379 |
OPAE_ERR("Invalid handle file descriptor");
|
|
Packit |
534379 |
result = FPGA_INVALID_PARAM;
|
|
Packit |
534379 |
goto out_unlock;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
if (metrics_names == NULL ||
|
|
Packit |
534379 |
metrics == NULL) {
|
|
Packit |
534379 |
OPAE_ERR("Invalid Input parameters");
|
|
Packit |
534379 |
result = FPGA_INVALID_PARAM;
|
|
Packit |
534379 |
goto out_unlock;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
if (num_metric_names == 0) {
|
|
Packit |
534379 |
OPAE_ERR("Invalid Input parameters");
|
|
Packit |
534379 |
result = FPGA_INVALID_PARAM;
|
|
Packit |
534379 |
goto out_unlock;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
result = enum_fpga_metrics(handle);
|
|
Packit |
534379 |
if (result != FPGA_OK) {
|
|
Packit |
534379 |
OPAE_ERR("Failed to Discover Metrics");
|
|
Packit |
534379 |
result = FPGA_NOT_FOUND;
|
|
Packit |
534379 |
goto out_unlock;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
|
|
Packit |
534379 |
result = get_fpga_object_type(handle, &objtype);
|
|
Packit |
534379 |
if (result != FPGA_OK) {
|
|
Packit |
534379 |
OPAE_ERR("Failed to init vector");
|
|
Packit |
534379 |
result = FPGA_INVALID_PARAM;
|
|
Packit |
534379 |
goto out_unlock;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
if (objtype == FPGA_ACCELERATOR) {
|
|
Packit |
534379 |
// get AFU metrics
|
|
Packit |
534379 |
for (i = 0; i < num_metric_names; i++) {
|
|
Packit |
534379 |
result = parse_metric_num_name(metrics_names[i],
|
|
Packit |
534379 |
&(_handle->fpga_enum_metric_vector),
|
|
Packit |
534379 |
&metric_num);
|
|
Packit |
534379 |
if (result != FPGA_OK) {
|
|
Packit |
534379 |
OPAE_MSG("Invalid input metrics string= %s", metrics_names[i]);
|
|
Packit |
534379 |
metrics[i].metric_num = METRIC_ARRAY_INVALID_INDEX;
|
|
Packit |
534379 |
continue;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
result = get_afu_metric_value(handle, &(_handle->fpga_enum_metric_vector),
|
|
Packit |
534379 |
metric_num,
|
|
Packit |
534379 |
&metrics[i]);
|
|
Packit |
534379 |
if (result != FPGA_OK) {
|
|
Packit |
534379 |
OPAE_MSG("Failed to get metric value for metric = %s", metrics_names[i]);
|
|
Packit |
534379 |
metrics[i].metric_num = METRIC_ARRAY_INVALID_INDEX;
|
|
Packit |
534379 |
continue;
|
|
Packit |
534379 |
} else {
|
|
Packit |
534379 |
// found metrics num
|
|
Packit |
534379 |
found++;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
// API returns not found if doesnot found any metric
|
|
Packit |
534379 |
if (found == 0 || num_metric_names == 0) {
|
|
Packit |
534379 |
result = FPGA_NOT_FOUND;
|
|
Packit |
534379 |
} else {
|
|
Packit |
534379 |
result = FPGA_OK;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
} else if (objtype == FPGA_DEVICE) {
|
|
Packit |
534379 |
// get FME metrics
|
|
Packit |
534379 |
for (i = 0; i < num_metric_names; i++) {
|
|
Packit |
534379 |
|
|
Packit |
534379 |
result = parse_metric_num_name(metrics_names[i],
|
|
Packit |
534379 |
&(_handle->fpga_enum_metric_vector),
|
|
Packit |
534379 |
&metric_num);
|
|
Packit |
534379 |
if (result != FPGA_OK) {
|
|
Packit |
534379 |
OPAE_ERR("Invalid input metrics string= %s", metrics_names[i]);
|
|
Packit |
534379 |
metrics[i].metric_num = METRIC_ARRAY_INVALID_INDEX;
|
|
Packit |
534379 |
continue;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
result = get_fme_metric_value(handle,
|
|
Packit |
534379 |
&(_handle->fpga_enum_metric_vector),
|
|
Packit |
534379 |
metric_num,
|
|
Packit |
534379 |
&metrics[i]);
|
|
Packit |
534379 |
if (result != FPGA_OK) {
|
|
Packit |
534379 |
OPAE_ERR("Failed to get metric value for metric = %s \n", metrics_names[i]);
|
|
Packit |
534379 |
metrics[i].metric_num = METRIC_ARRAY_INVALID_INDEX;
|
|
Packit |
534379 |
continue;
|
|
Packit |
534379 |
} else {
|
|
Packit |
534379 |
// found metrics num
|
|
Packit |
534379 |
found++;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
// API returns not found if doesnot found any metric
|
|
Packit |
534379 |
if (found == 0 || num_metric_names == 0) {
|
|
Packit |
534379 |
result = FPGA_NOT_FOUND;
|
|
Packit |
534379 |
} else {
|
|
Packit |
534379 |
result = FPGA_OK;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
} else {
|
|
Packit |
534379 |
result = FPGA_INVALID_PARAM;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
out_unlock:
|
|
Packit |
534379 |
|
|
Packit |
534379 |
clear_cached_values(_handle);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
err = pthread_mutex_unlock(&_handle->lock);
|
|
Packit |
534379 |
if (err) {
|
|
Packit |
534379 |
OPAE_ERR("pthread_mutex_unlock() failed: %s", strerror(err));
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
return result;
|
|
Packit |
534379 |
}
|