blob: 6706a368f53a237f8671dcd43d8e89be02f6a57e [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
Patrick Williams15b63e12024-08-16 15:22:01 -040012void VerifyDriveGeometry::geometryOkay(
13 uint64_t eraseMaxGeometry, uint64_t eraseMinGeometry, uint64_t bytes)
John Edward Broadbente6ffe702021-10-14 14:03:11 -070014{
Tom Tung043af592023-11-24 13:37:05 +080015 if (bytes > eraseMaxGeometry)
John Edward Broadbente6ffe702021-10-14 14:03:11 -070016 {
17 lg2::error("Erase verify Geometry too large", "REDFISH_MESSAGE_ID",
18 std::string("OpenBMC.0.1.DriveEraseFailure"),
19 "REDFISH_MESSAGE_ARGS",
20 std::to_string(bytes) + ">" +
Tom Tung043af592023-11-24 13:37:05 +080021 std::to_string(eraseMaxGeometry));
John Wedig972c3fa2021-12-29 17:30:41 -080022 throw InternalFailure();
John Edward Broadbente6ffe702021-10-14 14:03:11 -070023 }
Tom Tung043af592023-11-24 13:37:05 +080024 if (bytes < eraseMinGeometry)
John Edward Broadbente6ffe702021-10-14 14:03:11 -070025 {
26 lg2::error(
27 "eStorageD erase verify Geometry too small", "REDFISH_MESSAGE_ID",
28 std::string("OpenBMC.0.1.DriveEraseFailure"),
29 "REDFISH_MESSAGE_ARGS",
Tom Tung043af592023-11-24 13:37:05 +080030 std::to_string(bytes) + "<" + std::to_string(eraseMinGeometry));
John Wedig972c3fa2021-12-29 17:30:41 -080031 throw InternalFailure();
John Edward Broadbente6ffe702021-10-14 14:03:11 -070032 }
Ed Tanous82897c32022-02-21 14:11:59 -080033
34 lg2::info("eStorageD erase verify Geometry in range", "REDFISH_MESSAGE_ID",
35 std::string("OpenBMC.0.1.DriveEraseSuccess"));
John Edward Broadbente6ffe702021-10-14 14:03:11 -070036}
John Edward Broadbentd3bfa7b2022-01-13 17:41:32 -080037
38} // namespace estoraged