aboutsummaryrefslogtreecommitdiff
path: root/hw/bt.c
diff options
context:
space:
mode:
authorAlistair Popple <alistair@popple.id.au>2014-10-23 16:14:09 +1100
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2014-10-30 16:35:51 +1100
commitb2a374da98aa710b4c55556f9a9047d4d4a8665d (patch)
tree31055569f5e456f721f011d2646be7ee6b1e9f57 /hw/bt.c
parentb118964db9acd6a36ae1ffe70c09715479a58095 (diff)
downloadskiboot-b2a374da98aa710b4c55556f9a9047d4d4a8665d.zip
skiboot-b2a374da98aa710b4c55556f9a9047d4d4a8665d.tar.gz
skiboot-b2a374da98aa710b4c55556f9a9047d4d4a8665d.tar.bz2
ipmi: Add an opal interface to the ipmi stack
This patch adds two opal calls (opal_ipmi_send and opal_ipmi_recv) to allow an operating system to send and receive arbitrary ipmi messages to the BMC. Signed-off-by: Alistair Popple <alistair@popple.id.au> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'hw/bt.c')
-rw-r--r--hw/bt.c36
1 files changed, 28 insertions, 8 deletions
diff --git a/hw/bt.c b/hw/bt.c
index 561ed14..1fe25dc 100644
--- a/hw/bt.c
+++ b/hw/bt.c
@@ -58,7 +58,9 @@
/*
* How long (in TB ticks) before a message is timed out.
*/
-#define BT_MSG_TIMEOUT (secs_to_tb(1))
+#define BT_MSG_TIMEOUT (secs_to_tb(3))
+
+#define BT_QUEUE_DEBUG 0
enum bt_states {
BT_STATE_IDLE = 0,
@@ -76,7 +78,6 @@ struct bt_msg {
struct list_node link;
unsigned long tb;
uint8_t seq;
- uint8_t lun;
struct ipmi_msg ipmi_msg;
};
@@ -132,7 +133,6 @@ 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);
- bt_msg->lun = 0;
lock(&bt.lock);
bt_msg->tb = mftb();
bt_msg->seq = ipmi_seq++;
@@ -197,7 +197,7 @@ static bool bt_try_send_msg(void)
bt_outb(ipmi_msg->req_size + BT_MIN_REQ_LEN, BT_HOST2BMC);
/* Byte 2 - NetFn/LUN */
- bt_outb((ipmi_msg->netfn << 2) | (bt_msg->lun & 0x3), BT_HOST2BMC);
+ bt_outb(ipmi_msg->netfn, BT_HOST2BMC);
/* Byte 3 - Seq */
bt_outb(bt_msg->seq, BT_HOST2BMC);
@@ -290,16 +290,13 @@ static bool bt_get_resp(void)
}
ipmi_msg->resp_size = resp_len;
- bt_msg->lun = netfn & 0x3;
- netfn = netfn >> 2;
-
/* Byte 6:N - Data */
for (i = 0; i < resp_len; i++)
ipmi_msg->data[i] = bt_inb(BT_HOST2BMC);
bt_set_h_busy(false);
if (cc != IPMI_CC_NO_ERROR)
- prerror("BT: Host error 0x%02x receiving BT/IPMI response\n", cc);
+ prerror("BT: Host error 0x%02x receiving BT/IPMI response for msg 0x%02x\n", cc, seq);
/* Make sure the other side is idle before we move to the idle state */
bt_set_state(BT_STATE_B_BUSY);
@@ -310,6 +307,10 @@ static bool bt_get_resp(void)
/*
* Call the IPMI layer to finish processing the message.
*/
+#if BT_QUEUE_DEBUG
+ prlog(PR_DEBUG, "cmd 0x%02x done\n", seq);
+#endif
+
ipmi_cmd_done(cmd, netfn, cc, ipmi_msg);
/* Immediately send the next message */
@@ -337,6 +338,25 @@ static void bt_poll(void *data __unused)
bool ret = true;
do {
+
+#if BT_QUEUE_DEBUG
+ struct bt_msg *msg;
+ static bool printed = false;
+ lock(&bt.lock);
+ if (!list_empty(&bt.msgq)) {
+ printed = false;
+ prlog(PR_DEBUG, "-------- BT Msg Queue --------\n");
+ list_for_each(&bt.msgq, msg, link) {
+ prlog(PR_DEBUG, "Seq: 0x%02x Cmd: 0x%02x\n", msg->seq, msg->ipmi_msg.cmd);
+ }
+ prlog(PR_DEBUG, "-----------------------------\n");
+ } else if (!printed) {
+ printed = true;
+ prlog(PR_DEBUG, "----- BT Msg Queue Empty -----\n");
+ }
+ unlock(&bt.lock);
+#endif
+
bt_expire_old_msg();
switch(bt.state) {