Add ipmi OEM handler to get the BMC mode
The response can indicate one of the BMC mode
below
0 -> Non Bare Metal Mode
1 -> Bare Metal Mode
2 -> Bare Metal Cleaning Mode
The Bare Metal Cleaning Mode is not
yet supported
Tested:
Response in BM Mode
ipmitool raw 0x2e 0x32 0x79 0x2b 0x00 0x10
79 2b 00 14 01
Response in Non-BM Mode
ipmitool raw 0x2e 0x32 0x79 0x2b 0x00 0x10
79 2b 00 14 00
Signed-off-by: Nikhil Namjoshi <nikhilnamjoshi@google.com>
Change-Id: I34474fd04f9aed35bd71725805ed52a5df8ab8c9
diff --git a/handler.cpp b/handler.cpp
index 6113f5d..161f10d 100644
--- a/handler.cpp
+++ b/handler.cpp
@@ -11,7 +11,6 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
-
#include "handler.hpp"
#include "errors.hpp"
@@ -41,6 +40,8 @@
#include <variant>
#include <xyz/openbmc_project/Common/error.hpp>
+#include "bm_config.h"
+
#ifndef NCSI_IF_NAME
#define NCSI_IF_NAME eth0
#endif
@@ -65,6 +66,28 @@
using InternalFailure =
sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
+enum class BmcMode : uint8_t
+{
+ NON_BM_MODE = 0,
+ BM_MODE,
+ BM_CLEANING_MODE
+};
+
+uint8_t isBmcInBareMetalMode()
+{
+#if BARE_METAL
+ return static_cast<uint8_t>(BmcMode::BM_MODE);
+#else
+ return static_cast<uint8_t>(BmcMode::NON_BM_MODE);
+#endif
+}
+
+uint8_t Handler::getBmcMode()
+{
+ // BM_CLEANING_MODE is not implemented yet
+ return isBmcInBareMetalMode();
+}
+
std::tuple<std::uint8_t, std::string>
Handler::getEthDetails(std::string intf) const
{