The Diagnostic API interface
The API interface defines how the caller will use the API. An
example also shows how the API can be used.
It also defines the RdcDiagnostic module which can load the
library dynamically and then dispatch diagnostic test to run.
Change-Id: I1e041aab86f7e19338860f5ba65262977f4ea9cb
[ROCm/rdc commit: eab3625d65]
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
Copyright (c) 2020 - present Advanced Micro Devices, Inc. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
#ifndef INCLUDE_RDC_LIB_IMPL_DIAGNOSTICMODULE_H_
|
||||
#define INCLUDE_RDC_LIB_IMPL_DIAGNOSTICMODULE_H_
|
||||
|
||||
#include <map>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include "rdc_lib/RdcDiagnostic.h"
|
||||
#include "rdc_lib/impl/RdcRasLib.h"
|
||||
#include "rdc_lib/impl/RdcSmiLib.h"
|
||||
|
||||
namespace amd {
|
||||
namespace rdc {
|
||||
|
||||
class RdcDiagnosticModule : public RdcDiagnostic {
|
||||
public:
|
||||
rdc_status_t rdc_diag_test_cases_query(
|
||||
rdc_diag_test_cases_t test_cases[MAX_TEST_CASES],
|
||||
uint32_t* test_case_count) override;
|
||||
|
||||
// Run a specific test case
|
||||
rdc_status_t rdc_test_case_run(
|
||||
rdc_diag_test_cases_t test_case,
|
||||
uint32_t gpu_index[RDC_MAX_NUM_DEVICES],
|
||||
uint32_t gpu_count,
|
||||
rdc_diag_test_result_t* result) override;
|
||||
|
||||
rdc_status_t rdc_diagnostic_run(
|
||||
const rdc_group_info_t& gpus,
|
||||
rdc_diag_level_t level,
|
||||
rdc_diag_response_t* response) override;
|
||||
|
||||
rdc_status_t rdc_diag_init(uint64_t flags) override;
|
||||
rdc_status_t rdc_diag_destroy() override;
|
||||
|
||||
explicit RdcDiagnosticModule(const RdcSmiLibPtr& smi_lib,
|
||||
const RdcRasLibPtr& ras_module);
|
||||
|
||||
private:
|
||||
//< Helper function to dispatch fields to module
|
||||
void get_fields_for_module(
|
||||
rdc_gpu_field_t* fields,
|
||||
uint32_t fields_count,
|
||||
std::map<RdcDiagnosticPtr, std::vector<rdc_gpu_field_t>>
|
||||
& fields_in_module,
|
||||
std::vector<rdc_gpu_field_value_t>& unsupport_fields); // NOLINT
|
||||
std::list<RdcDiagnosticPtr> diagnostic_modules_;
|
||||
std::map<rdc_diag_test_cases_t, RdcDiagnosticPtr> testcases_to_module_;
|
||||
};
|
||||
|
||||
typedef std::shared_ptr<RdcDiagnosticModule> RdcDiagnosticModulePtr;
|
||||
|
||||
} // namespace rdc
|
||||
} // namespace amd
|
||||
|
||||
|
||||
#endif // INCLUDE_RDC_LIB_IMPL_DIAGNOSTICMODULE_H_
|
||||
@@ -86,6 +86,11 @@ class RdcEmbeddedHandler: public RdcHandler {
|
||||
uint64_t *next_since_time_stamp, rdc_field_value* value) override;
|
||||
rdc_status_t rdc_field_unwatch(rdc_gpu_group_t group_id,
|
||||
rdc_field_grp_t field_group_id) override;
|
||||
// Diagnostic API
|
||||
rdc_status_t rdc_diagnostic_run(
|
||||
rdc_gpu_group_t group_id,
|
||||
rdc_diag_level_t level,
|
||||
rdc_diag_response_t* response) override;
|
||||
// Control API
|
||||
rdc_status_t rdc_field_update_all(uint32_t wait_for_update) override;
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ THE SOFTWARE.
|
||||
#include "rdc_lib/RdcMetricFetcher.h"
|
||||
#include "rdc_lib/RdcTelemetry.h"
|
||||
#include "rdc_lib/impl/RdcRasLib.h"
|
||||
#include "rdc_lib/impl/RdcSmiLib.h"
|
||||
|
||||
namespace amd {
|
||||
namespace rdc {
|
||||
@@ -34,14 +35,16 @@ namespace rdc {
|
||||
class RdcModuleMgrImpl: public RdcModuleMgr {
|
||||
public:
|
||||
RdcTelemetryPtr get_telemetry_module() override;
|
||||
RdcDiagnosticPtr get_diagnostic_module() override;
|
||||
explicit RdcModuleMgrImpl(const RdcMetricFetcherPtr& fetcher);
|
||||
private:
|
||||
// Function module
|
||||
RdcTelemetryPtr rdc_telemetry_module_;
|
||||
RdcDiagnosticPtr rdc_diagnostic_module_;
|
||||
|
||||
// Domain module
|
||||
RdcRasLibPtr ras_lib_;
|
||||
|
||||
RdcSmiLibPtr smi_lib_;
|
||||
RdcMetricFetcherPtr fetcher_;
|
||||
};
|
||||
|
||||
|
||||
@@ -30,11 +30,12 @@ THE SOFTWARE.
|
||||
#include <string>
|
||||
#include "rdc_lib/RdcLibraryLoader.h"
|
||||
#include "rdc_lib/RdcTelemetry.h"
|
||||
#include "rdc_lib/RdcDiagnostic.h"
|
||||
|
||||
|
||||
namespace amd {
|
||||
namespace rdc {
|
||||
class RdcRasLib: public RdcTelemetry {
|
||||
class RdcRasLib: public RdcTelemetry, public RdcDiagnostic {
|
||||
public:
|
||||
// get support field ids
|
||||
rdc_status_t rdc_telemetry_fields_query(uint32_t field_ids[MAX_NUM_FIELDS],
|
||||
@@ -51,6 +52,25 @@ class RdcRasLib: public RdcTelemetry {
|
||||
rdc_status_t rdc_telemetry_fields_unwatch(rdc_gpu_field_t* fields,
|
||||
uint32_t fields_count) override;
|
||||
|
||||
rdc_status_t rdc_diag_test_cases_query(
|
||||
rdc_diag_test_cases_t test_cases[MAX_TEST_CASES],
|
||||
uint32_t* test_case_count) override;
|
||||
|
||||
// Run a specific test case
|
||||
rdc_status_t rdc_test_case_run(
|
||||
rdc_diag_test_cases_t test_case,
|
||||
uint32_t gpu_index[RDC_MAX_NUM_DEVICES],
|
||||
uint32_t gpu_count,
|
||||
rdc_diag_test_result_t* result) override;
|
||||
|
||||
rdc_status_t rdc_diagnostic_run(
|
||||
const rdc_group_info_t& gpus,
|
||||
rdc_diag_level_t level,
|
||||
rdc_diag_response_t* response) override;
|
||||
|
||||
rdc_status_t rdc_diag_init(uint64_t flags) override;
|
||||
rdc_status_t rdc_diag_destroy() override;
|
||||
|
||||
explicit RdcRasLib(const char* lib_name);
|
||||
|
||||
~RdcRasLib();
|
||||
|
||||
@@ -26,11 +26,12 @@ THE SOFTWARE.
|
||||
#include <memory>
|
||||
#include "rdc_lib/RdcMetricFetcher.h"
|
||||
#include "rdc_lib/RdcTelemetry.h"
|
||||
#include "rdc_lib/RdcDiagnostic.h"
|
||||
|
||||
namespace amd {
|
||||
namespace rdc {
|
||||
|
||||
class RdcSmiLib : public RdcTelemetry {
|
||||
class RdcSmiLib : public RdcTelemetry, public RdcDiagnostic {
|
||||
public:
|
||||
// get support field ids
|
||||
rdc_status_t rdc_telemetry_fields_query(
|
||||
@@ -46,12 +47,33 @@ class RdcSmiLib : public RdcTelemetry {
|
||||
rdc_status_t rdc_telemetry_fields_unwatch(rdc_gpu_field_t* fields,
|
||||
uint32_t fields_count) override;
|
||||
|
||||
rdc_status_t rdc_diag_test_cases_query(
|
||||
rdc_diag_test_cases_t test_cases[MAX_TEST_CASES],
|
||||
uint32_t* test_case_count) override;
|
||||
|
||||
// Run a specific test case
|
||||
rdc_status_t rdc_test_case_run(
|
||||
rdc_diag_test_cases_t test_case,
|
||||
uint32_t gpu_index[RDC_MAX_NUM_DEVICES],
|
||||
uint32_t gpu_count,
|
||||
rdc_diag_test_result_t* result) override;
|
||||
|
||||
rdc_status_t rdc_diagnostic_run(
|
||||
const rdc_group_info_t& gpus,
|
||||
rdc_diag_level_t level,
|
||||
rdc_diag_response_t* response) override;
|
||||
|
||||
rdc_status_t rdc_diag_init(uint64_t flags) override;
|
||||
rdc_status_t rdc_diag_destroy() override;
|
||||
|
||||
explicit RdcSmiLib(const RdcMetricFetcherPtr& mf);
|
||||
|
||||
private:
|
||||
RdcMetricFetcherPtr metric_fetcher_;
|
||||
};
|
||||
|
||||
typedef std::shared_ptr<RdcSmiLib> RdcSmiLibPtr;
|
||||
|
||||
} // namespace rdc
|
||||
} // namespace amd
|
||||
|
||||
|
||||
@@ -80,6 +80,11 @@ class RdcStandaloneHandler: public RdcHandler {
|
||||
uint64_t *next_since_time_stamp, rdc_field_value* value) override;
|
||||
rdc_status_t rdc_field_unwatch(rdc_gpu_group_t group_id,
|
||||
rdc_field_grp_t field_group_id) override;
|
||||
// Diagnostic API
|
||||
rdc_status_t rdc_diagnostic_run(
|
||||
rdc_gpu_group_t group_id,
|
||||
rdc_diag_level_t level,
|
||||
rdc_diag_response_t* response) override;
|
||||
|
||||
// Control RdcAPI
|
||||
rdc_status_t rdc_field_update_all(uint32_t wait_for_update) override;
|
||||
|
||||
@@ -28,6 +28,7 @@ THE SOFTWARE.
|
||||
#include <memory>
|
||||
#include "rdc_lib/RdcTelemetry.h"
|
||||
#include "rdc_lib/impl/RdcRasLib.h"
|
||||
#include "rdc_lib/impl/RdcSmiLib.h"
|
||||
#include "rdc_lib/RdcMetricFetcher.h"
|
||||
|
||||
namespace amd {
|
||||
@@ -48,7 +49,7 @@ class RdcTelemetryModule : public RdcTelemetry {
|
||||
rdc_status_t rdc_telemetry_fields_unwatch(rdc_gpu_field_t* fields,
|
||||
uint32_t fields_count);
|
||||
|
||||
RdcTelemetryModule(const RdcMetricFetcherPtr& fetcher,
|
||||
RdcTelemetryModule(const RdcSmiLibPtr& smi_lib,
|
||||
const RdcRasLibPtr& ras_module);
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user