Reorganize the code path of the rdci Discovery Subsystem

Prepare for adding 'detection version information' later

Change-Id: Ib2b5e70b2360b1c5ff87a537f41f34f23c7ed61f
Signed-off-by: Chen Gong <curry.gong@amd.com>


[ROCm/rdc commit: 45c6d0b03b]
This commit is contained in:
Chen Gong
2024-08-17 14:58:01 +08:00
zatwierdzone przez Galantsev, Dmitrii
rodzic 2aba92bdce
commit d19c6dfa36
2 zmienionych plików z 18 dodań i 9 usunięć
@@ -36,6 +36,8 @@ class RdciDiscoverySubSystem : public RdciSubSystem {
private:
bool show_help_;
void show_help() const;
bool is_list_;
void show_attributes();
};
} // namespace rdc
@@ -31,7 +31,9 @@ THE SOFTWARE.
namespace amd {
namespace rdc {
RdciDiscoverySubSystem::RdciDiscoverySubSystem() : show_help_(false) {}
RdciDiscoverySubSystem::RdciDiscoverySubSystem()
: show_help_(false),
is_list_(false) {}
void RdciDiscoverySubSystem::parse_cmd_opts(int argc, char** argv) {
const int HOST_OPTIONS = 1000;
@@ -43,7 +45,6 @@ void RdciDiscoverySubSystem::parse_cmd_opts(int argc, char** argv) {
int option_index = 0;
int opt = 0;
bool is_list = false;
while ((opt = getopt_long(argc, argv, "hlu", long_options, &option_index)) != -1) {
switch (opt) {
@@ -60,7 +61,7 @@ void RdciDiscoverySubSystem::parse_cmd_opts(int argc, char** argv) {
use_auth_ = false;
break;
case 'l':
is_list = true;
is_list_ = true;
break;
default:
show_help();
@@ -68,7 +69,7 @@ void RdciDiscoverySubSystem::parse_cmd_opts(int argc, char** argv) {
}
}
if (!is_list) {
if (!is_list_) {
show_help();
throw RdcException(RDC_ST_BAD_PARAMETER, "Need to specify operations");
}
@@ -89,11 +90,7 @@ void RdciDiscoverySubSystem::show_help() const {
<< " on the system\n";
}
void RdciDiscoverySubSystem::process() {
if (show_help_) {
return show_help();
}
void RdciDiscoverySubSystem::show_attributes() {
uint32_t gpu_index_list[RDC_MAX_NUM_DEVICES];
uint32_t count = 0;
rdc_status_t result = rdc_device_get_all(rdc_handle_, gpu_index_list, &count);
@@ -141,5 +138,15 @@ void RdciDiscoverySubSystem::process() {
}
}
void RdciDiscoverySubSystem::process() {
if (show_help_) {
return show_help();
}
if (is_list_) {
return show_attributes();
}
}
} // namespace rdc
} // namespace amd