John Edward Broadbent | e6ffe70 | 2021-10-14 14:03:11 -0700 | [diff] [blame] | 1 | #include "verifyDriveGeometry.hpp" |
| 2 | |
John Edward Broadbent | e6ffe70 | 2021-10-14 14:03:11 -0700 | [diff] [blame] | 3 | #include <phosphor-logging/lg2.hpp> |
John Wedig | 972c3fa | 2021-12-29 17:30:41 -0800 | [diff] [blame] | 4 | #include <xyz/openbmc_project/Common/error.hpp> |
John Edward Broadbent | e6ffe70 | 2021-10-14 14:03:11 -0700 | [diff] [blame] | 5 | |
| 6 | #include <string> |
| 7 | |
John Edward Broadbent | d3bfa7b | 2022-01-13 17:41:32 -0800 | [diff] [blame] | 8 | namespace estoraged |
| 9 | { |
John Wedig | 972c3fa | 2021-12-29 17:30:41 -0800 | [diff] [blame] | 10 | using sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure; |
John Edward Broadbent | e6ffe70 | 2021-10-14 14:03:11 -0700 | [diff] [blame] | 11 | |
Tom Tung | 043af59 | 2023-11-24 13:37:05 +0800 | [diff] [blame] | 12 | void VerifyDriveGeometry::geometryOkay(uint64_t eraseMaxGeometry, |
| 13 | uint64_t eraseMinGeometry, |
| 14 | uint64_t bytes) |
John Edward Broadbent | e6ffe70 | 2021-10-14 14:03:11 -0700 | [diff] [blame] | 15 | { |
Tom Tung | 043af59 | 2023-11-24 13:37:05 +0800 | [diff] [blame] | 16 | if (bytes > eraseMaxGeometry) |
John Edward Broadbent | e6ffe70 | 2021-10-14 14:03:11 -0700 | [diff] [blame] | 17 | { |
| 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 Tung | 043af59 | 2023-11-24 13:37:05 +0800 | [diff] [blame] | 22 | std::to_string(eraseMaxGeometry)); |
John Wedig | 972c3fa | 2021-12-29 17:30:41 -0800 | [diff] [blame] | 23 | throw InternalFailure(); |
John Edward Broadbent | e6ffe70 | 2021-10-14 14:03:11 -0700 | [diff] [blame] | 24 | } |
Tom Tung | 043af59 | 2023-11-24 13:37:05 +0800 | [diff] [blame] | 25 | if (bytes < eraseMinGeometry) |
John Edward Broadbent | e6ffe70 | 2021-10-14 14:03:11 -0700 | [diff] [blame] | 26 | { |
| 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 Tung | 043af59 | 2023-11-24 13:37:05 +0800 | [diff] [blame] | 31 | std::to_string(bytes) + "<" + std::to_string(eraseMinGeometry)); |
John Wedig | 972c3fa | 2021-12-29 17:30:41 -0800 | [diff] [blame] | 32 | throw InternalFailure(); |
John Edward Broadbent | e6ffe70 | 2021-10-14 14:03:11 -0700 | [diff] [blame] | 33 | } |
Ed Tanous | 82897c3 | 2022-02-21 14:11:59 -0800 | [diff] [blame] | 34 | |
| 35 | lg2::info("eStorageD erase verify Geometry in range", "REDFISH_MESSAGE_ID", |
| 36 | std::string("OpenBMC.0.1.DriveEraseSuccess")); |
John Edward Broadbent | e6ffe70 | 2021-10-14 14:03:11 -0700 | [diff] [blame] | 37 | } |
John Edward Broadbent | d3bfa7b | 2022-01-13 17:41:32 -0800 | [diff] [blame] | 38 | |
| 39 | } // namespace estoraged |