From d19c6dfa36410a6312ef5a489be02ae47d7f645b Mon Sep 17 00:00:00 2001 From: Chen Gong Date: Sat, 17 Aug 2024 14:58:01 +0800 Subject: [PATCH] Reorganize the code path of the rdci Discovery Subsystem Prepare for adding 'detection version information' later Change-Id: Ib2b5e70b2360b1c5ff87a537f41f34f23c7ed61f Signed-off-by: Chen Gong [ROCm/rdc commit: 45c6d0b03b222e4762ff0df5019136ac8e4cc0c9] --- .../rdc/rdci/include/RdciDiscoverySubSystem.h | 2 ++ .../rdc/rdci/src/RdciDiscoverySubSystem.cc | 25 ++++++++++++------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/projects/rdc/rdci/include/RdciDiscoverySubSystem.h b/projects/rdc/rdci/include/RdciDiscoverySubSystem.h index b0851e7ac9..f0dd2be95b 100644 --- a/projects/rdc/rdci/include/RdciDiscoverySubSystem.h +++ b/projects/rdc/rdci/include/RdciDiscoverySubSystem.h @@ -36,6 +36,8 @@ class RdciDiscoverySubSystem : public RdciSubSystem { private: bool show_help_; void show_help() const; + bool is_list_; + void show_attributes(); }; } // namespace rdc diff --git a/projects/rdc/rdci/src/RdciDiscoverySubSystem.cc b/projects/rdc/rdci/src/RdciDiscoverySubSystem.cc index 0a50c78098..8d5233a759 100644 --- a/projects/rdc/rdci/src/RdciDiscoverySubSystem.cc +++ b/projects/rdc/rdci/src/RdciDiscoverySubSystem.cc @@ -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