Implement the code related to the GetMixedComponentVersion()
Change-Id: I98aad97b4cb6498b7f2fc03a2d5ee7c9e949d5f1
Signed-off-by: Chen Gong <curry.gong@amd.com>
[ROCm/rdc commit: 1edd04d84e]
Этот коммит содержится в:
коммит произвёл
Galantsev, Dmitrii
родитель
dc85a9e385
Коммит
cd98bb7f90
@@ -0,0 +1,66 @@
|
||||
|
||||
#ifndef INCLUDE_RDC_RDC_PRIVATE_H_
|
||||
#define INCLUDE_RDC_RDC_PRIVATE_H_
|
||||
|
||||
#include "rdc/rdc.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
// cstddef include causes issues on older GCC
|
||||
// use stddef.h instead
|
||||
#if __GNUC__ < 9
|
||||
#include <stddef.h>
|
||||
#else
|
||||
#include <cstddef>
|
||||
#endif // __GNUC__
|
||||
|
||||
#include <cstdint>
|
||||
#else
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#endif // __cplusplus
|
||||
|
||||
/**
|
||||
* @brief The maximum string length occupied by version information.
|
||||
*/
|
||||
#define USR_MAX_VERSION_STR_LENGTH 60
|
||||
|
||||
/**
|
||||
* @brief Version information of mixed components
|
||||
*/
|
||||
typedef struct {
|
||||
char version[USR_MAX_VERSION_STR_LENGTH];
|
||||
} mixed_component_version_t;
|
||||
|
||||
/**
|
||||
* @brief Type of Components
|
||||
*/
|
||||
typedef enum {
|
||||
RDCD_COMPONENT
|
||||
//If needed later, add them one by one
|
||||
} mixed_component_t;
|
||||
|
||||
/**
|
||||
* @brief Get ersion information of mixed components.
|
||||
*
|
||||
* @details Given a component type, return its version information.
|
||||
*
|
||||
* @param[in] p_rdc_handle The RDC handler.
|
||||
*
|
||||
* @param[in] component Component type.
|
||||
*
|
||||
* @param[out] p_mixed_compv Version information of the corresponding component.
|
||||
*
|
||||
* @retval ::RDC_ST_OK is returned upon successful call.
|
||||
*/
|
||||
rdc_status_t get_mixed_component_version(rdc_handle_t p_rdc_handle, mixed_component_t component, mixed_component_version_t* p_mixed_compv);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // INCLUDE_RDC_RDC_PRIVATE_H_
|
||||
@@ -23,6 +23,7 @@ THE SOFTWARE.
|
||||
#define INCLUDE_RDC_LIB_RDCHANDLER_H_
|
||||
|
||||
#include "rdc/rdc.h"
|
||||
#include "rdc/rdc_private.h"
|
||||
#include "rdc_lib/rdc_common.h"
|
||||
|
||||
namespace amd {
|
||||
@@ -88,6 +89,10 @@ class RdcHandler {
|
||||
// Control API
|
||||
virtual rdc_status_t rdc_field_update_all(uint32_t wait_for_update) = 0;
|
||||
|
||||
// It is just a client interface under the GRPC framework and is not used as an RDC API.
|
||||
// The reason is that RdcEmbeddedHandler::get_mixed_component_version does not need to be called.
|
||||
virtual rdc_status_t get_mixed_component_version(mixed_component_t component, mixed_component_version_t* p_mixed_compv) = 0;
|
||||
|
||||
virtual ~RdcHandler() {}
|
||||
};
|
||||
|
||||
|
||||
@@ -91,6 +91,10 @@ class RdcEmbeddedHandler final : public RdcHandler {
|
||||
// Control API
|
||||
rdc_status_t rdc_field_update_all(uint32_t wait_for_update) override;
|
||||
|
||||
// It is just a client interface under the GRPC framework and is not used as an RDC API.
|
||||
// Pure virtual functions need to be overridden.
|
||||
rdc_status_t get_mixed_component_version(mixed_component_t component, mixed_component_version_t* p_mixed_compv) override;
|
||||
|
||||
explicit RdcEmbeddedHandler(rdc_operation_mode_t op_mode);
|
||||
~RdcEmbeddedHandler() final;
|
||||
|
||||
|
||||
@@ -86,6 +86,10 @@ class RdcStandaloneHandler : public RdcHandler {
|
||||
// Control RdcAPI
|
||||
rdc_status_t rdc_field_update_all(uint32_t wait_for_update) override;
|
||||
|
||||
// It is just a client interface under the GRPC framework and is not used as an RDC API.
|
||||
// Pure virtual functions need to be overridden
|
||||
rdc_status_t get_mixed_component_version(mixed_component_t component, mixed_component_version_t* p_mixed_compv) override;
|
||||
|
||||
explicit RdcStandaloneHandler(const char* ip_and_port, const char* root_ca,
|
||||
const char* client_cert, const char* client_key);
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ THE SOFTWARE.
|
||||
|
||||
#include "common/rdc_fields_supported.h"
|
||||
#include "rdc/rdc.h"
|
||||
#include "rdc/rdc_private.h"
|
||||
#include "rdc_lib/RdcHandler.h"
|
||||
#include "rdc_lib/RdcLibraryLoader.h"
|
||||
#include "rdc_lib/RdcLogger.h"
|
||||
@@ -324,6 +325,15 @@ rdc_status_t rdc_test_case_run(rdc_handle_t p_rdc_handle, rdc_gpu_group_t group_
|
||||
->rdc_test_case_run(group_id, test_case, config, config_size, result);
|
||||
}
|
||||
|
||||
rdc_status_t get_mixed_component_version(rdc_handle_t p_rdc_handle, mixed_component_t component, mixed_component_version_t* p_mixed_compv) {
|
||||
if (!p_rdc_handle || !p_mixed_compv) {
|
||||
return RDC_ST_INVALID_HANDLER;
|
||||
}
|
||||
|
||||
return static_cast<amd::rdc::RdcHandler*>(p_rdc_handle)
|
||||
->get_mixed_component_version(component, p_mixed_compv);
|
||||
}
|
||||
|
||||
const char* rdc_status_string(rdc_status_t result) {
|
||||
switch (result) {
|
||||
case RDC_ST_OK:
|
||||
|
||||
@@ -421,5 +421,13 @@ rdc_status_t RdcEmbeddedHandler::rdc_field_update_all(uint32_t wait_for_update)
|
||||
return RDC_ST_OK;
|
||||
}
|
||||
|
||||
// It is just a client interface under the GRPC framework and is not used as an RDC API.
|
||||
// Just write an empty function to solve compilation errors
|
||||
rdc_status_t RdcEmbeddedHandler::get_mixed_component_version(mixed_component_t component, mixed_component_version_t* p_mixed_compv) {
|
||||
(void)(component);
|
||||
(void)(p_mixed_compv);
|
||||
return RDC_ST_OK;
|
||||
}
|
||||
|
||||
} // namespace rdc
|
||||
} // namespace amd
|
||||
|
||||
@@ -662,5 +662,27 @@ rdc_status_t RdcStandaloneHandler::rdc_field_update_all(uint32_t wait_for_update
|
||||
return error_handle(status, reply.status());
|
||||
}
|
||||
|
||||
// It is only an interface for the client under the GRPC framework and is not used as an RDC API.
|
||||
rdc_status_t RdcStandaloneHandler::get_mixed_component_version(mixed_component_t component, mixed_component_version_t* p_mixed_compv) {
|
||||
|
||||
if (!p_mixed_compv) {
|
||||
return RDC_ST_BAD_PARAMETER;
|
||||
}
|
||||
|
||||
::rdc::GetMixedComponentVersionRequest request;
|
||||
::rdc::GetMixedComponentVersionResponse reply;
|
||||
::grpc::ClientContext context;
|
||||
|
||||
request.set_component_id(component);
|
||||
::grpc::Status status = stub_->GetMixedComponentVersion(&context, request, &reply);
|
||||
|
||||
rdc_status_t err_status = error_handle(status, reply.status());
|
||||
if (err_status != RDC_ST_OK) return err_status;
|
||||
|
||||
strncpy_with_null(p_mixed_compv->version, reply.version().c_str(), USR_MAX_VERSION_STR_LENGTH);
|
||||
return RDC_ST_OK;
|
||||
|
||||
}
|
||||
|
||||
} // namespace rdc
|
||||
} // namespace amd
|
||||
|
||||
@@ -125,6 +125,8 @@ class RdcAPIServiceImpl final : public ::rdc::RdcAPI::Service {
|
||||
const ::rdc::DiagnosticTestCaseRunRequest* request,
|
||||
::rdc::DiagnosticTestCaseRunResponse* reply) override;
|
||||
|
||||
::grpc::Status GetMixedComponentVersion(::grpc::ServerContext* context, const ::rdc::GetMixedComponentVersionRequest* request,
|
||||
::rdc::GetMixedComponentVersionResponse* reply) override;
|
||||
private:
|
||||
bool copy_gpu_usage_info(const rdc_gpu_usage_info_t& src, ::rdc::GpuUsageInfo* target);
|
||||
rdc_handle_t rdc_handle_;
|
||||
|
||||
@@ -20,7 +20,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
#include "rdc/rdc_api_service.h"
|
||||
|
||||
#include "rdc/rdc_server_main.h"
|
||||
#include <assert.h>
|
||||
#include <grpcpp/grpcpp.h>
|
||||
|
||||
@@ -31,6 +31,7 @@ THE SOFTWARE.
|
||||
|
||||
#include "rdc.grpc.pb.h" // NOLINT
|
||||
#include "rdc/rdc.h"
|
||||
#include "rdc/rdc_private.h"
|
||||
#include "rdc_lib/RdcLogger.h"
|
||||
#include "rdc_lib/rdc_common.h"
|
||||
|
||||
@@ -660,5 +661,35 @@ bool RdcAPIServiceImpl::copy_gpu_usage_info(const rdc_gpu_usage_info_t& src,
|
||||
return ::grpc::Status::OK;
|
||||
}
|
||||
|
||||
::grpc::Status RdcAPIServiceImpl::GetMixedComponentVersion(::grpc::ServerContext* context,
|
||||
const ::rdc::GetMixedComponentVersionRequest* request,
|
||||
::rdc::GetMixedComponentVersionResponse* reply) {
|
||||
(void)(context);
|
||||
if (!reply) {
|
||||
return ::grpc::Status(::grpc::StatusCode::INTERNAL, "Empty reply");
|
||||
}
|
||||
|
||||
mixed_component_t component = static_cast<mixed_component_t>(request->component_id());
|
||||
|
||||
if (component == RDCD_COMPONENT) {
|
||||
std::string version = RDC_SERVER_VERSION_STRING;
|
||||
std::string hash;
|
||||
std::string rdcdversion;
|
||||
#ifdef CURRENT_GIT_HASH
|
||||
hash = QUOTE(CURRENT_GIT_HASH);
|
||||
rdcdversion = version + "+" + hash;
|
||||
#else
|
||||
hash = "";
|
||||
rdcdversion = version;
|
||||
#endif
|
||||
|
||||
reply->set_version(rdcdversion);
|
||||
reply->set_status(RDC_ST_OK);
|
||||
return ::grpc::Status::OK;
|
||||
} else {
|
||||
return ::grpc::Status(::grpc::StatusCode::INVALID_ARGUMENT, "The provided request parameters are invalid");
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace rdc
|
||||
} // namespace amd
|
||||
|
||||
Ссылка в новой задаче
Block a user