From c5c830487b1672c6184fdd8e3ec12d1735c3c232 Mon Sep 17 00:00:00 2001 From: Andrew Jeffery Date: Tue, 7 Aug 2018 23:22:05 +0930 Subject: protocol: Add ack Change-Id: I3ebad03d7f79381c683a121c181db9f30a13a3c4 Signed-off-by: Andrew Jeffery --- protocol.c | 8 ++++++++ protocol.h | 8 ++++++++ transport_mbox.c | 13 ++++++++++--- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/protocol.c b/protocol.c index b112231..293934f 100644 --- a/protocol.c +++ b/protocol.c @@ -283,6 +283,12 @@ int protocol_v1_close(struct mbox_context *context, struct protocol_close *io) 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 @@ static const struct protocol_ops protocol_ops_v1 = { .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 @@ static const struct protocol_ops protocol_ops_v2 = { .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 @@ struct protocol_close { } 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 @@ struct protocol_ops { 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 @@ int protocol_v1_mark_dirty(struct mbox_context *context, 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_close_window(struct mbox_context *context, 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; + + io.req.flags = req->msg.args[0]; - return clr_bmc_events(context, (bmc_events & BMC_EVENT_ACK_MASK), - SET_BMC_EVENT); + rc = context->protocol->ack(context, &io); + if (rc < 0) { + return mbox_xlate_errno(context, rc); + } + + return 0; } /* -- cgit v1.2.1