diff options
author | Alistair Popple <alistair@popple.id.au> | 2014-11-13 17:16:03 +1100 |
---|---|---|
committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2014-12-02 18:38:04 +1100 |
commit | f8a0bb99bb6879124f153a161339bbfdef2049bf (patch) | |
tree | 2b38b3d7323a76f24d5477f63c4a9fb2ffdee6a5 | |
parent | 89348d6f95a3dff8ccc1d51c132b524d60c1b1eb (diff) | |
download | skiboot-f8a0bb99bb6879124f153a161339bbfdef2049bf.zip skiboot-f8a0bb99bb6879124f153a161339bbfdef2049bf.tar.gz skiboot-f8a0bb99bb6879124f153a161339bbfdef2049bf.tar.bz2 |
ipmi/bt: Enable adding messages to the start of the queue
By default new ipmi messages are added to the end of the transmission
queue. However sometimes it is necessary to add messages to the start
of the queue. This patch adds a new ipmi function that adds messages
to the start of the transmission queue.
Signed-off-by: Alistair Popple <alistair@popple.id.au>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
-rw-r--r-- | core/ipmi.c | 5 | ||||
-rw-r--r-- | hw/bt.c | 28 | ||||
-rw-r--r-- | include/ipmi.h | 4 |
3 files changed, 32 insertions, 5 deletions
diff --git a/core/ipmi.c b/core/ipmi.c index 32f1f4d..14c35f3 100644 --- a/core/ipmi.c +++ b/core/ipmi.c @@ -64,6 +64,11 @@ struct ipmi_msg *ipmi_mkmsg(int interface, uint32_t code, return msg; } +int ipmi_queue_msg_head(struct ipmi_msg *msg) +{ + return msg->backend->queue_msg_head(msg); +} + int ipmi_queue_msg(struct ipmi_msg *msg) { /* Here we could choose which interface to use if we want to support @@ -374,14 +374,10 @@ static void bt_poll(struct timer *t __unused, void *data __unused) bt.irq_ok ? TIMER_POLL : msecs_to_tb(BT_DEFAULT_POLL_MS)); } -static int bt_add_ipmi_msg(struct ipmi_msg *ipmi_msg) +static void bt_add_msg(struct bt_msg *bt_msg) { - struct bt_msg *bt_msg = container_of(ipmi_msg, struct bt_msg, ipmi_msg); - - lock(&bt.msgq_lock); bt_msg->tb = 0; bt_msg->seq = ipmi_seq++; - list_add_tail(&bt.msgq, &bt_msg->link); bt.queue_len++; if (bt.queue_len > BT_MAX_QUEUE_LEN) { /* Maximum ueue lenght exceeded - remove the oldest message @@ -391,10 +387,31 @@ static int bt_add_ipmi_msg(struct ipmi_msg *ipmi_msg) assert(bt_msg); bt_msg_del(bt_msg); } +} + +static int bt_add_ipmi_msg_head(struct ipmi_msg *ipmi_msg) +{ + struct bt_msg *bt_msg = container_of(ipmi_msg, struct bt_msg, ipmi_msg); + + lock(&bt.msgq_lock); + bt_add_msg(bt_msg); + list_add(&bt.msgq, &bt_msg->link); unlock(&bt.msgq_lock); bt_poll(NULL, NULL); + return 0; +} + +static int bt_add_ipmi_msg(struct ipmi_msg *ipmi_msg) +{ + struct bt_msg *bt_msg = container_of(ipmi_msg, struct bt_msg, ipmi_msg); + lock(&bt.msgq_lock); + bt_add_msg(bt_msg); + list_add_tail(&bt.msgq, &bt_msg->link); + unlock(&bt.msgq_lock); + + bt_poll(NULL, NULL); return 0; } @@ -459,6 +476,7 @@ struct ipmi_backend bt_backend = { .alloc_msg = bt_alloc_ipmi_msg, .free_msg = bt_free_ipmi_msg, .queue_msg = bt_add_ipmi_msg, + .queue_msg_head = bt_add_ipmi_msg_head, .dequeue_msg = bt_del_ipmi_msg, }; diff --git a/include/ipmi.h b/include/ipmi.h index 8c178f5..38770ab 100644 --- a/include/ipmi.h +++ b/include/ipmi.h @@ -140,6 +140,7 @@ struct ipmi_backend { struct ipmi_msg *(*alloc_msg)(size_t, size_t); void (*free_msg)(struct ipmi_msg *); int (*queue_msg)(struct ipmi_msg *); + int (*queue_msg_head)(struct ipmi_msg *); int (*dequeue_msg)(struct ipmi_msg *); }; @@ -161,6 +162,9 @@ struct ipmi_msg *ipmi_mkmsg(int interface, uint32_t code, /* Add an ipmi message to the queue */ int ipmi_queue_msg(struct ipmi_msg *msg); +/* Add an ipmi message to the start of the queue */ +int ipmi_queue_msg_head(struct ipmi_msg *msg); + /* Process a completed message */ void ipmi_cmd_done(uint8_t cmd, uint8_t netfn, uint8_t cc, struct ipmi_msg *msg); |