bridgingcommands:Move ClearMessageFlags to new API
Rewrite ipmiAppClearMessageFlags command to use the newly
introduced IPMI provider API.
Tested:
Verified using ipmitool ClearMessageFlags behavior is same
before and after the changes.
Command : ipmitool raw 0x06 0x31 //Get Message Flags
Response: 02
Command : ipmitool raw 0x06 0x30 0x00 //Clear Message Flags
Response:
Signed-off-by: jayaprakash Mutyala <mutyalax.jayaprakash@intel.com>
Change-Id: I8c03050332408e909ab61994f337cfa2c1c036a4
diff --git a/include/bridgingcommands.hpp b/include/bridgingcommands.hpp
index db3e99d..fe92f6c 100644
--- a/include/bridgingcommands.hpp
+++ b/include/bridgingcommands.hpp
@@ -287,6 +287,9 @@
Bridging() = default;
std::size_t getResponseQueueSize();
+ std::vector<IpmbResponse> getResponseQueue();
+ void clearResponseQueue();
+
ipmi_return_codes sendMessageHandler(ipmi_request_t request,
ipmi_response_t response,
ipmi_data_len_t dataLen);
@@ -294,14 +297,8 @@
ipmi_return_codes getMessageHandler(ipmi_request_t request,
ipmi_response_t response,
ipmi_data_len_t dataLen);
-
- ipmi_return_codes clearMessageFlagsHandler(ipmi_request_t request,
- ipmi_response_t response,
- ipmi_data_len_t dataLen);
-
enum IpmiAppBridgingCmds
{
- ipmiCmdClearMessageFlags = 0x30,
ipmiCmdGetMessage = 0x33,
ipmiCmdSendMessage = 0x34,
};
diff --git a/src/bridgingcommands.cpp b/src/bridgingcommands.cpp
index b4f0264..ac074e3 100644
--- a/src/bridgingcommands.cpp
+++ b/src/bridgingcommands.cpp
@@ -38,6 +38,11 @@
static Bridging bridging;
+void Bridging::clearResponseQueue()
+{
+ responseQueue.clear();
+}
+
/**
* @brief utils for checksum
*/
@@ -448,25 +453,6 @@
return IPMI_CC_OK;
}
-ipmi_return_codes Bridging::clearMessageFlagsHandler(ipmi_request_t request,
- ipmi_response_t response,
- ipmi_data_len_t dataLen)
-{
- if (*dataLen != sizeof(sClearMessageFlagsReq))
- {
- return IPMI_CC_REQ_DATA_LEN_INVALID;
- }
-
- auto clearMsgFlagsReq = reinterpret_cast<sClearMessageFlagsReq *>(request);
-
- if (clearMsgFlagsReq->receiveMessageBitGet() == 1)
- {
- responseQueue.clear();
- }
-
- return IPMI_CC_OK;
-}
-
ipmi_ret_t ipmiAppSendMessage(ipmi_netfn_t netFn, ipmi_cmd_t cmd,
ipmi_request_t request, ipmi_response_t response,
ipmi_data_len_t dataLen, ipmi_context_t context)
@@ -533,26 +519,42 @@
return ipmi::responseSuccess(getMsgFlagsRes);
}
-ipmi_ret_t ipmiAppClearMessageFlags(ipmi_netfn_t netFn, ipmi_cmd_t cmd,
- ipmi_request_t request,
- ipmi_response_t response,
- ipmi_data_len_t dataLen,
- ipmi_context_t context)
+/** @brief This command is used to flush unread data from the receive
+ * message queue
+ * @param receiveMessage - clear receive message queue
+ * @param eventMsgBufFull - clear event message buffer full
+ * @param reserved2 - reserved bit
+ * @param watchdogTimeout - clear watchdog pre-timeout interrupt flag
+ * @param reserved1 - reserved bit
+ * @param oem0 - clear OEM 0 data
+ * @param oem1 - clear OEM 1 data
+ * @param oem2 - clear OEM 2 data
+
+ * @return IPMI completion code on success
+ */
+ipmi::RspType<> ipmiAppClearMessageFlags(bool receiveMessage,
+ bool eventMsgBufFull, bool reserved2,
+ bool watchdogTimeout, bool reserved1,
+ bool oem0, bool oem1, bool oem2)
{
- ipmi_ret_t retCode = IPMI_CC_OK;
- retCode = bridging.clearMessageFlagsHandler(request, response, dataLen);
+ if (reserved1 || reserved2)
+ {
+ return ipmi::responseInvalidFieldRequest();
+ }
- *dataLen = 0;
-
- return retCode;
+ if (receiveMessage)
+ {
+ bridging.clearResponseQueue();
+ }
+ return ipmi::responseSuccess();
}
static void register_bridging_functions() __attribute__((constructor));
static void register_bridging_functions()
{
- ipmi_register_callback(
- NETFUN_APP, Bridging::IpmiAppBridgingCmds::ipmiCmdClearMessageFlags,
- NULL, ipmiAppClearMessageFlags, PRIVILEGE_USER);
+ ipmi::registerHandler(ipmi::prioOemBase, ipmi::netFnApp,
+ ipmi::app::cmdClearMessageFlags,
+ ipmi::Privilege::User, ipmiAppClearMessageFlags);
ipmi::registerHandler(ipmi::prioOemBase, ipmi::netFnApp,
ipmi::app::cmdGetMessageFlags, ipmi::Privilege::User,