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

Commit 5e2b705

Browse files
Arun Thomas KaringadaJuston Li
Arun Thomas Karingada
authored and
Juston Li
committed
Added wait (-w) option to the Fw update command
Fw update command waits until ARS is complete and then proceeds with the staging of FW. Signed-off-by: Arun Thomas Karingada <[email protected]>
1 parent c6cf3ab commit 5e2b705

7 files changed

+115
-4
lines changed

src/cli/features/core/FieldSupportFeature.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ void cli::nvmcli::FieldSupportFeature::getPaths(cli::framework::CommandSpecList
128128
updateFirmware.addOption(framework::OPTION_EXAMINE)
129129
.helpText(TR("Verify the firmware image specified in the source option and return its version "
130130
"without actually downloading the image to the specified " NVM_DIMM_NAME "(s)."));
131+
updateFirmware.addOption(framework::OPTION_WAIT)
132+
.helpText(TR("If any long-operations are pending, wait for them to complete and then continue the firmware update."));
131133
updateFirmware.addTarget(TARGET_DIMM_R)
132134
.valueText(DIMMIDS_STR)
133135
.helpText(TR("Update the firmware on specific " NVM_DIMM_NAME "s by supplying one or more comma-separated "
@@ -340,7 +342,8 @@ cli::nvmcli::FieldSupportFeature::FieldSupportFeature() :
340342
m_DumpSupport(wbemDumpSupport),
341343
m_ClearSupport(wbemClearSupport),
342344
m_getEvents(wbemGetEvents),
343-
m_uidToDimmIdStr(wbem::physical_asset::NVDIMMFactory::uidToDimmIdStr)
345+
m_uidToDimmIdStr(wbem::physical_asset::NVDIMMFactory::uidToDimmIdStr),
346+
m_WaitForARSToComplete(wbemWaitForARSToComplete)
344347
{
345348
}
346349

@@ -543,6 +546,8 @@ cli::framework::ResultBase *cli::nvmcli::FieldSupportFeature::updateFirmware(
543546
!= parsedCommand.options.end();
544547
bool examineOption = parsedCommand.options.find(framework::OPTION_EXAMINE.name)
545548
!= parsedCommand.options.end();
549+
bool waitOption = parsedCommand.options.find(framework::OPTION_WAIT.name)
550+
!= parsedCommand.options.end();
546551

547552
std::vector<std::string> uids;
548553
pResult = m_getDimms(parsedCommand, uids);
@@ -627,6 +632,10 @@ cli::framework::ResultBase *cli::nvmcli::FieldSupportFeature::updateFirmware(
627632
}
628633
else
629634
{
635+
if (waitOption)
636+
{
637+
m_WaitForARSToComplete(uids[i]);
638+
}
630639
m_InstallFromPath(uids[i], path, true);
631640
pSimpleList->insert(prefix +
632641
std::string(TRS(cli::framework::SUCCESS_MSG)) + TRS(UPDATEFIRMWARE_RESET_MSG));
@@ -682,6 +691,13 @@ int cli::nvmcli::FieldSupportFeature::wbemExamineFwImage(const std::string &devi
682691
return provider.examineFwImage(deviceUid, path, fwVersion);
683692
}
684693

694+
void cli::nvmcli::FieldSupportFeature::wbemWaitForARSToComplete(const std::string &deviceUid)
695+
{
696+
LogEnterExit logging(__FUNCTION__, __FILE__, __LINE__);
697+
wbem::software::NVDIMMSoftwareInstallationServiceFactory provider;
698+
provider.waitForARSToComplete(deviceUid);
699+
}
700+
685701
/*
686702
* cli command to dump the support data to a file
687703
*/

src/cli/features/core/FieldSupportFeature.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ namespace cli
4848
namespace nvmcli
4949
{
5050

51-
static const std::string UPDATEFIRMWARE_MSG = N_TR("Load FW on " NVM_DIMM_NAME " %s"); //!< update firmware success message
51+
static const std::string UPDATEFIRMWARE_MSG = N_TR("Load FW on " NVM_DIMM_NAME " %s"); //!< update firmware message
5252
static const std::string UPDATEFIRMWARE_RESET_MSG = N_TR(", a power cycle is required to activate the FW.");
5353
static const std::string UPDATEFIRMWARE_EXAMINE_VALID_MSG = N_TR(
5454
"Valid"); //!< examine FW valid message
@@ -62,6 +62,7 @@ static const std::string UPDATEFIRMWARE_ERROR_MSG = N_TR(
6262
"Load FW on " NVM_DIMM_NAME " (%s): Error - %s"); //!< update firmware error message
6363
static const std::string DOWNGRADE_FW_PROMPT = TR(
6464
"Downgrade firmware on " NVM_DIMM_NAME " %s?"); //!< prompt for user if not forced
65+
6566
static const std::string CREATESNAPSHOT_MSG = N_TR(
6667
"Create support snapshot"); //!< create support snapshot success message
6768
static const std::string DUMPSUPPORT_MSG = N_TR(
@@ -219,6 +220,12 @@ class NVM_CLI_API FieldSupportFeature : public cli::nvmcli::VerboseFeatureBase
219220
std::string (*m_uidToDimmIdStr)(const std::string &dimmUid)
220221
throw (wbem::framework::Exception);
221222

223+
/*!
224+
* API for allowing ARS to complete
225+
* @param deviceUid
226+
*/
227+
void (*m_WaitForARSToComplete)(const std::string &deviceUid);
228+
222229
/*
223230
* Retrieve a list of supported preferences
224231
*/
@@ -291,6 +298,13 @@ class NVM_CLI_API FieldSupportFeature : public cli::nvmcli::VerboseFeatureBase
291298
static int wbemExamineFwImage(const std::string &deviceUid, const std::string &path,
292299
std::string &fwVersion);
293300

301+
/*!
302+
* Wrapper around wbem waitForARSToComplete
303+
* @param deviceUid
304+
* @return
305+
*/
306+
static void wbemWaitForARSToComplete(const std::string &deviceUid);
307+
294308
/*!
295309
* Wrapper around wbem
296310
* @param path

src/core/device/DeviceService.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,13 @@ std::string core::device::DeviceService::getFirmwareApiVersionByUid(const std::s
155155
return m_lib.getDeviceDiscovery(deviceUid).fw_api_version;
156156
}
157157

158+
NVM_UINT32 core::device::DeviceService::getHandleByUid(const std::string &deviceUid)
159+
{
160+
LogEnterExit logging(__FUNCTION__, __FILE__, __LINE__);
161+
return m_lib.getDeviceDiscovery(deviceUid).device_handle.handle;
162+
}
163+
164+
158165
void core::device::DeviceService::modifyDeviceSettings(const std::string& deviceUid,
159166
const bool enableFirstFastRefresh, const bool enableViralPolicy)
160167
{

src/core/device/DeviceService.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class NVM_CORE_API DeviceService
5252
virtual DeviceCollection getAllDevices();
5353
virtual Result<Device> getDevice(std::string uid);
5454
virtual std::string getFirmwareApiVersionByUid(const std::string &deviceUid);
55+
virtual NVM_UINT32 getHandleByUid(const std::string &deviceUid);
5556

5657
virtual void modifyDeviceSettings(const std::string &deviceUid,
5758
const bool enableFirstFastRefresh, const bool enableViralPolicy);

src/lib/update_firmware.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,6 @@ int update_firmware(const NVM_NFIT_DEVICE_HANDLE device_handle, const NVM_PATH p
282282
{
283283
nvm_sleep(1000); // 1 second
284284
}
285-
286285
// Changing the state invalidates the device cache
287286
invalidate_devices();
288287
}

src/wbem/software/NVDIMMSoftwareInstallationServiceFactory.cpp

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,11 @@
4444
#include "NVDIMMSoftwareInstallationServiceFactory.h"
4545
#include "NVDIMMCollectionFactory.h"
4646

47+
4748
#include <algorithm>
4849
#include <string.h>
50+
#include <string/s_str.h>
51+
4952

5053
#include <exception/NvmExceptionLibError.h>
5154
#include <NvmStrings.h>
@@ -54,7 +57,8 @@
5457
wbem::software::NVDIMMSoftwareInstallationServiceFactory::NVDIMMSoftwareInstallationServiceFactory()
5558
throw (wbem::framework::Exception) : m_UpdateDeviceFw(nvm_update_device_fw),
5659
m_ExamineFwImage(nvm_examine_device_fw),
57-
m_GetManageableDeviceUids(physical_asset::NVDIMMFactory::getManageableDeviceUids)
60+
m_GetManageableDeviceUids(physical_asset::NVDIMMFactory::getManageableDeviceUids),
61+
m_GetDeviceDetails(nvm_get_device_details)
5862
{ }
5963

6064
wbem::software::NVDIMMSoftwareInstallationServiceFactory::~NVDIMMSoftwareInstallationServiceFactory()
@@ -458,3 +462,49 @@ throw (framework::Exception)
458462
version = fw_version;
459463
return rc;
460464
}
465+
466+
void wbem::software::NVDIMMSoftwareInstallationServiceFactory::waitForARSToComplete( ) const
467+
throw (framework::Exception)
468+
{
469+
LogEnterExit logging(__FUNCTION__, __FILE__, __LINE__);
470+
471+
std::vector<std::string> devices = m_GetManageableDeviceUids();
472+
for (size_t i = 0; i < devices.size(); i++)
473+
{
474+
waitForARSToComplete(devices[i]);
475+
}
476+
}
477+
478+
int wbem::software::NVDIMMSoftwareInstallationServiceFactory::waitForARSToComplete(
479+
const std::string& deviceUid) const
480+
throw (framework::Exception)
481+
{
482+
LogEnterExit logging(__FUNCTION__, __FILE__, __LINE__);
483+
484+
if (!core::device::isUidValid(deviceUid))
485+
{
486+
throw framework::ExceptionBadParameter("deviceUid");
487+
}
488+
struct device_status status;
489+
NVM_UID lib_deviceUid;
490+
int rc = NVM_SUCCESS;
491+
492+
core::Helper::stringToUid(deviceUid, lib_deviceUid);
493+
494+
rc = nvm_get_device_status(lib_deviceUid, &status);
495+
if(status.ars_status == DEVICE_ARS_STATUS_INPROGRESS)
496+
{
497+
printf("Cannot stage FW while ARS is in Progress. Waiting for ARS Completion\n");
498+
499+
}
500+
501+
while (status.ars_status == DEVICE_ARS_STATUS_INPROGRESS)
502+
{
503+
nvm_sleep(1000); // 1 second
504+
printf(".");
505+
fflush(stdout);
506+
rc = nvm_get_device_status(lib_deviceUid, &status);
507+
}
508+
printf("\n");
509+
return rc;
510+
}

src/wbem/software/NVDIMMSoftwareInstallationServiceFactory.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,22 @@ class NVM_CIM_API NVDIMMSoftwareInstallationServiceFactory : public framework_in
158158
std::string &version) const
159159
throw (framework::Exception);
160160

161+
/*!
162+
* Wait for ARS to complete
163+
* @param deviceUid
164+
* Device to allow ARS for completion
165+
* @return
166+
*/
167+
int waitForARSToComplete(const std::string &deviceUid) const
168+
throw (framework::Exception);
169+
170+
/*!
171+
* Wait for ARS to complete for all devices.
172+
* @return
173+
*/
174+
void waitForARSToComplete( ) const
175+
throw (framework::Exception);
176+
161177
/*!
162178
* API indirection
163179
* @param device_uid
@@ -188,6 +204,14 @@ class NVM_CIM_API NVDIMMSoftwareInstallationServiceFactory : public framework_in
188204
*/
189205
std::vector<std::string> (*m_GetManageableDeviceUids)();
190206

207+
/*!
208+
* API for getting device details
209+
* @param device_uid
210+
* @return status of operation
211+
*/
212+
int (*m_GetDeviceDetails)(const NVM_UID device_uid,
213+
struct device_details *p_details);
214+
191215
private:
192216
void populateAttributeList(framework::attribute_names_t &attributes)
193217
throw (framework::Exception);

0 commit comments

Comments
 (0)