xref: /openbmc/estoraged/src/erase/verifyDriveGeometry.cpp (revision 043af59f7fadce9b7e3872d91b1a0e841fc24cea)
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 
12*043af59fSTom Tung void VerifyDriveGeometry::geometryOkay(uint64_t eraseMaxGeometry,
13*043af59fSTom Tung                                        uint64_t eraseMinGeometry,
14*043af59fSTom Tung                                        uint64_t bytes)
15e6ffe704SJohn Edward Broadbent {
16*043af59fSTom Tung     if (bytes > eraseMaxGeometry)
17e6ffe704SJohn Edward Broadbent     {
18e6ffe704SJohn Edward Broadbent         lg2::error("Erase verify Geometry too large", "REDFISH_MESSAGE_ID",
19e6ffe704SJohn Edward Broadbent                    std::string("OpenBMC.0.1.DriveEraseFailure"),
20e6ffe704SJohn Edward Broadbent                    "REDFISH_MESSAGE_ARGS",
21e6ffe704SJohn Edward Broadbent                    std::to_string(bytes) + ">" +
22*043af59fSTom Tung                        std::to_string(eraseMaxGeometry));
23972c3faaSJohn Wedig         throw InternalFailure();
24e6ffe704SJohn Edward Broadbent     }
25*043af59fSTom Tung     if (bytes < eraseMinGeometry)
26e6ffe704SJohn Edward Broadbent     {
27e6ffe704SJohn Edward Broadbent         lg2::error(
28e6ffe704SJohn Edward Broadbent             "eStorageD erase verify Geometry too small", "REDFISH_MESSAGE_ID",
29e6ffe704SJohn Edward Broadbent             std::string("OpenBMC.0.1.DriveEraseFailure"),
30e6ffe704SJohn Edward Broadbent             "REDFISH_MESSAGE_ARGS",
31*043af59fSTom Tung             std::to_string(bytes) + "<" + std::to_string(eraseMinGeometry));
32972c3faaSJohn Wedig         throw InternalFailure();
33e6ffe704SJohn Edward Broadbent     }
3482897c35SEd Tanous 
3582897c35SEd Tanous     lg2::info("eStorageD erase verify Geometry in range", "REDFISH_MESSAGE_ID",
36e6ffe704SJohn Edward Broadbent               std::string("OpenBMC.0.1.DriveEraseSuccess"));
37e6ffe704SJohn Edward Broadbent }
38d3bfa7bbSJohn Edward Broadbent 
39d3bfa7bbSJohn Edward Broadbent } // namespace estoraged
40