From patchwork Thu Feb 5 03:10:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 436569 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 24EAF140218 for ; Thu, 5 Feb 2015 14:10:32 +1100 (AEDT) Received: from ozlabs.org (ozlabs.org [103.22.144.67]) by lists.ozlabs.org (Postfix) with ESMTP id 039D91A0BD7 for ; Thu, 5 Feb 2015 14:10:32 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from mail-pa0-x234.google.com (mail-pa0-x234.google.com [IPv6:2607:f8b0:400e:c03::234]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 0CAD31A0B77 for ; Thu, 5 Feb 2015 14:10:29 +1100 (AEDT) Received: by mail-pa0-f52.google.com with SMTP id kx10so6845099pab.11 for ; Wed, 04 Feb 2015 19:10:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jms.id.au; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=XzWPm1uLZl1oTlMSm0rN0PvAys6MhO/aU3yznp3DgHQ=; b=VSdDy+GXMGOp4Uc3uk0bfJQrBF/DRhPshz+OlVB9pY8aDooe1js71kgi1c8zzIJeZ0 mVj+b0y5MV0AWMBt0tO6PNWfEkyUzsqB5R+8h5Jfiw3P++izqaSsuyqortANCwPFspVS v0OcxwHN35XNvNO2dnzLKpRwbPsUpxch51hGM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=XzWPm1uLZl1oTlMSm0rN0PvAys6MhO/aU3yznp3DgHQ=; b=bY5ZfXJS5qYnffR8xPQpVZgZtb/4M/cKNJzl2vED9u8XD8cDOTckLw7XLS2vOS6M5N oHTHGJvet9HVMl8Rfy0TuBZ7gx9y6MFtGEho4u0mfctxPSVG+pvNF4QkTqd1G2DlSDR9 9bK3XiOjDuTbgXWIdB0Bc3h0LVDR1XwCuwbesnxFpBu2tfjLISN2Oer7160yOQdftUVs bQ8k6YTENUCmJqtvGWS8hTHVkRja3hWZMAcqXhRiGVnfIwk6OZA/y+bfl7/gxRfgWVKg HjD8ioGnsvFFhGyEtqMIQ8LJOgo2n1w3wOtA/Ahwq3FYbvlGcf/q6HtubBjrUZz4SWG2 XcqQ== X-Gm-Message-State: ALoCoQl0t+Qxn6TCpbOWJOksarKPv6QZpAA4nhcE+UVd/CQOD9H5EmQnt1V+yor48UeNkhlbQXVO X-Received: by 10.68.241.35 with SMTP id wf3mr2485242pbc.22.1423105826974; Wed, 04 Feb 2015 19:10:26 -0800 (PST) Received: from icarus.au.ibm.com (220-244-113-206.static.tpgi.com.au. [220.244.113.206]) by mx.google.com with ESMTPSA id zo7sm3435594pab.8.2015.02.04.19.10.23 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 04 Feb 2015 19:10:26 -0800 (PST) From: Joel Stanley To: skiboot@lists.ozlabs.org Date: Thu, 5 Feb 2015 13:40:02 +1030 Message-Id: <1423105805-3816-2-git-send-email-joel@jms.id.au> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1423105805-3816-1-git-send-email-joel@jms.id.au> References: <1423105805-3816-1-git-send-email-joel@jms.id.au> In-Reply-To: <1422577911-18394-1-git-send-email-joel@jms.id.au> References: <1422577911-18394-1-git-send-email-joel@jms.id.au> Cc: Jeremy Kerr Subject: [Skiboot] [PATCH 1/4] ipmi: handle SMS_ATN events X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" From: Jeremy Kerr When the bt interface sets the SMS_ATN flag, we perform a Get Message Flags to determine what messages are available. The only message type currently processed is the Event Message Buffer, which provides SEL messages for indicating OEM specific events such as graceful system shutdown and PNOR access requested. These events will be handled by the IPMI layer in skiboot. Signed-off-by: Jeremy Kerr Signed-off-by: Joel Stanley --- core/ipmi.c | 40 ++++++++++++++++++++++++++++++++++++++++ hw/bt.c | 6 ++++++ include/ipmi.h | 15 +++++++++++++++ 3 files changed, 61 insertions(+) diff --git a/core/ipmi.c b/core/ipmi.c index 14c35f3..35bfead 100644 --- a/core/ipmi.c +++ b/core/ipmi.c @@ -103,6 +103,46 @@ void ipmi_cmd_done(uint8_t cmd, uint8_t netfn, uint8_t cc, struct ipmi_msg *msg) completion functions. */ } +static void ipmi_read_event_complete(struct ipmi_msg *msg) +{ + prlog(PR_DEBUG, "IPMI read event %02x complete: %d bytes. cc: %02x\n", + msg->cmd, msg->resp_size, msg->cc); + + /* TODO: Handle power control & PNOR handshake events */ + + ipmi_free_msg(msg); +} + +static void ipmi_get_message_flags_complete(struct ipmi_msg *msg) +{ + uint8_t flags = msg->data[0]; + + ipmi_free_msg(msg); + + prlog(PR_DEBUG, "IPMI Get Message Flags: %02x\n", flags); + + /* Message available in the event buffer? Queue a Read Event command + * to retrieve it. The flag is cleared by performing a read */ + if (flags & IPMI_MESSAGE_FLAGS_EVENT_BUFFER) { + msg = ipmi_mkmsg(IPMI_DEFAULT_INTERFACE, IPMI_READ_EVENT, + ipmi_read_event_complete, NULL, NULL, 0, 16); + ipmi_queue_msg(msg); + } +} + +void ipmi_sms_attention(void) +{ + struct ipmi_msg *msg; + + /* todo: when we handle multiple IPMI interfaces, we'll need to + * ensure that this message is associated with the appropriate + * backend. */ + msg = ipmi_mkmsg(IPMI_DEFAULT_INTERFACE, IPMI_GET_MESSAGE_FLAGS, + ipmi_get_message_flags_complete, NULL, NULL, 0, 1); + + ipmi_queue_msg(msg); +} + void ipmi_register_backend(struct ipmi_backend *backend) { /* We only support one backend at the moment */ diff --git a/hw/bt.c b/hw/bt.c index afdd5df..d5c71a8 100644 --- a/hw/bt.c +++ b/hw/bt.c @@ -418,12 +418,18 @@ static int bt_add_ipmi_msg(struct ipmi_msg *ipmi_msg) void bt_irq(void) { uint8_t ireg = bt_inb(BT_INTMASK); + uint8_t ctrl = bt_inb(BT_CTRL); bt.irq_ok = true; if (ireg & BT_INTMASK_B2H_IRQ) { bt_outb(BT_INTMASK_B2H_IRQ | BT_INTMASK_B2H_IRQEN, BT_INTMASK); bt_poll(NULL, NULL); } + + if (ctrl & BT_CTRL_SMS_ATN) { + bt_outb(BT_CTRL_SMS_ATN, BT_CTRL); + ipmi_sms_attention(); + } } /* diff --git a/include/ipmi.h b/include/ipmi.h index 50de293..740b82a 100644 --- a/include/ipmi.h +++ b/include/ipmi.h @@ -76,6 +76,14 @@ #define IPMI_PWR_SYS_UNKNOWN 0x2a #define IPMI_PWR_NOCHANGE 0x7f +/* 22.{3,4} Clear / Get message flags */ +#define IPMI_MESSAGE_FLAGS_RX_MESSAGE_QUEUE (1<<0) +#define IPMI_MESSAGE_FLAGS_EVENT_BUFFER (1<<1) +#define IPMI_MESSAGE_FLAGS_WATCHDOG_PRE_TIMEOUT (1<<3) +#define IPMI_MESSAGE_FLAGS_OEM0 (1<<5) +#define IPMI_MESSAGE_FLAGS_OEM1 (1<<6) +#define IPMI_MESSAGE_FLAGS_OEM2 (1<<7) + #define IPMI_CODE(netfn, cmd) ((netfn) << 8 | (cmd)) #define IPMI_CMD(code) ((code) & 0xff) #define IPMI_NETFN(code) ((code) >> 8 & 0xff) @@ -93,6 +101,10 @@ #define IPMI_CHASSIS_CONTROL IPMI_CODE(IPMI_NETFN_CHASSIS, 0x02) #define IPMI_SET_POWER_STATE IPMI_CODE(IPMI_NETFN_APP, 0x06) #define IPMI_GET_POWER_STATE IPMI_CODE(IPMI_NETFN_APP, 0x07) +#define IPMI_CLEAR_MESSAGE_FLAGS IPMI_CODE(IPMI_NETFN_APP, 0x30) +#define IPMI_GET_MESSAGE_FLAGS IPMI_CODE(IPMI_NETFN_APP, 0x31) +#define IPMI_GET_MESSAGE IPMI_CODE(IPMI_NETFN_APP, 0x33) +#define IPMI_READ_EVENT IPMI_CODE(IPMI_NETFN_APP, 0x35) #define IPMI_PARTIAL_ADD_ESEL IPMI_CODE(IPMI_NETFN_OEM, 0xf0) @@ -163,6 +175,9 @@ struct ipmi_msg *ipmi_mkmsg(int interface, uint32_t code, void *user_data, void *req_data, size_t req_size, size_t resp_size); +/* called by backend code to indicate a SMS_ATN event */ +void ipmi_sms_attention(void); + /* Add an ipmi message to the queue */ int ipmi_queue_msg(struct ipmi_msg *msg);