Skip to content
This repository has been archived by the owner on Aug 5, 2022. It is now read-only.

Commit

Permalink
Support dimm uid in show -topology command
Browse files Browse the repository at this point in the history
Signed-off-by: Swetha Venkatachari Sundarajan <[email protected]>
  • Loading branch information
swetha-intel authored and Juston Li committed Mar 5, 2018
1 parent 756d222 commit 38fd935
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/cli/features/core/ShowCommandUtilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,13 @@ class NVM_CLI_API ShowCommandUtilities
static void split(const std::string &s, char delim, Out result);
static std::string listToString(std::vector<std::string> list);
static const std::size_t min_hex_id_length = 6;
static bool isUid(std::string id);

protected:
static std::string getFirstBadDimmId(const core::StringList &dimmIds,
core::device::DeviceCollection &devices);
static std::string getFirstBadSocketId(const core::StringList &socketIds,
core::device::DeviceCollection &devices);
static bool isUid(std::string id);
};

}
Expand Down
16 changes: 12 additions & 4 deletions src/cli/features/core/ShowTopologyCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,19 @@ void ShowTopologyCommand::filterTopologiesOnDimmIds()
for (size_t i = m_topologies.size(); i > 0; i--)
{
core::device::Topology &topology = m_topologies[i - 1];
NVM_UINT32 handle = topology.getDeviceHandle();
NVM_UINT32 expected_handle = topology.getDeviceHandle();
std::string expected_uid = topology.getUid();

bool topology_found = false;

for (size_t j = 0; j < input_handles.size(); j++)
{
if (input_handles[j] == handle)
std::string dimmId = m_dimmIds[j];
NVM_UINT32 input_handle = (NVM_UINT32)stringToUInt64(dimmId);
bool isHandle = cli::nvmcli::isStringValidNumber(dimmId);
bool isValidUid = ShowCommandUtilities::isUid(dimmId);
if ((isHandle && (input_handle == expected_handle))
|| (isValidUid && (dimmId == expected_uid)))
{
topology_found = true;
break;
Expand Down Expand Up @@ -228,11 +235,12 @@ std::string ShowTopologyCommand::getFirstBadDimmId(core::device::TopologyCollect
{
bool dimmIdFound = false;
std::string dimmId = m_dimmIds[i];
NVM_UINT32 input_handle = (NVM_UINT32)stringToUInt64(dimmId);
bool isValidUid = ShowCommandUtilities::isUid(dimmId);
bool isHandle = cli::nvmcli::isStringValidNumber(dimmId);
for (size_t j = 0; j < topologies.size() && !dimmIdFound; j++)
{
if (isHandle && (input_handle == topologies[j].getDeviceHandle()))
if ((isHandle && (NVM_UINT32)stringToUInt64(dimmId) == topologies[j].getDeviceHandle())
|| (isValidUid && framework::stringsIEqual(dimmId, topologies[j].getUid())))
{
dimmIdFound = true;
break;
Expand Down

0 comments on commit 38fd935

Please sign in to comment.