From patchwork Fri Jan 30 00:31:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 434692 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id D086014007D for ; Fri, 30 Jan 2015 11:32:34 +1100 (AEDT) Received: from ozlabs.org (ozlabs.org [103.22.144.67]) by lists.ozlabs.org (Postfix) with ESMTP id 8420E1A05CD for ; Fri, 30 Jan 2015 11:32:34 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from mail-pa0-x230.google.com (mail-pa0-x230.google.com [IPv6:2607:f8b0:400e:c03::230]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 2FEF31A0D8B for ; Fri, 30 Jan 2015 11:32:30 +1100 (AEDT) Received: by mail-pa0-f48.google.com with SMTP id ey11so45120500pad.7 for ; Thu, 29 Jan 2015 16:32:28 -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; bh=PjqmI4N+cT2j8GeLz19LxomK4rjJwxuLdMU3lUeAqOA=; b=cY5GXgwPX0GPnbgVisEdJqwGw6LBBaiwyCe+h92cI2+gGJV2fgTAgCm65I+pQxNgbP 3PL2AGNvPV8zPRFN2hL+Jk8eoiY5zLiZOHQcnRntaNgZsIKgohxfSNZI7C+BOxuw2LDt fJfNZxu5aumXQRSf18BkQSMz2yBv04AcaF3YU= 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; bh=PjqmI4N+cT2j8GeLz19LxomK4rjJwxuLdMU3lUeAqOA=; b=A/fbVcXy2PkXEdjy/3KO6oL/I1+chqAFeH60qOPoVvkTfonS43wBH6tiR1tJoGIum7 CdrWQyZXIH0BvN7nMz3Euy4vOKL7lumQSLBdhgkVmcY+gxbFDYgpZjkmiIZr7G4yfkLg ld8iDvQ25PgXmFTti0NAOi04jCMg16EqoLa/7bVLXDjrELGKJvgPFG2vUzVJr+dxpUX8 gEbaQQzPuch8fZi8ybtcLAdAbQHcaCQCykDE7hoDEwYoCZ/VEo0GHca6lVT6pw8FHYJT d6q5g21r/lPzVFfqZcIwlm63pqhGhxZwU0KZqCr4xYHxzIYsnjAbwZ3AsSQoY3hpnh+1 toPA== X-Gm-Message-State: ALoCoQlazqhibOcCSVwIkuArAQEo+7Xn7mGUIY59ZteDoOehDwRZ8rv8xwagLQ2Z4ymAXGjDnVRR X-Received: by 10.66.193.33 with SMTP id hl1mr4602056pac.141.1422577948201; Thu, 29 Jan 2015 16:32:28 -0800 (PST) Received: from icarus.au.ibm.com (ppp121-45-7-169.lns20.adl2.internode.on.net. [121.45.7.169]) by mx.google.com with ESMTPSA id ca2sm8864916pbc.68.2015.01.29.16.32.25 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 29 Jan 2015 16:32:27 -0800 (PST) From: Joel Stanley To: skiboot@lists.ozlabs.org Date: Fri, 30 Jan 2015 11:01:49 +1030 Message-Id: <1422577911-18394-4-git-send-email-joel@jms.id.au> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1422577911-18394-1-git-send-email-joel@jms.id.au> References: <1422577911-18394-1-git-send-email-joel@jms.id.au> Subject: [Skiboot] [PATCH 3/5] ipmi: Implement Read Event and SEL parsing 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" The read event mechanism is used when the BMC has an asynchronous message for the host. It sets a flag that we read with Get Message Flags, and then we read the message using Read Event. This event message contains a SEL message. There are two OEM SEL messages we expect from the AMI BMC: - graceful power operations. This is when the BMC wants the host to power down or reboot. - PNOR Locking. When the BMC wants to access the PNOR, it requests that the host not touch it. This patch implements the parsing. Signed-off-by: Joel Stanley --- core/ipmi.c | 3 +- hw/ipmi/ipmi-sel.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/ipmi.h | 3 ++ 3 files changed, 89 insertions(+), 1 deletion(-) diff --git a/core/ipmi.c b/core/ipmi.c index 35bfead..b5ada0e 100644 --- a/core/ipmi.c +++ b/core/ipmi.c @@ -108,7 +108,8 @@ 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 */ + /* Handle power control & PNOR handshake events */ + ipmi_parse_sel(msg); ipmi_free_msg(msg); } diff --git a/hw/ipmi/ipmi-sel.c b/hw/ipmi/ipmi-sel.c index d6f7f47..301e559 100644 --- a/hw/ipmi/ipmi-sel.c +++ b/hw/ipmi/ipmi-sel.c @@ -22,6 +22,33 @@ #include #include +/* OEM SEL fields */ +#define SEL_OEM_ID_0 0x55 +#define SEL_OEM_ID_1 0x55 +#define SEL_RECORD_TYPE_OEM 0xC0 +#define SEL_RECORD_TYPE_EVENT 0x02 +#define SEL_MANUF_0 0x8E +#define SEL_MANUF_1 0xCB +#define SEL_MANUF_2 0xC8 + +#define SEL_NETFN_IBM 0x3a + +/* OEM SEL Commands */ +#define CMD_AMI_POWER 0x04 +#define CMD_AMI_PNOR_ACCESS 0x07 + +struct oem_sel { + /* SEL header */ + uint8_t id[2]; + uint8_t type; + uint8_t manuf_id[3]; + uint8_t timestamp[4]; + /* OEM SEL data (6 bytes) follows */ + uint8_t netfun; + uint8_t cmd; + uint8_t data[4]; +}; + /* As far as I can tell the size of PEL record is unbounded (due to * the possible presence of the user defined section). We chose this * size because it's what FSP uses, but we could probably reduce @@ -148,3 +175,60 @@ int ipmi_elog_commit(struct errorlog *elog_buf) return 0; } + +static void dump_sel(struct oem_sel *sel) +{ + const int level = PR_DEBUG; + + prlog(level, "\tid %02x%02x\n", sel->id[0], sel->id[1]); + prlog(level, "\ttype %02x\n", sel->type); + prlog(level, "\tmanuf %02x %02x %02x\n", + sel->manuf_id[0], sel->manuf_id[1], sel->manuf_id[2]); + prlog(level, "\ttime %02x %02x %02x %02x\n", + sel->timestamp[0], sel->timestamp[1], + sel->timestamp[2], sel->timestamp[3]); + prlog(level, "\tnetfun %02x\n", sel->netfun); + prlog(level, "\tcmd %02x\n", sel->cmd); + prlog(level, "\tdata %02x %02x %02x %02x\n", sel->data[0], + sel->data[1], sel->data[2], sel->data[3]); +} + +void ipmi_parse_sel(struct ipmi_msg *msg) +{ + struct oem_sel sel; + + prlog(PR_INFO, "SEL received (size: %d)\n", msg->resp_size); + assert(msg->resp_size <= 16); + + memcpy(&sel, msg->data, msg->resp_size); + + dump_sel(&sel); + + /* We do not process system event records */ + if (sel.type == SEL_RECORD_TYPE_EVENT) { + prlog(PR_INFO, "IPMI: dropping System Event Record SEL\n"); + return; + } + + /* Only accept OEM SEL messages */ + if (sel.id[0] != SEL_OEM_ID_0 || + sel.id[1] != SEL_OEM_ID_1 || + sel.type != SEL_RECORD_TYPE_OEM || + sel.manuf_id[0] != SEL_MANUF_0 || + sel.manuf_id[1] != SEL_MANUF_1 || + sel.manuf_id[2] != SEL_MANUF_2) { + prlog(PR_WARNING, "IPMI: unknown SEL %02x%02x (type %02x)\n", + sel.id[0], sel.id[1], sel.type); + return; + } + + switch (sel.cmd) { + case CMD_AMI_POWER: + break; + case CMD_AMI_PNOR_ACCESS: + break; + default: + printf("IPMI: unknown OEM SEL command %02x received\n", + sel.cmd); + } +} diff --git a/include/ipmi.h b/include/ipmi.h index 048e6cf..c1f0493 100644 --- a/include/ipmi.h +++ b/include/ipmi.h @@ -213,4 +213,7 @@ void ipmi_fru_init(uint8_t fru_dev_id); struct errorlog; int ipmi_elog_commit(struct errorlog *elog_buf); +/* Callback to parse an OEM SEL message */ +void ipmi_parse_sel(struct ipmi_msg *msg); + #endif