Add new init and destroy API for RAS library.
RAS library will provide two new APIs: rdc_status_t rdc_module_init(uint64_t flags); rdc_status_t rdc_module_destroy(); When RDC load the librdc_ras.so, it will call rdc_module_init(). When RDC exit, it will call rdc_module_destroy() Change-Id: I7f5c81fd19a45a906c3c339cd6eabee2277f27ca
This commit is contained in:
@@ -53,11 +53,16 @@ class RdcRasLib: public RdcTelemetry {
|
||||
|
||||
explicit RdcRasLib(const char* lib_name);
|
||||
|
||||
~RdcRasLib();
|
||||
|
||||
private:
|
||||
RdcLibraryLoader lib_loader_;
|
||||
rdc_status_t (*fields_value_get_)(rdc_gpu_field_t*,
|
||||
uint32_t, rdc_field_value_f, void*);
|
||||
rdc_status_t (*fields_query_)(uint32_t[MAX_NUM_FIELDS], uint32_t*);
|
||||
|
||||
rdc_status_t (*rdc_module_init_)(uint64_t);
|
||||
rdc_status_t (*rdc_module_destroy_)();
|
||||
};
|
||||
typedef std::shared_ptr<RdcRasLib> RdcRasLibPtr;
|
||||
|
||||
|
||||
@@ -27,14 +27,36 @@ THE SOFTWARE.
|
||||
namespace amd {
|
||||
namespace rdc {
|
||||
|
||||
RdcRasLib::RdcRasLib(const char* lib_name) {
|
||||
RdcRasLib::RdcRasLib(const char* lib_name):
|
||||
fields_value_get_(nullptr)
|
||||
, fields_query_(nullptr)
|
||||
, rdc_module_init_(nullptr)
|
||||
, rdc_module_destroy_(nullptr) {
|
||||
rdc_status_t status = lib_loader_.load(lib_name);
|
||||
if (status != RDC_ST_OK) {
|
||||
fields_value_get_ = nullptr;
|
||||
fields_query_ = nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
status = lib_loader_.load_symbol(&rdc_module_init_,
|
||||
"rdc_module_init");
|
||||
if (status != RDC_ST_OK) {
|
||||
rdc_module_init_ = nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
if (rdc_module_init_(0) != RDC_ST_OK) {
|
||||
RDC_LOG(RDC_ERROR, "Fail to init librdc_ras.so:"
|
||||
<< rdc_status_string(status));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
status = lib_loader_.load_symbol(&rdc_module_destroy_,
|
||||
"rdc_module_destroy");
|
||||
if (status != RDC_ST_OK) {
|
||||
rdc_module_destroy_ = nullptr;
|
||||
}
|
||||
|
||||
status = lib_loader_.load_symbol(&fields_value_get_,
|
||||
"rdc_telemetry_fields_value_get");
|
||||
if (status != RDC_ST_OK) {
|
||||
@@ -47,6 +69,12 @@ RdcRasLib::RdcRasLib(const char* lib_name) {
|
||||
}
|
||||
}
|
||||
|
||||
RdcRasLib::~RdcRasLib() {
|
||||
if (rdc_module_destroy_) {
|
||||
rdc_module_destroy_();
|
||||
}
|
||||
}
|
||||
|
||||
rdc_status_t RdcRasLib::rdc_telemetry_fields_query(
|
||||
uint32_t field_ids[MAX_NUM_FIELDS], uint32_t* field_count) {
|
||||
if (field_count == nullptr) {
|
||||
|
||||
مرجع در شماره جدید
Block a user