Add BIC to handle the DCMI commands

Added a BIC enable check to parshes the DCMI commands in
IPMI OEM.

Signed-off-by: Logananth Sundararaj <logananth_s@hcl.com>
Change-Id: I8c02926168e74a613762e6ffa18bf759fcc0d4ab
diff --git a/src/oemcommands.cpp b/src/oemcommands.cpp
index 3b67520..c735b95 100644
--- a/src/oemcommands.cpp
+++ b/src/oemcommands.cpp
@@ -1937,48 +1937,70 @@
     return IPMI_CC_OK;
 }
 
-/* Helper function for sending DCMI commands to ME and getting response back */
-ipmi::RspType<std::vector<uint8_t>> sendDCMICmd(uint8_t cmd,
-                                                std::vector<uint8_t>& cmdData)
+/* Helper function for sending DCMI commands to ME/BIC and
+ * getting response back
+ */
+ipmi::RspType<std::vector<uint8_t>>
+    sendDCMICmd([[maybe_unused]] ipmi::Context::ptr ctx,
+                [[maybe_unused]] uint8_t cmd, std::vector<uint8_t>& cmdData)
 {
     std::vector<uint8_t> respData;
 
+#if BIC_ENABLED
+
+    uint8_t bicAddr = (uint8_t)ctx->hostIdx << 2;
+
+    if (sendBicCmd(ctx->netFn, ctx->cmd, bicAddr, cmdData, respData))
+    {
+        return ipmi::responseUnspecifiedError();
+    }
+
+#else
+
     /* Add group id as first byte to request for ME command */
     cmdData.insert(cmdData.begin(), groupDCMI);
 
     if (sendMeCmd(ipmi::netFnGroup, cmd, cmdData, respData))
+    {
         return ipmi::responseUnspecifiedError();
+    }
 
     /* Remove group id as first byte as it will be added by IPMID */
     respData.erase(respData.begin());
 
+#endif
+
     return ipmi::responseSuccess(std::move(respData));
 }
 
 /* DCMI Command handellers. */
 
 ipmi::RspType<std::vector<uint8_t>>
-    ipmiOemDCMIGetPowerReading(std::vector<uint8_t> reqData)
+    ipmiOemDCMIGetPowerReading(ipmi::Context::ptr ctx,
+                               std::vector<uint8_t> reqData)
 {
-    return sendDCMICmd(ipmi::dcmi::cmdGetPowerReading, reqData);
+    return sendDCMICmd(ctx, ipmi::dcmi::cmdGetPowerReading, reqData);
 }
 
 ipmi::RspType<std::vector<uint8_t>>
-    ipmiOemDCMIGetPowerLimit(std::vector<uint8_t> reqData)
+    ipmiOemDCMIGetPowerLimit(ipmi::Context::ptr ctx,
+                             std::vector<uint8_t> reqData)
 {
-    return sendDCMICmd(ipmi::dcmi::cmdGetPowerLimit, reqData);
+    return sendDCMICmd(ctx, ipmi::dcmi::cmdGetPowerLimit, reqData);
 }
 
 ipmi::RspType<std::vector<uint8_t>>
-    ipmiOemDCMISetPowerLimit(std::vector<uint8_t> reqData)
+    ipmiOemDCMISetPowerLimit(ipmi::Context::ptr ctx,
+                             std::vector<uint8_t> reqData)
 {
-    return sendDCMICmd(ipmi::dcmi::cmdSetPowerLimit, reqData);
+    return sendDCMICmd(ctx, ipmi::dcmi::cmdSetPowerLimit, reqData);
 }
 
 ipmi::RspType<std::vector<uint8_t>>
-    ipmiOemDCMIApplyPowerLimit(std::vector<uint8_t> reqData)
+    ipmiOemDCMIApplyPowerLimit(ipmi::Context::ptr ctx,
+                               std::vector<uint8_t> reqData)
 {
-    return sendDCMICmd(ipmi::dcmi::cmdActDeactivatePwrLimit, reqData);
+    return sendDCMICmd(ctx, ipmi::dcmi::cmdActDeactivatePwrLimit, reqData);
 }
 
 static void registerOEMFunctions(void)