LINT: Add cpplint, clang-format and pre-commit support
Change-Id: I3cbb787ef27d90486b212dfb1a8c77c460acc2ac Signed-off-by: Galantsev, Dmitrii <dmitrii.galantsev@amd.com>
Tá an tiomantas seo le fáil i:
Inrite → Rialta
+21
-34
@@ -28,6 +28,7 @@ THE SOFTWARE.
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "rocm_smi/rocm_smi.h"
|
||||
|
||||
/**
|
||||
@@ -190,7 +191,6 @@ typedef enum {
|
||||
RDC_STATUS_UNKNOWN_ERROR = 0xFFFFFFFF, //!< An unknown error occurred
|
||||
} rdc_status_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Handle to RDC server channel
|
||||
*/
|
||||
@@ -232,10 +232,8 @@ typedef uintptr_t rdc_channel_t;
|
||||
* @retval ::RDC_STATUS_SUCCESS is returned upon successful call.
|
||||
*
|
||||
*/
|
||||
rdc_status_t
|
||||
rdc_channel_state_get(rdc_channel_t channel, bool try_to_connect,
|
||||
grpc_connectivity_state *state);
|
||||
|
||||
rdc_status_t rdc_channel_state_get(rdc_channel_t channel, bool try_to_connect,
|
||||
grpc_connectivity_state* state);
|
||||
|
||||
/**
|
||||
* @brief Verify a channel's connection to the server
|
||||
@@ -252,8 +250,7 @@ rdc_channel_state_get(rdc_channel_t channel, bool try_to_connect,
|
||||
* @retval ::RDC_STATUS_SUCCESS is returned upon successful call.
|
||||
*
|
||||
*/
|
||||
rdc_status_t
|
||||
rdc_channel_connection_verify(rdc_channel_t channel);
|
||||
rdc_status_t rdc_channel_connection_verify(rdc_channel_t channel);
|
||||
|
||||
/** @} */ // end of RDCAdmin
|
||||
|
||||
@@ -267,7 +264,7 @@ rdc_channel_connection_verify(rdc_channel_t channel);
|
||||
/**
|
||||
* @brief Create a communications channel to an RDC server
|
||||
*
|
||||
* @details Given a pointer to an ::rdc_channel_t @p channel, a string
|
||||
* @details Given a pointer to an ::rdc_channel_t @p channel, a string
|
||||
* containing the ip address of the server @p ip, a string containing
|
||||
* the port number on which the server is listening @p port and a bool
|
||||
* indicating whether the channel should use a secure link @p secure,
|
||||
@@ -290,9 +287,8 @@ rdc_channel_connection_verify(rdc_channel_t channel);
|
||||
* @retval ::RDC_STATUS_SUCCESS is returned upon successful call.
|
||||
*
|
||||
*/
|
||||
rdc_status_t
|
||||
rdc_channel_create(rdc_channel_t *channel, const char *ip, const char *port,
|
||||
bool secure);
|
||||
rdc_status_t rdc_channel_create(rdc_channel_t* channel, const char* ip, const char* port,
|
||||
bool secure);
|
||||
|
||||
/**
|
||||
* @brief Destroy a communications channel to an RDC server
|
||||
@@ -305,13 +301,12 @@ rdc_channel_create(rdc_channel_t *channel, const char *ip, const char *port,
|
||||
* @retval ::RDC_STATUS_SUCCESS is returned upon successful call.
|
||||
*
|
||||
*/
|
||||
rdc_status_t
|
||||
rdc_channel_destroy(rdc_channel_t channel);
|
||||
rdc_status_t rdc_channel_destroy(rdc_channel_t channel);
|
||||
|
||||
/** @} */ // end of InitShutAdmin
|
||||
|
||||
/*****************************************************************************/
|
||||
/** @defgroup RSMIAccess Remote ROCm SMI Calls
|
||||
/** @defgroup RSMIAccess Remote ROCm SMI Calls
|
||||
* These functions calls make ROCm SMI function calls on the remote server.
|
||||
* Please refer to the
|
||||
* [ROCm SMI documentation]
|
||||
@@ -319,10 +314,10 @@ rdc_channel_destroy(rdc_channel_t channel);
|
||||
* information about the calls. Here, we will document any additional aspects
|
||||
* of the calls introduced by RDC that are not covered in the ROCm SMI
|
||||
* documentation.
|
||||
*
|
||||
*
|
||||
* All of the functions in this section attempt to make an RSMI call on the
|
||||
* server machine, given an ::rdc_channel_t associated with the server, and
|
||||
* all the arguments that are required to make the RSMI call.
|
||||
* all the arguments that are required to make the RSMI call.
|
||||
* @{
|
||||
*/
|
||||
|
||||
@@ -330,12 +325,10 @@ rdc_channel_destroy(rdc_channel_t channel);
|
||||
* @brief Remote call to rsmi_num_monitor_devices()
|
||||
*
|
||||
*/
|
||||
rdc_status_t
|
||||
rdc_num_gpus_get(rdc_channel_t channel, uint64_t *num_gpu);
|
||||
rdc_status_t rdc_num_gpus_get(rdc_channel_t channel, uint64_t* num_gpu);
|
||||
|
||||
/** @} */ // end of RSMIAccess
|
||||
|
||||
|
||||
/** @defgroup PhysQuer Physical State Queries
|
||||
* These functions provide information about the physical characteristics of
|
||||
* the device.
|
||||
@@ -345,34 +338,29 @@ rdc_num_gpus_get(rdc_channel_t channel, uint64_t *num_gpu);
|
||||
* @brief Remote call to rsmi_dev_temp_metric_get()
|
||||
*
|
||||
*/
|
||||
rdc_status_t
|
||||
rdc_dev_temp_metric_get(rdc_channel_t channel, uint32_t dv_ind,
|
||||
uint32_t sensor_type, rsmi_temperature_metric_t metric,
|
||||
int64_t *temperature);
|
||||
rdc_status_t rdc_dev_temp_metric_get(rdc_channel_t channel, uint32_t dv_ind, uint32_t sensor_type,
|
||||
rsmi_temperature_metric_t metric, int64_t* temperature);
|
||||
|
||||
/**
|
||||
* @brief Remote call to rsmi_dev_fan_rpms_get()
|
||||
*
|
||||
*/
|
||||
rdc_status_t
|
||||
rdc_dev_fan_rpms_get(rdc_channel_t channel, uint32_t dv_ind,
|
||||
uint32_t sensor_ind, int64_t *rpms);
|
||||
rdc_status_t rdc_dev_fan_rpms_get(rdc_channel_t channel, uint32_t dv_ind, uint32_t sensor_ind,
|
||||
int64_t* rpms);
|
||||
|
||||
/**
|
||||
* @brief Remote call to rsmi_dev_fan_speed_get()
|
||||
*
|
||||
*/
|
||||
rdc_status_t
|
||||
rdc_dev_fan_speed_get(rdc_channel_t channel, uint32_t dv_ind,
|
||||
uint32_t sensor_ind, int64_t *speed);
|
||||
rdc_status_t rdc_dev_fan_speed_get(rdc_channel_t channel, uint32_t dv_ind, uint32_t sensor_ind,
|
||||
int64_t* speed);
|
||||
|
||||
/**
|
||||
* @brief Remote call to rsmi_dev_fan_speed_max_get()
|
||||
*
|
||||
*/
|
||||
rdc_status_t
|
||||
rdc_dev_fan_speed_max_get(rdc_channel_t channel, uint32_t dv_ind,
|
||||
uint32_t sensor_ind, uint64_t *max_speed);
|
||||
rdc_status_t rdc_dev_fan_speed_max_get(rdc_channel_t channel, uint32_t dv_ind, uint32_t sensor_ind,
|
||||
uint64_t* max_speed);
|
||||
/** @} */ // end of PhysQuer
|
||||
|
||||
/**
|
||||
@@ -389,7 +377,6 @@ rdc_dev_fan_speed_max_get(rdc_channel_t channel, uint32_t dv_ind,
|
||||
* @retval ::RSMI_STATUS_SUCCESS is returned upon successful call
|
||||
*
|
||||
*/
|
||||
rdc_status_t
|
||||
rdc_status_string(rdc_status_t status, const char **status_string);
|
||||
rdc_status_t rdc_status_string(rdc_status_t status, const char** status_string);
|
||||
|
||||
#endif // CLIENT_INCLUDE_RDC_RDC_CLIENT_H_
|
||||
|
||||
Inrite → Rialta
+8
-10
@@ -26,8 +26,8 @@ THE SOFTWARE.
|
||||
|
||||
#include <grpcpp/grpcpp.h>
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "rdc.grpc.pb.h" // NOLINT
|
||||
#include "rdc/rdc_client.h"
|
||||
@@ -37,8 +37,7 @@ namespace rdc {
|
||||
|
||||
class RDCChannel {
|
||||
public:
|
||||
explicit RDCChannel(std::string server_ip, std::string server_port,
|
||||
bool secure_channel);
|
||||
explicit RDCChannel(std::string server_ip, std::string server_port, bool secure_channel);
|
||||
~RDCChannel();
|
||||
|
||||
rdc_status_t Initialize(void);
|
||||
@@ -47,13 +46,12 @@ class RDCChannel {
|
||||
|
||||
// Don't have setter for server ip and ports; we don't want to change those
|
||||
// after construction
|
||||
std::string server_ip(void) const {return server_ip_;}
|
||||
std::string server_port(void) const {return server_port_;}
|
||||
bool secure_channel(void) const {return secure_channel_;}
|
||||
std::shared_ptr<::rdc::Rsmi::Stub> rsmi_stub(void) const {return rsmi_stub_;}
|
||||
std::shared_ptr<::rdc::RdcAdmin::Stub> rdc_admin_stub(void) const {
|
||||
return rdc_admin_stub_;}
|
||||
std::shared_ptr<grpc::Channel> const channel(void) {return channel_;}
|
||||
std::string server_ip(void) const { return server_ip_; }
|
||||
std::string server_port(void) const { return server_port_; }
|
||||
bool secure_channel(void) const { return secure_channel_; }
|
||||
std::shared_ptr<::rdc::Rsmi::Stub> rsmi_stub(void) const { return rsmi_stub_; }
|
||||
std::shared_ptr<::rdc::RdcAdmin::Stub> rdc_admin_stub(void) const { return rdc_admin_stub_; }
|
||||
std::shared_ptr<grpc::Channel> const channel(void) { return channel_; }
|
||||
|
||||
private:
|
||||
std::string server_ip_;
|
||||
|
||||
Inrite → Rialta
@@ -22,6 +22,7 @@ THE SOFTWARE.
|
||||
#ifndef CLIENT_INCLUDE_RDC_RDC_CLIENT_UTILS_H_
|
||||
#define CLIENT_INCLUDE_RDC_RDC_CLIENT_UTILS_H_
|
||||
|
||||
#include "rdc/rdc_client.h"
|
||||
namespace amd {
|
||||
namespace rdc {
|
||||
|
||||
|
||||
Inrite → Rialta
+2
-3
@@ -34,8 +34,8 @@ namespace rdc {
|
||||
/// @brief Exception type which carries an error code to return to the user.
|
||||
class rdc_exception : public std::exception {
|
||||
public:
|
||||
rdc_exception(rdc_status_t error, const std::string description) :
|
||||
err_(error), desc_(description) {}
|
||||
rdc_exception(rdc_status_t error, const std::string description)
|
||||
: err_(error), desc_(description) {}
|
||||
rdc_status_t error_code() const noexcept { return err_; }
|
||||
const char* what() const noexcept override { return desc_.c_str(); }
|
||||
|
||||
@@ -48,4 +48,3 @@ class rdc_exception : public std::exception {
|
||||
} // namespace amd
|
||||
|
||||
#endif // CLIENT_INCLUDE_RDC_RDC_EXCEPTION_H_
|
||||
|
||||
|
||||
Inrite → Rialta
+190
-211
@@ -20,30 +20,31 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <grpcpp/grpcpp.h>
|
||||
#include "rdc/rdc_client.h"
|
||||
|
||||
#include <grpcpp/grpcpp.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "rdc/rdc_client_main.h"
|
||||
#include "rdc/rdc_client.h"
|
||||
#include "rdc/rdc_client_utils.h"
|
||||
#include "common/rdc_utils.h"
|
||||
#include "rdc/rdc_exception.h"
|
||||
#include "rdc.grpc.pb.h" // NOLINT
|
||||
#include "rdc/rdc_client_main.h"
|
||||
#include "rdc/rdc_client_utils.h"
|
||||
#include "rdc/rdc_exception.h"
|
||||
#include "rocm_smi/rocm_smi.h"
|
||||
|
||||
#define CHK_PTR_ARG(PTR) \
|
||||
if ((PTR) == nullptr) { \
|
||||
#define CHK_PTR_ARG(PTR) \
|
||||
if ((PTR) == nullptr) { \
|
||||
return RDC_RSMI_STATUS_INVALID_ARGS; \
|
||||
}
|
||||
|
||||
#define UINTPTR_TO_RDC_CHAN(UPTR) \
|
||||
amd::rdc::RDCChannel *ch = reinterpret_cast<amd::rdc::RDCChannel *>(UPTR); \
|
||||
if (ch == nullptr) { \
|
||||
return RDC_STATUS_GRPC_INVALID_ARG; \
|
||||
} \
|
||||
#define UINTPTR_TO_RDC_CHAN(UPTR) \
|
||||
amd::rdc::RDCChannel* ch = reinterpret_cast<amd::rdc::RDCChannel*>(UPTR); \
|
||||
if (ch == nullptr) { \
|
||||
return RDC_STATUS_GRPC_INVALID_ARG; \
|
||||
}
|
||||
|
||||
static rdc_status_t handleException() {
|
||||
try {
|
||||
@@ -71,13 +72,15 @@ static rdc_status_t handleException() {
|
||||
}
|
||||
|
||||
#define TRY try {
|
||||
#define CATCH } catch (...) {return handleException();}
|
||||
#define CATCH \
|
||||
} \
|
||||
catch (...) { \
|
||||
return handleException(); \
|
||||
}
|
||||
|
||||
rdc_status_t
|
||||
rdc_channel_create(rdc_channel_t *channel, const char *ip,
|
||||
const char *port, bool secure) {
|
||||
TRY
|
||||
std::string server_str;
|
||||
rdc_status_t rdc_channel_create(rdc_channel_t* channel, const char* ip, const char* port,
|
||||
bool secure) {
|
||||
TRY std::string server_str;
|
||||
std::string port_str;
|
||||
|
||||
if (channel == nullptr) {
|
||||
@@ -95,8 +98,7 @@ rdc_channel_create(rdc_channel_t *channel, const char *ip,
|
||||
port_str = std::to_string(RDC_DEFAULT_SERVER_PORT);
|
||||
}
|
||||
|
||||
amd::rdc::RDCChannel *ch =
|
||||
new amd::rdc::RDCChannel(server_str, port_str, secure);
|
||||
amd::rdc::RDCChannel* ch = new amd::rdc::RDCChannel(server_str, port_str, secure);
|
||||
|
||||
if (ch == nullptr) {
|
||||
return RDC_STATUS_GRPC_RESOURCE_EXHAUSTED;
|
||||
@@ -115,32 +117,26 @@ rdc_channel_create(rdc_channel_t *channel, const char *ip,
|
||||
|
||||
CATCH
|
||||
}
|
||||
rdc_status_t
|
||||
rdc_channel_state_get(rdc_channel_t channel, bool try_to_connect,
|
||||
grpc_connectivity_state *state) {
|
||||
TRY
|
||||
CHK_PTR_ARG(state)
|
||||
UINTPTR_TO_RDC_CHAN(channel)
|
||||
rdc_status_t rdc_channel_state_get(rdc_channel_t channel, bool try_to_connect,
|
||||
grpc_connectivity_state* state) {
|
||||
TRY CHK_PTR_ARG(state) UINTPTR_TO_RDC_CHAN(channel)
|
||||
|
||||
*state = ch->channel()->GetState(try_to_connect);
|
||||
* state = ch->channel()->GetState(try_to_connect);
|
||||
return RDC_STATUS_SUCCESS;
|
||||
|
||||
CATCH
|
||||
}
|
||||
|
||||
rdc_status_t
|
||||
rdc_channel_connection_verify(rdc_channel_t channel) {
|
||||
TRY
|
||||
UINTPTR_TO_RDC_CHAN(channel)
|
||||
rdc_status_t rdc_channel_connection_verify(rdc_channel_t channel) {
|
||||
TRY UINTPTR_TO_RDC_CHAN(channel)
|
||||
|
||||
::rdc::VerifyConnectionResponse resp;
|
||||
::rdc::VerifyConnectionResponse resp;
|
||||
::rdc::VerifyConnectionRequest req;
|
||||
::grpc::ClientContext context;
|
||||
unsigned int seed = time(NULL);
|
||||
|
||||
req.set_magic_num(static_cast<uint64_t>(rand_r(&seed)));
|
||||
::grpc::Status status =
|
||||
ch->rdc_admin_stub()->VerifyConnection(&context, req, &resp);
|
||||
::grpc::Status status = ch->rdc_admin_stub()->VerifyConnection(&context, req, &resp);
|
||||
|
||||
if (!status.ok()) {
|
||||
return amd::rdc::GrpcErrorToRdcError(status.error_code());
|
||||
@@ -155,29 +151,23 @@ rdc_channel_connection_verify(rdc_channel_t channel) {
|
||||
CATCH
|
||||
}
|
||||
|
||||
rdc_status_t
|
||||
rdc_channel_destroy(rdc_channel_t channel) {
|
||||
TRY
|
||||
UINTPTR_TO_RDC_CHAN(channel)
|
||||
rdc_status_t rdc_channel_destroy(rdc_channel_t channel) {
|
||||
TRY UINTPTR_TO_RDC_CHAN(channel)
|
||||
|
||||
delete ch;
|
||||
delete ch;
|
||||
|
||||
return RDC_STATUS_SUCCESS;
|
||||
|
||||
CATCH
|
||||
}
|
||||
|
||||
rdc_status_t
|
||||
rdc_num_gpus_get(rdc_channel_t channel, uint64_t *num_gpu) {
|
||||
TRY
|
||||
CHK_PTR_ARG(num_gpu)
|
||||
UINTPTR_TO_RDC_CHAN(channel)
|
||||
rdc_status_t rdc_num_gpus_get(rdc_channel_t channel, uint64_t* num_gpu) {
|
||||
TRY CHK_PTR_ARG(num_gpu) UINTPTR_TO_RDC_CHAN(channel)
|
||||
|
||||
::rdc::GetNumDevicesResponse resp;
|
||||
::rdc::GetNumDevicesResponse resp;
|
||||
::rdc::GetNumDevicesRequest empty;
|
||||
::grpc::ClientContext context;
|
||||
::grpc::Status status =
|
||||
ch->rsmi_stub()->GetNumDevices(&context, empty, &resp);
|
||||
::grpc::Status status = ch->rsmi_stub()->GetNumDevices(&context, empty, &resp);
|
||||
|
||||
if (!status.ok()) {
|
||||
return amd::rdc::GrpcErrorToRdcError(status.error_code());
|
||||
@@ -191,21 +181,16 @@ rdc_num_gpus_get(rdc_channel_t channel, uint64_t *num_gpu) {
|
||||
|
||||
// rsmi and rdc currently happen to have a 1-to-1 mapping, but
|
||||
// have this function in case that changes
|
||||
static ::rdc::GetTemperatureRequest_TemperatureMetric
|
||||
rsmi_temp2rdc_temp(rsmi_temperature_metric_t rsmi_temp) {
|
||||
return
|
||||
static_cast<::rdc::GetTemperatureRequest_TemperatureMetric>(rsmi_temp);
|
||||
static ::rdc::GetTemperatureRequest_TemperatureMetric rsmi_temp2rdc_temp(
|
||||
rsmi_temperature_metric_t rsmi_temp) {
|
||||
return static_cast<::rdc::GetTemperatureRequest_TemperatureMetric>(rsmi_temp);
|
||||
}
|
||||
|
||||
rdc_status_t
|
||||
rdc_dev_temp_metric_get(rdc_channel_t channel, uint32_t dv_ind,
|
||||
uint32_t sensor_type, rsmi_temperature_metric_t metric,
|
||||
int64_t *temperature) {
|
||||
TRY
|
||||
CHK_PTR_ARG(temperature)
|
||||
UINTPTR_TO_RDC_CHAN(channel)
|
||||
rdc_status_t rdc_dev_temp_metric_get(rdc_channel_t channel, uint32_t dv_ind, uint32_t sensor_type,
|
||||
rsmi_temperature_metric_t metric, int64_t* temperature) {
|
||||
TRY CHK_PTR_ARG(temperature) UINTPTR_TO_RDC_CHAN(channel)
|
||||
|
||||
::rdc::GetTemperatureResponse resp;
|
||||
::rdc::GetTemperatureResponse resp;
|
||||
::rdc::GetTemperatureRequest in_args;
|
||||
::grpc::ClientContext context;
|
||||
|
||||
@@ -213,8 +198,7 @@ rdc_dev_temp_metric_get(rdc_channel_t channel, uint32_t dv_ind,
|
||||
in_args.set_dv_ind(dv_ind);
|
||||
in_args.set_sensor_type(sensor_type);
|
||||
|
||||
::grpc::Status status =
|
||||
ch->rsmi_stub()->GetTemperature(&context, in_args, &resp);
|
||||
::grpc::Status status = ch->rsmi_stub()->GetTemperature(&context, in_args, &resp);
|
||||
|
||||
if (!status.ok()) {
|
||||
return ::amd::rdc::GrpcErrorToRdcError(status.error_code());
|
||||
@@ -226,22 +210,18 @@ rdc_dev_temp_metric_get(rdc_channel_t channel, uint32_t dv_ind,
|
||||
CATCH
|
||||
}
|
||||
|
||||
rdc_status_t
|
||||
rdc_dev_fan_rpms_get(rdc_channel_t channel, uint32_t dv_ind,
|
||||
uint32_t sensor_ind, int64_t *rpms) {
|
||||
TRY
|
||||
CHK_PTR_ARG(rpms)
|
||||
UINTPTR_TO_RDC_CHAN(channel)
|
||||
rdc_status_t rdc_dev_fan_rpms_get(rdc_channel_t channel, uint32_t dv_ind, uint32_t sensor_ind,
|
||||
int64_t* rpms) {
|
||||
TRY CHK_PTR_ARG(rpms) UINTPTR_TO_RDC_CHAN(channel)
|
||||
|
||||
::rdc::GetFanRpmsResponse resp;
|
||||
::rdc::GetFanRpmsResponse resp;
|
||||
::rdc::GetFanRpmsRequest in_args;
|
||||
::grpc::ClientContext context;
|
||||
|
||||
in_args.set_dv_ind(dv_ind);
|
||||
in_args.set_sensor_ind(sensor_ind);
|
||||
|
||||
::grpc::Status status =
|
||||
ch->rsmi_stub()->GetFanRpms(&context, in_args, &resp);
|
||||
::grpc::Status status = ch->rsmi_stub()->GetFanRpms(&context, in_args, &resp);
|
||||
|
||||
if (!status.ok()) {
|
||||
return ::amd::rdc::GrpcErrorToRdcError(status.error_code());
|
||||
@@ -253,22 +233,18 @@ rdc_dev_fan_rpms_get(rdc_channel_t channel, uint32_t dv_ind,
|
||||
CATCH
|
||||
}
|
||||
|
||||
rdc_status_t
|
||||
rdc_dev_fan_speed_get(rdc_channel_t channel, uint32_t dv_ind,
|
||||
uint32_t sensor_ind, int64_t *speed) {
|
||||
TRY
|
||||
CHK_PTR_ARG(speed)
|
||||
UINTPTR_TO_RDC_CHAN(channel)
|
||||
rdc_status_t rdc_dev_fan_speed_get(rdc_channel_t channel, uint32_t dv_ind, uint32_t sensor_ind,
|
||||
int64_t* speed) {
|
||||
TRY CHK_PTR_ARG(speed) UINTPTR_TO_RDC_CHAN(channel)
|
||||
|
||||
::rdc::GetFanSpeedResponse resp;
|
||||
::rdc::GetFanSpeedResponse resp;
|
||||
::rdc::GetFanSpeedRequest in_args;
|
||||
::grpc::ClientContext context;
|
||||
|
||||
in_args.set_dv_ind(dv_ind);
|
||||
in_args.set_sensor_ind(sensor_ind);
|
||||
|
||||
::grpc::Status status =
|
||||
ch->rsmi_stub()->GetFanSpeed(&context, in_args, &resp);
|
||||
::grpc::Status status = ch->rsmi_stub()->GetFanSpeed(&context, in_args, &resp);
|
||||
|
||||
if (!status.ok()) {
|
||||
return ::amd::rdc::GrpcErrorToRdcError(status.error_code());
|
||||
@@ -280,22 +256,18 @@ rdc_dev_fan_speed_get(rdc_channel_t channel, uint32_t dv_ind,
|
||||
CATCH
|
||||
}
|
||||
|
||||
rdc_status_t
|
||||
rdc_dev_fan_speed_max_get(rdc_channel_t channel, uint32_t dv_ind,
|
||||
uint32_t sensor_ind, uint64_t *max_speed) {
|
||||
TRY
|
||||
CHK_PTR_ARG(max_speed)
|
||||
UINTPTR_TO_RDC_CHAN(channel)
|
||||
rdc_status_t rdc_dev_fan_speed_max_get(rdc_channel_t channel, uint32_t dv_ind, uint32_t sensor_ind,
|
||||
uint64_t* max_speed) {
|
||||
TRY CHK_PTR_ARG(max_speed) UINTPTR_TO_RDC_CHAN(channel)
|
||||
|
||||
::rdc::GetFanSpeedMaxResponse resp;
|
||||
::rdc::GetFanSpeedMaxResponse resp;
|
||||
::rdc::GetFanSpeedMaxRequest in_args;
|
||||
::grpc::ClientContext context;
|
||||
|
||||
in_args.set_dv_ind(dv_ind);
|
||||
in_args.set_sensor_ind(sensor_ind);
|
||||
|
||||
::grpc::Status status =
|
||||
ch->rsmi_stub()->GetFanSpeedMax(&context, in_args, &resp);
|
||||
::grpc::Status status = ch->rsmi_stub()->GetFanSpeedMax(&context, in_args, &resp);
|
||||
|
||||
if (!status.ok()) {
|
||||
return ::amd::rdc::GrpcErrorToRdcError(status.error_code());
|
||||
@@ -307,89 +279,97 @@ rdc_dev_fan_speed_max_get(rdc_channel_t channel, uint32_t dv_ind,
|
||||
CATCH
|
||||
}
|
||||
|
||||
rdc_status_t
|
||||
rdc_status_string(rdc_status_t status, const char **status_string) {
|
||||
TRY
|
||||
if (status_string == nullptr) {
|
||||
return RDC_RSMI_STATUS_INVALID_ARGS;
|
||||
}
|
||||
rdc_status_t rdc_status_string(rdc_status_t status, const char** status_string) {
|
||||
TRY if (status_string == nullptr) { return RDC_RSMI_STATUS_INVALID_ARGS; }
|
||||
|
||||
const size_t status_u = static_cast<size_t>(status);
|
||||
switch (status_u) {
|
||||
case RDC_STATUS_SUCCESS:
|
||||
*status_string = "RDC_STATUS_SUCCESS: The function has been executed"
|
||||
" successfully.";
|
||||
*status_string =
|
||||
"RDC_STATUS_SUCCESS: The function has been executed"
|
||||
" successfully.";
|
||||
break;
|
||||
|
||||
case RDC_RSMI_STATUS_INVALID_ARGS:
|
||||
*status_string =
|
||||
"RDC_RSMI_STATUS_INVALID_ARGS: The provided arguments do not"
|
||||
" meet the preconditions required for calling this function.";
|
||||
" meet the preconditions required for calling this function.";
|
||||
break;
|
||||
|
||||
case RDC_RSMI_STATUS_NOT_SUPPORTED:
|
||||
*status_string = "RDC_RSMI_STATUS_NOT_SUPPORTED: This function is not"
|
||||
" supported in the current environment.";
|
||||
*status_string =
|
||||
"RDC_RSMI_STATUS_NOT_SUPPORTED: This function is not"
|
||||
" supported in the current environment.";
|
||||
break;
|
||||
|
||||
case RDC_RSMI_STATUS_FILE_ERROR:
|
||||
*status_string =
|
||||
"RDC_RSMI_STATUS_FILE_ERROR: There was an error in finding or"
|
||||
" opening a file or directory. The operation may not be supported by "
|
||||
"this Linux kernel version.";
|
||||
"RDC_RSMI_STATUS_FILE_ERROR: There was an error in finding or"
|
||||
" opening a file or directory. The operation may not be supported by "
|
||||
"this Linux kernel version.";
|
||||
break;
|
||||
|
||||
case RDC_RSMI_STATUS_PERMISSION:
|
||||
*status_string = "RDC_RSMI_STATUS_PERMISSION: The user ID of the calling"
|
||||
" process does not have sufficient permission to execute a command."
|
||||
" Often this is fixed by running as root (sudo).";
|
||||
*status_string =
|
||||
"RDC_RSMI_STATUS_PERMISSION: The user ID of the calling"
|
||||
" process does not have sufficient permission to execute a command."
|
||||
" Often this is fixed by running as root (sudo).";
|
||||
break;
|
||||
|
||||
case RDC_RSMI_STATUS_OUT_OF_RESOURCES:
|
||||
*status_string = "RDC_RSMI_STATUS_OUT_OF_RESOURCES: Unable to acquire "
|
||||
*status_string =
|
||||
"RDC_RSMI_STATUS_OUT_OF_RESOURCES: Unable to acquire "
|
||||
"memory or other resource";
|
||||
break;
|
||||
|
||||
case RDC_RSMI_STATUS_INTERNAL_EXCEPTION:
|
||||
*status_string = "RDC_RSMI_STATUS_INTERNAL_EXCEPTION: An internal "
|
||||
*status_string =
|
||||
"RDC_RSMI_STATUS_INTERNAL_EXCEPTION: An internal "
|
||||
"exception was caught";
|
||||
break;
|
||||
|
||||
case RDC_RSMI_STATUS_INPUT_OUT_OF_BOUNDS:
|
||||
*status_string = "RDC_RSMI_STATUS_INPUT_OUT_OF_BOUNDS: The provided "
|
||||
*status_string =
|
||||
"RDC_RSMI_STATUS_INPUT_OUT_OF_BOUNDS: The provided "
|
||||
"input is out of allowable or safe range";
|
||||
break;
|
||||
|
||||
case RDC_RSMI_STATUS_INIT_ERROR:
|
||||
*status_string = "RDC_RSMI_STATUS_INIT_ERROR: An error occurred during "
|
||||
*status_string =
|
||||
"RDC_RSMI_STATUS_INIT_ERROR: An error occurred during "
|
||||
"initialization, during "
|
||||
"monitor discovery or when when initializing internal data structures";
|
||||
"monitor discovery or when when initializing internal data structures";
|
||||
break;
|
||||
|
||||
case RDC_RSMI_STATUS_NOT_YET_IMPLEMENTED:
|
||||
*status_string = "RDC_RSMI_STATUS_NOT_YET_IMPLEMENTED: The called "
|
||||
*status_string =
|
||||
"RDC_RSMI_STATUS_NOT_YET_IMPLEMENTED: The called "
|
||||
"function has not been implemented in this "
|
||||
"system for this device type";
|
||||
"system for this device type";
|
||||
break;
|
||||
|
||||
case RDC_RSMI_STATUS_NOT_FOUND:
|
||||
*status_string = "RDC_RSMI_STATUS_NOT_FOUND: An item required to "
|
||||
*status_string =
|
||||
"RDC_RSMI_STATUS_NOT_FOUND: An item required to "
|
||||
"complete the call was not found";
|
||||
break;
|
||||
|
||||
case RDC_RSMI_STATUS_INSUFFICIENT_SIZE:
|
||||
*status_string = "RDC_RSMI_STATUS_INSUFFICIENT_SIZE: Not enough "
|
||||
*status_string =
|
||||
"RDC_RSMI_STATUS_INSUFFICIENT_SIZE: Not enough "
|
||||
"resources were available to fully execute"
|
||||
" the call";
|
||||
" the call";
|
||||
break;
|
||||
|
||||
case RDC_RSMI_STATUS_UNKNOWN_ERROR:
|
||||
*status_string = "An unknown error prevented the call from completing"
|
||||
" successfully";
|
||||
*status_string =
|
||||
"An unknown error prevented the call from completing"
|
||||
" successfully";
|
||||
break;
|
||||
|
||||
case RDC_RSMI_STATUS_INTERRUPT:
|
||||
*status_string = "RDC_RSMI_STATUS_INTERRUPT An interrupt occurred while "
|
||||
*status_string =
|
||||
"RDC_RSMI_STATUS_INTERRUPT An interrupt occurred while "
|
||||
"executing the function";
|
||||
break;
|
||||
|
||||
@@ -401,31 +381,31 @@ rdc_status_string(rdc_status_t status, const char **status_string) {
|
||||
|
||||
case RDC_STATUS_GRPC_UNKNOWN:
|
||||
*status_string =
|
||||
"RDC_STATUS_GRPC_UNKNOWN Unknown error. An example of where this error"
|
||||
" may be returned is if a"
|
||||
"Status value received from another address space belongs to an error-"
|
||||
"space that is not known in this address space. Also errors raised by "
|
||||
"APIs that do not return enough error information may be converted to "
|
||||
"this error.";
|
||||
"RDC_STATUS_GRPC_UNKNOWN Unknown error. An example of where this error"
|
||||
" may be returned is if a"
|
||||
"Status value received from another address space belongs to an error-"
|
||||
"space that is not known in this address space. Also errors raised by "
|
||||
"APIs that do not return enough error information may be converted to "
|
||||
"this error.";
|
||||
break;
|
||||
|
||||
case RDC_STATUS_GRPC_INVALID_ARG:
|
||||
*status_string =
|
||||
"RDC_STATUS_GRPC_INVALID_ARG Client specified an invalid argument. "
|
||||
"Note that this differs from"
|
||||
"FAILED_PRECONDITION. INVALID_ARGUMENT indicates arguments that are "
|
||||
"problematic regardless of the state of the system (e.g., a malformed "
|
||||
"file name).";
|
||||
"RDC_STATUS_GRPC_INVALID_ARG Client specified an invalid argument. "
|
||||
"Note that this differs from"
|
||||
"FAILED_PRECONDITION. INVALID_ARGUMENT indicates arguments that are "
|
||||
"problematic regardless of the state of the system (e.g., a malformed "
|
||||
"file name).";
|
||||
break;
|
||||
|
||||
case RDC_STATUS_GRPC_DEADLINE_EXCEEDED:
|
||||
*status_string =
|
||||
"RDC_STATUS_GRPC_DEADLINE_EXCEEDED Deadline expired before operation "
|
||||
"could complete. For operations that"
|
||||
"change the state of the system, this error may be returned even if "
|
||||
"the operation has completed successfully. For example, a successful "
|
||||
"response from a server could have been delayed long enough for the "
|
||||
"deadline to expire.";
|
||||
"RDC_STATUS_GRPC_DEADLINE_EXCEEDED Deadline expired before operation "
|
||||
"could complete. For operations that"
|
||||
"change the state of the system, this error may be returned even if "
|
||||
"the operation has completed successfully. For example, a successful "
|
||||
"response from a server could have been delayed long enough for the "
|
||||
"deadline to expire.";
|
||||
break;
|
||||
|
||||
case RDC_STATUS_GRPC_NOT_FOUND:
|
||||
@@ -436,130 +416,129 @@ rdc_status_string(rdc_status_t status, const char **status_string) {
|
||||
|
||||
case RDC_STATUS_GRPC_ALREADY_EXISTS:
|
||||
*status_string =
|
||||
"RDC_STATUS_GRPC_ALREADY_EXISTS Some entity that we attempted to create "
|
||||
"(e.g., file or directory) already exists.";
|
||||
"RDC_STATUS_GRPC_ALREADY_EXISTS Some entity that we "
|
||||
"attempted to create "
|
||||
"(e.g., file or directory) already exists.";
|
||||
break;
|
||||
|
||||
case RDC_STATUS_GRPC_PERM_DENIED:
|
||||
*status_string =
|
||||
"RDC_STATUS_GRPC_PERM_DENIED The caller does not have permission to "
|
||||
"execute the specified operation."
|
||||
"PERMISSION_DENIED must not be used for rejections caused by "
|
||||
"exhausting some resource (use RESOURCE_EXHAUSTED instead for those "
|
||||
"errors). PERMISSION_DENIED must not be used if the caller can not "
|
||||
" be identified (use UNAUTHENTICATED instead for those errors).";
|
||||
"RDC_STATUS_GRPC_PERM_DENIED The caller does not have permission to "
|
||||
"execute the specified operation."
|
||||
"PERMISSION_DENIED must not be used for rejections caused by "
|
||||
"exhausting some resource (use RESOURCE_EXHAUSTED instead for those "
|
||||
"errors). PERMISSION_DENIED must not be used if the caller can not "
|
||||
" be identified (use UNAUTHENTICATED instead for those errors).";
|
||||
break;
|
||||
|
||||
case RDC_STATUS_GRPC_UNAUTHENTICATED:
|
||||
*status_string =
|
||||
"RDC_STATUS_GRPC_UNAUTHENTICATED The request does not have valid "
|
||||
"authentication credentials for the operation.";
|
||||
"RDC_STATUS_GRPC_UNAUTHENTICATED The request does not have valid "
|
||||
"authentication credentials for the operation.";
|
||||
break;
|
||||
|
||||
case RDC_STATUS_GRPC_RESOURCE_EXHAUSTED:
|
||||
*status_string =
|
||||
"RDC_STATUS_GRPC_RESOURCE_EXHAUSTED Some resource has been exhausted, "
|
||||
"perhaps a per-user quota, or perhaps the "
|
||||
"entire file system is out of space.";
|
||||
"RDC_STATUS_GRPC_RESOURCE_EXHAUSTED Some resource has been exhausted, "
|
||||
"perhaps a per-user quota, or perhaps the "
|
||||
"entire file system is out of space.";
|
||||
break;
|
||||
|
||||
case RDC_STATUS_GRPC_FAILED_PRECOND:
|
||||
*status_string =
|
||||
"RDC_STATUS_GRPC_FAILED_PRECOND Operation was rejected because the "
|
||||
"system is not in a state required for "
|
||||
"the operation's execution. For example, directory to be deleted may "
|
||||
"be non-empty, an rmdir operation is applied to a non-directory, etc.\n"
|
||||
"A litmus test that may help a service implementor in deciding "
|
||||
"between FAILED_PRECONDITION, ABORTED, and UNAVAILABLE:\n"
|
||||
" (a) Use UNAVAILABLE if the client can retry just the failing call.\n"
|
||||
" (b) Use ABORTED if the client should retry at a higher-level "
|
||||
" (e.g., restarting a read-modify-write sequence).\n"
|
||||
" (c) Use FAILED_PRECONDITION if the client should not retry until"
|
||||
" the system state has been explicitly fixed. E.g., if an \"rmdir\""
|
||||
" fails because the directory is non-empty, FAILED_PRECONDITION"
|
||||
" should be returned since the client should not retry unless"
|
||||
" they have first fixed up the directory by deleting files from it.\n"
|
||||
" (d) Use FAILED_PRECONDITION if the client performs conditional"
|
||||
" REST Get/Update/Delete on a resource and the resource on the"
|
||||
" server does not match the condition. E.g., conflicting"
|
||||
" read-modify-write on the same resource.";
|
||||
"RDC_STATUS_GRPC_FAILED_PRECOND Operation was rejected because the "
|
||||
"system is not in a state required for "
|
||||
"the operation's execution. For example, directory to be deleted may "
|
||||
"be non-empty, an rmdir operation is applied to a non-directory, etc.\n"
|
||||
"A litmus test that may help a service implementor in deciding "
|
||||
"between FAILED_PRECONDITION, ABORTED, and UNAVAILABLE:\n"
|
||||
" (a) Use UNAVAILABLE if the client can retry just the failing call.\n"
|
||||
" (b) Use ABORTED if the client should retry at a higher-level "
|
||||
" (e.g., restarting a read-modify-write sequence).\n"
|
||||
" (c) Use FAILED_PRECONDITION if the client should not retry until"
|
||||
" the system state has been explicitly fixed. E.g., if an \"rmdir\""
|
||||
" fails because the directory is non-empty, FAILED_PRECONDITION"
|
||||
" should be returned since the client should not retry unless"
|
||||
" they have first fixed up the directory by deleting files from it.\n"
|
||||
" (d) Use FAILED_PRECONDITION if the client performs conditional"
|
||||
" REST Get/Update/Delete on a resource and the resource on the"
|
||||
" server does not match the condition. E.g., conflicting"
|
||||
" read-modify-write on the same resource.";
|
||||
break;
|
||||
|
||||
case RDC_STATUS_GRPC_ABORTED:
|
||||
*status_string =
|
||||
"RDC_STATUS_GRPC_ABORTED The operation was aborted, "
|
||||
"typically due to a concurrency issue like "
|
||||
"sequencer check failures, transaction aborts, etc.\n"
|
||||
"See litmus test above for deciding between "
|
||||
"FAILED_PRECONDITION, ABORTED, "
|
||||
"and UNAVAILABLE.";
|
||||
"RDC_STATUS_GRPC_ABORTED The operation was aborted, "
|
||||
"typically due to a concurrency issue like "
|
||||
"sequencer check failures, transaction aborts, etc.\n"
|
||||
"See litmus test above for deciding between "
|
||||
"FAILED_PRECONDITION, ABORTED, "
|
||||
"and UNAVAILABLE.";
|
||||
break;
|
||||
|
||||
case RDC_STATUS_GRPC_OUT_OF_RANGE:
|
||||
*status_string =
|
||||
"RDC_STATUS_GRPC_OUT_OF_RANGE Operation was attempted "
|
||||
"past the valid range. E.g., seeking or reading "
|
||||
"past end of file.\n"
|
||||
"Unlike INVALID_ARGUMENT, this error indicates a "
|
||||
"problem that may be fixed "
|
||||
"if the system state changes. For example, a 32-bit file system will "
|
||||
"generate INVALID_ARGUMENT if asked to read "
|
||||
"at an offset that is not in the "
|
||||
"range [0,2^32-1], but it will generate "
|
||||
"OUT_OF_RANGE if asked to read from "
|
||||
"an offset past the current file size.\n"
|
||||
"There is a fair bit of overlap between FAILED_PRECONDITION and "
|
||||
"OUT_OF_RANGE. We recommend using OUT_OF_RANGE "
|
||||
"(the more specific error) "
|
||||
"when it applies so that callers who are "
|
||||
"iterating through a space can "
|
||||
"easily look for an OUT_OF_RANGE error to detect when they are done.";
|
||||
"RDC_STATUS_GRPC_OUT_OF_RANGE Operation was attempted "
|
||||
"past the valid range. E.g., seeking or reading "
|
||||
"past end of file.\n"
|
||||
"Unlike INVALID_ARGUMENT, this error indicates a "
|
||||
"problem that may be fixed "
|
||||
"if the system state changes. For example, a 32-bit file system will "
|
||||
"generate INVALID_ARGUMENT if asked to read "
|
||||
"at an offset that is not in the "
|
||||
"range [0,2^32-1], but it will generate "
|
||||
"OUT_OF_RANGE if asked to read from "
|
||||
"an offset past the current file size.\n"
|
||||
"There is a fair bit of overlap between FAILED_PRECONDITION and "
|
||||
"OUT_OF_RANGE. We recommend using OUT_OF_RANGE "
|
||||
"(the more specific error) "
|
||||
"when it applies so that callers who are "
|
||||
"iterating through a space can "
|
||||
"easily look for an OUT_OF_RANGE error to detect when they are done.";
|
||||
break;
|
||||
|
||||
case RDC_STATUS_GRPC_UNIMPLEMENTED:
|
||||
*status_string =
|
||||
"RDC_STATUS_GRPC_UNIMPLEMENTED Operation is not "
|
||||
"implemented or not supported/enabled in this service.";
|
||||
"RDC_STATUS_GRPC_UNIMPLEMENTED Operation is not "
|
||||
"implemented or not supported/enabled in this service.";
|
||||
break;
|
||||
|
||||
case RDC_STATUS_GRPC_INTERNAL:
|
||||
*status_string =
|
||||
"RDC_STATUS_GRPC_INTERNAL Internal errors. This means "
|
||||
"some invariants expected by underlying System has "
|
||||
"been broken. If you see one of these errors.";
|
||||
"RDC_STATUS_GRPC_INTERNAL Internal errors. This means "
|
||||
"some invariants expected by underlying System has "
|
||||
"been broken. If you see one of these errors.";
|
||||
break;
|
||||
|
||||
case RDC_STATUS_GRPC_UNAVAILABLE:
|
||||
*status_string =
|
||||
"RDC_STATUS_GRPC_UNAVAILABLE The service is currently unavailable. "
|
||||
"This is a most likely a transient "
|
||||
"condition and may be corrected by retrying with a backoff.\n"
|
||||
"Warning: Although data MIGHT not have been transmitted when this "
|
||||
"status occurs, there is NOT A GUARANTEE that the server has not seen "
|
||||
"anything. So in general it is unsafe to retry on this status code "
|
||||
"if the call is non-idempotent. "
|
||||
"See litmus test above for deciding between "
|
||||
"FAILED_PRECONDITION, ABORTED,"
|
||||
"and UNAVAILABLE.";
|
||||
"RDC_STATUS_GRPC_UNAVAILABLE The service is currently unavailable. "
|
||||
"This is a most likely a transient "
|
||||
"condition and may be corrected by retrying with a backoff.\n"
|
||||
"Warning: Although data MIGHT not have been transmitted when this "
|
||||
"status occurs, there is NOT A GUARANTEE that the server has not seen "
|
||||
"anything. So in general it is unsafe to retry on this status code "
|
||||
"if the call is non-idempotent. "
|
||||
"See litmus test above for deciding between "
|
||||
"FAILED_PRECONDITION, ABORTED,"
|
||||
"and UNAVAILABLE.";
|
||||
break;
|
||||
|
||||
case RDC_STATUS_GRPC_DATA_LOSS:
|
||||
*status_string =
|
||||
"RDC_STATUS_GRPC_DATA_LOSS Unrecoverable data loss or corruption.";
|
||||
*status_string = "RDC_STATUS_GRPC_DATA_LOSS Unrecoverable data loss or corruption.";
|
||||
break;
|
||||
|
||||
case RDC_STATUS_UNKNOWN_ERROR:
|
||||
*status_string =
|
||||
"RDC_STATUS_UNKNOWN_ERROR An unknown RDC error occurred.";
|
||||
*status_string = "RDC_STATUS_UNKNOWN_ERROR An unknown RDC error occurred.";
|
||||
break;
|
||||
|
||||
case RDC_STATUS_CLIENT_ERR_SSL:
|
||||
*status_string =
|
||||
"An error occurred when executing SSL authentication operations.";
|
||||
*status_string = "An error occurred when executing SSL authentication operations.";
|
||||
break;
|
||||
|
||||
default:
|
||||
*status_string = "RDC_RSMI_STATUS_UNKNOWN_ERROR An "
|
||||
*status_string =
|
||||
"RDC_RSMI_STATUS_UNKNOWN_ERROR An "
|
||||
"unknown error occurred";
|
||||
return RDC_RSMI_STATUS_UNKNOWN_ERROR;
|
||||
}
|
||||
|
||||
Inrite → Rialta
+18
-28
@@ -21,46 +21,39 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "rdc/rdc_client_main.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <grpcpp/grpcpp.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "rdc.grpc.pb.h" // NOLINT
|
||||
#include "rdc/rdc_client_main.h"
|
||||
#include "rdc/rdc_client.h"
|
||||
#include "common/rdc_utils.h"
|
||||
#include "rdc.grpc.pb.h" // NOLINT
|
||||
#include "rdc/rdc_client.h"
|
||||
|
||||
namespace amd {
|
||||
namespace rdc {
|
||||
|
||||
#ifdef USE_PINNED_CERTS
|
||||
// Pinned certificates
|
||||
static const char *kDefaultRDCServerCertPinPath =
|
||||
"/etc/rdc/server/rdc_server.crt";
|
||||
static const char *kDefaultRDCClientKeyPinPath =
|
||||
"/etc/rdc/client/private/rdc_client.key";
|
||||
static const char *kDefaultRDCClientCertPinPath =
|
||||
"/etc/rdc/client/rdc_client.crt";
|
||||
static const char* kDefaultRDCServerCertPinPath = "/etc/rdc/server/rdc_server.crt";
|
||||
static const char* kDefaultRDCClientKeyPinPath = "/etc/rdc/client/private/rdc_client.key";
|
||||
static const char* kDefaultRDCClientCertPinPath = "/etc/rdc/client/rdc_client.crt";
|
||||
#endif // USE_PINNED_CERTS
|
||||
|
||||
// PKI certificates
|
||||
static const char * kDefaultRDCClientCertKeyPkiPath =
|
||||
"/etc/rdc/client/private/rdc_client_cert.key";
|
||||
static const char * kDefaultRDCClientCertPemPkiPath =
|
||||
"/etc/rdc/client/certs/rdc_client_cert.pem";
|
||||
static const char * kDefaultRDCClientCACertPemPkiPath =
|
||||
"/etc/rdc/client/certs/rdc_cacert.pem";
|
||||
static const char* kDefaultRDCClientCertKeyPkiPath = "/etc/rdc/client/private/rdc_client_cert.key";
|
||||
static const char* kDefaultRDCClientCertPemPkiPath = "/etc/rdc/client/certs/rdc_client_cert.pem";
|
||||
static const char* kDefaultRDCClientCACertPemPkiPath = "/etc/rdc/client/certs/rdc_cacert.pem";
|
||||
|
||||
RDCChannel::RDCChannel(std::string server_ip, std::string server_port,
|
||||
bool secure) : server_ip_(server_ip), server_port_(server_port),
|
||||
secure_channel_(secure) {}
|
||||
RDCChannel::RDCChannel(std::string server_ip, std::string server_port, bool secure)
|
||||
: server_ip_(server_ip), server_port_(server_port), secure_channel_(secure) {}
|
||||
|
||||
RDCChannel::~RDCChannel() {
|
||||
}
|
||||
RDCChannel::~RDCChannel() {}
|
||||
|
||||
#ifdef USE_PINNED_CERTS
|
||||
static int ConstructSSLOptsPin(grpc::SslCredentialsOptions *ssl_opts) {
|
||||
static int ConstructSSLOptsPin(grpc::SslCredentialsOptions* ssl_opts) {
|
||||
assert(ssl_opts != nullptr);
|
||||
if (ssl_opts == nullptr) {
|
||||
return -EINVAL;
|
||||
@@ -100,7 +93,7 @@ static int ConstructSSLOptsPin(grpc::SslCredentialsOptions *ssl_opts) {
|
||||
}
|
||||
#endif // USE_PINNED_CERTS
|
||||
|
||||
static int ConstructSSLOptsPKI(grpc::SslCredentialsOptions *ssl_opts) {
|
||||
static int ConstructSSLOptsPKI(grpc::SslCredentialsOptions* ssl_opts) {
|
||||
assert(ssl_opts != nullptr);
|
||||
if (ssl_opts == nullptr) {
|
||||
return -EINVAL;
|
||||
@@ -139,8 +132,7 @@ static int ConstructSSLOptsPKI(grpc::SslCredentialsOptions *ssl_opts) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
rdc_status_t
|
||||
RDCChannel::Initialize(void) {
|
||||
rdc_status_t RDCChannel::Initialize(void) {
|
||||
assert(!server_port_.empty());
|
||||
assert(!server_ip_.empty());
|
||||
|
||||
@@ -157,16 +149,14 @@ RDCChannel::Initialize(void) {
|
||||
ret = ConstructSSLOptsPKI(&ssl_opts);
|
||||
#endif
|
||||
if (ret) {
|
||||
std::cerr << "Failed to process OpenSSL keys and certificates." <<
|
||||
std::endl;
|
||||
std::cerr << "Failed to process OpenSSL keys and certificates." << std::endl;
|
||||
return RDC_STATUS_CLIENT_ERR_SSL;
|
||||
}
|
||||
|
||||
channel_creds_ = grpc::SslCredentials(ssl_opts);
|
||||
channel_ = grpc::CreateChannel(addr_str, channel_creds_);
|
||||
} else {
|
||||
channel_ = ::grpc::CreateChannel(addr_str,
|
||||
grpc::InsecureChannelCredentials());
|
||||
channel_ = ::grpc::CreateChannel(addr_str, grpc::InsecureChannelCredentials());
|
||||
}
|
||||
|
||||
rsmi_stub_ = ::rdc::Rsmi::NewStub(channel_);
|
||||
|
||||
Inrite → Rialta
+4
-4
@@ -20,17 +20,17 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "rdc/rdc_client.h"
|
||||
#include "rdc.grpc.pb.h" // NOLINT
|
||||
#include "rdc/rdc_client_utils.h"
|
||||
|
||||
#include "rdc.grpc.pb.h" // NOLINT
|
||||
#include "rdc/rdc_client.h"
|
||||
|
||||
namespace amd {
|
||||
namespace rdc {
|
||||
|
||||
rdc_status_t GrpcErrorToRdcError(grpc::StatusCode grpc_err) {
|
||||
uint32_t grpc_err_int = static_cast<uint32_t>(grpc_err);
|
||||
uint32_t rdc_grpc_base_int =
|
||||
static_cast<uint32_t>(RDC_STATUS_GRPC_ERR_FIRST);
|
||||
uint32_t rdc_grpc_base_int = static_cast<uint32_t>(RDC_STATUS_GRPC_ERR_FIRST);
|
||||
uint32_t rdc_err_int = grpc_err_int + rdc_grpc_base_int;
|
||||
|
||||
return static_cast<rdc_status_t>(rdc_err_int);
|
||||
|
||||
Tagairt in Eagrán Nua
Cuir bac ar úsáideoir