Implement the discovery -v command line interface
Call the previously implemented get_rdcd_version and rdc_get_smiversion
Change-Id: If76037d462fa9328c3af8c85423ee4547882e36e
Signed-off-by: Chen Gong <curry.gong@amd.com>
[ROCm/rdc commit: 0cfca6d93d]
このコミットが含まれているのは:
@@ -38,6 +38,8 @@ class RdciDiscoverySubSystem : public RdciSubSystem {
|
||||
void show_help() const;
|
||||
bool is_list_;
|
||||
void show_attributes();
|
||||
bool show_version_;
|
||||
void show_version();
|
||||
};
|
||||
|
||||
} // namespace rdc
|
||||
|
||||
@@ -25,6 +25,7 @@ THE SOFTWARE.
|
||||
#include <unistd.h>
|
||||
|
||||
#include "rdc/rdc.h"
|
||||
#include "rdc/rdc_private.h"
|
||||
#include "rdc_lib/RdcException.h"
|
||||
#include "rdc_lib/rdc_common.h"
|
||||
|
||||
@@ -33,7 +34,8 @@ namespace rdc {
|
||||
|
||||
RdciDiscoverySubSystem::RdciDiscoverySubSystem()
|
||||
: show_help_(false),
|
||||
is_list_(false) {}
|
||||
is_list_(false),
|
||||
show_version_(false) {}
|
||||
|
||||
void RdciDiscoverySubSystem::parse_cmd_opts(int argc, char** argv) {
|
||||
const int HOST_OPTIONS = 1000;
|
||||
@@ -41,12 +43,12 @@ void RdciDiscoverySubSystem::parse_cmd_opts(int argc, char** argv) {
|
||||
const struct option long_options[] = {
|
||||
{"host", required_argument, nullptr, HOST_OPTIONS}, {"help", optional_argument, nullptr, 'h'},
|
||||
{"unauth", optional_argument, nullptr, 'u'}, {"list", optional_argument, nullptr, 'l'},
|
||||
{"json", optional_argument, nullptr, JSON_OPTIONS}, {nullptr, 0, nullptr, 0}};
|
||||
{"json", optional_argument, nullptr, JSON_OPTIONS}, {"version", optional_argument, nullptr, 'v'}, {nullptr, 0, nullptr, 0}};
|
||||
|
||||
int option_index = 0;
|
||||
int opt = 0;
|
||||
|
||||
while ((opt = getopt_long(argc, argv, "hlu", long_options, &option_index)) != -1) {
|
||||
while ((opt = getopt_long(argc, argv, "hluv", long_options, &option_index)) != -1) {
|
||||
switch (opt) {
|
||||
case HOST_OPTIONS:
|
||||
ip_port_ = optarg;
|
||||
@@ -63,13 +65,16 @@ void RdciDiscoverySubSystem::parse_cmd_opts(int argc, char** argv) {
|
||||
case 'l':
|
||||
is_list_ = true;
|
||||
break;
|
||||
case 'v':
|
||||
show_version_ = true;
|
||||
break;
|
||||
default:
|
||||
show_help();
|
||||
throw RdcException(RDC_ST_BAD_PARAMETER, "Unknown command line options");
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_list_) {
|
||||
if ((!is_list_ && !show_version_) || (is_list_ && show_version_)) {
|
||||
show_help();
|
||||
throw RdcException(RDC_ST_BAD_PARAMETER, "Need to specify operations");
|
||||
}
|
||||
@@ -78,16 +83,18 @@ void RdciDiscoverySubSystem::parse_cmd_opts(int argc, char** argv) {
|
||||
void RdciDiscoverySubSystem::show_help() const {
|
||||
if (is_json_output()) return;
|
||||
std::cout << " discovery -- Used to discover and identify GPUs "
|
||||
<< "and their attributes.\n\n";
|
||||
<< "and their attributes, as well as server version information.\n\n";
|
||||
std::cout << "Usage\n";
|
||||
std::cout << " rdci discovery [--host <IP/FQDN>:port] [--json]"
|
||||
<< " [-u] -l\n";
|
||||
<< " [-u] -l -v\n";
|
||||
std::cout << "\nFlags:\n";
|
||||
show_common_usage();
|
||||
std::cout << " --json "
|
||||
<< "Output using json.\n";
|
||||
std::cout << " -l --list list GPU discovered"
|
||||
<< " on the system\n";
|
||||
std::cout << " -v --version Display version information of the"
|
||||
<< " the server and libraries used by the server\n";
|
||||
}
|
||||
|
||||
void RdciDiscoverySubSystem::show_attributes() {
|
||||
@@ -138,6 +145,33 @@ void RdciDiscoverySubSystem::show_attributes() {
|
||||
}
|
||||
}
|
||||
|
||||
void RdciDiscoverySubSystem::show_version() {
|
||||
rdc_component_version_t smiv;
|
||||
rdc_status_t result = rdc_device_get_component_version(rdc_handle_, RDC_AMDMSI_COMPONENT, &smiv);
|
||||
if (result != RDC_ST_OK) {
|
||||
return;
|
||||
}
|
||||
|
||||
mixed_component_version_t rdcdv;
|
||||
uint32_t ret = get_mixed_component_version(rdc_handle_, RDCD_COMPONENT, &rdcdv);
|
||||
if (ret) {
|
||||
std::cout << "get rdcd version fail"<< std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_json_output()) {
|
||||
std::cout << "\"version\" : ";
|
||||
std::cout << '{';
|
||||
std::cout << "\"rdcd\": " << "\"" << rdcdv.version << "\", ";
|
||||
std::cout << "\"amdsmi_lib\": " << "\"" << smiv.version << "\"";
|
||||
std::cout << '}';
|
||||
} else {
|
||||
std::cout << "RDCD : " << rdcdv.version << " | " << "AMDSMI Library : " << smiv.version << std::endl;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void RdciDiscoverySubSystem::process() {
|
||||
if (show_help_) {
|
||||
return show_help();
|
||||
@@ -146,6 +180,10 @@ void RdciDiscoverySubSystem::process() {
|
||||
if (is_list_) {
|
||||
return show_attributes();
|
||||
}
|
||||
|
||||
if (show_version_) {
|
||||
return show_version();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace rdc
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする