blob: 359135e6d5f83ebb2d950b4ec23dafea777c1c1e [file] [log] [blame]
John Edward Broadbente6ffe702021-10-14 14:03:11 -07001#include "verifyDriveGeometry.hpp"
2
John Edward Broadbente6ffe702021-10-14 14:03:11 -07003#include <phosphor-logging/lg2.hpp>
John Wedig972c3fa2021-12-29 17:30:41 -08004#include <xyz/openbmc_project/Common/error.hpp>
John Edward Broadbente6ffe702021-10-14 14:03:11 -07005
6#include <string>
7
John Edward Broadbentd3bfa7b2022-01-13 17:41:32 -08008namespace estoraged
9{
John Wedig972c3fa2021-12-29 17:30:41 -080010using sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
John Edward Broadbente6ffe702021-10-14 14:03:11 -070011
Tom Tung043af592023-11-24 13:37:05 +080012void VerifyDriveGeometry::geometryOkay(uint64_t eraseMaxGeometry,
13 uint64_t eraseMinGeometry,
14 uint64_t bytes)
John Edward Broadbente6ffe702021-10-14 14:03:11 -070015{
Tom Tung043af592023-11-24 13:37:05 +080016 if (bytes > eraseMaxGeometry)
John Edward Broadbente6ffe702021-10-14 14:03:11 -070017 {
18 lg2::error("Erase verify Geometry too large", "REDFISH_MESSAGE_ID",
19 std::string("OpenBMC.0.1.DriveEraseFailure"),
20 "REDFISH_MESSAGE_ARGS",
21 std::to_string(bytes) + ">" +
Tom Tung043af592023-11-24 13:37:05 +080022 std::to_string(eraseMaxGeometry));
John Wedig972c3fa2021-12-29 17:30:41 -080023 throw InternalFailure();
John Edward Broadbente6ffe702021-10-14 14:03:11 -070024 }
Tom Tung043af592023-11-24 13:37:05 +080025 if (bytes < eraseMinGeometry)
John Edward Broadbente6ffe702021-10-14 14:03:11 -070026 {
27 lg2::error(
28 "eStorageD erase verify Geometry too small", "REDFISH_MESSAGE_ID",
29 std::string("OpenBMC.0.1.DriveEraseFailure"),
30 "REDFISH_MESSAGE_ARGS",
Tom Tung043af592023-11-24 13:37:05 +080031 std::to_string(bytes) + "<" + std::to_string(eraseMinGeometry));
John Wedig972c3fa2021-12-29 17:30:41 -080032 throw InternalFailure();
John Edward Broadbente6ffe702021-10-14 14:03:11 -070033 }
Ed Tanous82897c32022-02-21 14:11:59 -080034
35 lg2::info("eStorageD erase verify Geometry in range", "REDFISH_MESSAGE_ID",
36 std::string("OpenBMC.0.1.DriveEraseSuccess"));
John Edward Broadbente6ffe702021-10-14 14:03:11 -070037}
John Edward Broadbentd3bfa7b2022-01-13 17:41:32 -080038
39} // namespace estoraged