xref: /openbmc/estoraged/src/erase/verifyDriveGeometry.cpp (revision 15b63e12bdc3f3116fb841349dd4f1cd17a8398b)
1e6ffe704SJohn Edward Broadbent #include "verifyDriveGeometry.hpp"
2e6ffe704SJohn Edward Broadbent 
3e6ffe704SJohn Edward Broadbent #include <phosphor-logging/lg2.hpp>
4972c3faaSJohn Wedig #include <xyz/openbmc_project/Common/error.hpp>
5e6ffe704SJohn Edward Broadbent 
6e6ffe704SJohn Edward Broadbent #include <string>
7e6ffe704SJohn Edward Broadbent 
8d3bfa7bbSJohn Edward Broadbent namespace estoraged
9d3bfa7bbSJohn Edward Broadbent {
10972c3faaSJohn Wedig using sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
11e6ffe704SJohn Edward Broadbent 
geometryOkay(uint64_t eraseMaxGeometry,uint64_t eraseMinGeometry,uint64_t bytes)12*15b63e12SPatrick Williams void VerifyDriveGeometry::geometryOkay(
13*15b63e12SPatrick Williams     uint64_t eraseMaxGeometry, uint64_t eraseMinGeometry, uint64_t bytes)
14e6ffe704SJohn Edward Broadbent {
15043af59fSTom Tung     if (bytes > eraseMaxGeometry)
16e6ffe704SJohn Edward Broadbent     {
17e6ffe704SJohn Edward Broadbent         lg2::error("Erase verify Geometry too large", "REDFISH_MESSAGE_ID",
18e6ffe704SJohn Edward Broadbent                    std::string("OpenBMC.0.1.DriveEraseFailure"),
19e6ffe704SJohn Edward Broadbent                    "REDFISH_MESSAGE_ARGS",
20e6ffe704SJohn Edward Broadbent                    std::to_string(bytes) + ">" +
21043af59fSTom Tung                        std::to_string(eraseMaxGeometry));
22972c3faaSJohn Wedig         throw InternalFailure();
23e6ffe704SJohn Edward Broadbent     }
24043af59fSTom Tung     if (bytes < eraseMinGeometry)
25e6ffe704SJohn Edward Broadbent     {
26e6ffe704SJohn Edward Broadbent         lg2::error(
27e6ffe704SJohn Edward Broadbent             "eStorageD erase verify Geometry too small", "REDFISH_MESSAGE_ID",
28e6ffe704SJohn Edward Broadbent             std::string("OpenBMC.0.1.DriveEraseFailure"),
29e6ffe704SJohn Edward Broadbent             "REDFISH_MESSAGE_ARGS",
30043af59fSTom Tung             std::to_string(bytes) + "<" + std::to_string(eraseMinGeometry));
31972c3faaSJohn Wedig         throw InternalFailure();
32e6ffe704SJohn Edward Broadbent     }
3382897c35SEd Tanous 
3482897c35SEd Tanous     lg2::info("eStorageD erase verify Geometry in range", "REDFISH_MESSAGE_ID",
35e6ffe704SJohn Edward Broadbent               std::string("OpenBMC.0.1.DriveEraseSuccess"));
36e6ffe704SJohn Edward Broadbent }
37d3bfa7bbSJohn Edward Broadbent 
38d3bfa7bbSJohn Edward Broadbent } // namespace estoraged
39