protocol: Add ack

Change-Id: I3ebad03d7f79381c683a121c181db9f30a13a3c4
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
diff --git a/protocol.c b/protocol.c
index b112231..293934f 100644
--- a/protocol.c
+++ b/protocol.c
@@ -283,6 +283,12 @@
 	return 0;
 }
 
+int protocol_v1_ack(struct mbox_context *context, struct protocol_ack *io)
+{
+	return clr_bmc_events(context, (io->req.flags & BMC_EVENT_ACK_MASK),
+			      SET_BMC_EVENT);
+}
+
 /*
  * get_suggested_timeout() - get the suggested timeout value in seconds
  * @context:	The mbox context pointer
@@ -451,6 +457,7 @@
 	.erase = NULL,
 	.flush = protocol_v1_flush,
 	.close = protocol_v1_close,
+	.ack = protocol_v1_ack,
 };
 
 static const struct protocol_ops protocol_ops_v2 = {
@@ -462,6 +469,7 @@
 	.erase = protocol_v2_erase,
 	.flush = protocol_v2_flush,
 	.close = protocol_v2_close,
+	.ack = protocol_v1_ack,
 };
 
 static const struct protocol_ops *protocol_ops_map[] = {
diff --git a/protocol.h b/protocol.h
index c948e80..5cdc2eb 100644
--- a/protocol.h
+++ b/protocol.h
@@ -93,6 +93,12 @@
 	} req;
 };
 
+struct protocol_ack {
+	struct {
+		uint8_t flags;
+	} req;
+};
+
 struct protocol_ops {
 	int (*reset)(struct mbox_context *context);
 	int (*get_info)(struct mbox_context *context,
@@ -106,6 +112,7 @@
 	int (*erase)(struct mbox_context *context, struct protocol_erase *io);
 	int (*flush)(struct mbox_context *context, struct protocol_flush *io);
 	int (*close)(struct mbox_context *context, struct protocol_close *io);
+	int (*ack)(struct mbox_context *context, struct protocol_ack *io);
 };
 
 int protocol_init(struct mbox_context *context);
@@ -125,6 +132,7 @@
 			   struct protocol_mark_dirty *io);
 int protocol_v1_flush(struct mbox_context *context, struct protocol_flush *io);
 int protocol_v1_close(struct mbox_context *context, struct protocol_close *io);
+int protocol_v1_ack(struct mbox_context *context, struct protocol_ack *io);
 
 /* Protocol v2 */
 int protocol_v2_get_info(struct mbox_context *context,
diff --git a/transport_mbox.c b/transport_mbox.c
index 89562e8..bc5e1e2 100644
--- a/transport_mbox.c
+++ b/transport_mbox.c
@@ -515,10 +515,17 @@
 int mbox_handle_ack(struct mbox_context *context, union mbox_regs *req,
 			   struct mbox_msg *resp)
 {
-	uint8_t bmc_events = req->msg.args[0];
+	struct protocol_ack io;
+	int rc;
 
-	return clr_bmc_events(context, (bmc_events & BMC_EVENT_ACK_MASK),
-			      SET_BMC_EVENT);
+	io.req.flags = req->msg.args[0];
+
+	rc = context->protocol->ack(context, &io);
+	if (rc < 0) {
+		return mbox_xlate_errno(context, rc);
+	}
+
+	return 0;
 }
 
 /*