From patchwork Fri Dec 30 15:21:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 89387 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp6490262qgi; Fri, 30 Dec 2016 07:34:12 -0800 (PST) X-Received: by 10.55.195.148 with SMTP id r20mr44908979qkl.45.1483112052520; Fri, 30 Dec 2016 07:34:12 -0800 (PST) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id g5si7039852qkf.117.2016.12.30.07.34.12 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 30 Dec 2016 07:34:12 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Received: from localhost ([::1]:40354 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cMzC8-0003LZ-1x for patch@linaro.org; Fri, 30 Dec 2016 10:34:12 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43351) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cMz0U-0002Mc-0v for qemu-devel@nongnu.org; Fri, 30 Dec 2016 10:22:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cMz0S-0000HV-Tk for qemu-devel@nongnu.org; Fri, 30 Dec 2016 10:22:10 -0500 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:35738) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cMz0S-0000H0-Nz for qemu-devel@nongnu.org; Fri, 30 Dec 2016 10:22:08 -0500 Received: by mail-pg0-x241.google.com with SMTP id i5so22381182pgh.2 for ; Fri, 30 Dec 2016 07:22:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=3xYnHpjfJgDAORcT4PdA0fqMbjifqSX2JP4AIGOPMRs=; b=nfIaq3pT1gBCJqrpE4P83/RfGegtyib4mZyPHkO86rNJujIDh40uh0V9UKl4wQSZi0 pY6z0N3X9DsmLWJ87HIT3xCiSf8RR88WMGX/D42mvq6W5h6zfY7RmtKa21wZEA7g1T4C YXIOxq4j9SCTHhXno66TIMRTXBNJPyKV8gYCpQtr32E16r8jEkUkk0+Kk6CJoKGStHlR 67bJ8xMnuUPzOBPyR5tTVUOi7h9/v76U5wuGLXSkmhF3nJLn16MOw8n2tGTyrCsCt0UH L3rvuyQrB9ynWUIO3Fwd/g4Aqxbk036lgU/iLrYy3ajvx1fkVY9ziAJbLgSTcdzbWQgk hjHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=3xYnHpjfJgDAORcT4PdA0fqMbjifqSX2JP4AIGOPMRs=; b=qVFfuUvKz+KjXKtLbnm9t5Cd5AcnfakSG8MvSOk9+dNU4mWwpn8RHiU046GdyjY4Nz fZjg2wqBHf8eYYGjCnHjEUQax5YkLqc6wx5eVU18F9xNR/ptwR9cV8taVH8zARhuLFLx JFmOlxYcLlzzAaC8FFzzi4tghnlL5u1n1KMVHAIkYAVGrL9Cgk1M196pN8xW97JyHN4o F3j3skkJTlUQIuD8JQ4tuStJKZC+ZUA3tCp0iEtiBZxJRQ9D5Jj9kcPDhkM8xNEkUd1d ERlQyjHVhvNvlbltaPw9oc6afFq9G6tju/yBvGo1PCAiPXdc2l+8o7UhKTiIkEBw9vFZ UkQw== X-Gm-Message-State: AIkVDXI7jF0+/Aajf7R/Zxxt7SwsAkC3EZbgDA9Z11a5/yrGzlKm87DM/5lPkNoXlf6RYQ== X-Received: by 10.84.195.228 with SMTP id j91mr98088997pld.88.1483111327970; Fri, 30 Dec 2016 07:22:07 -0800 (PST) Received: from serve.minyard.net (serve.minyard.net. [2001:470:b8f6:1b::1]) by smtp.gmail.com with ESMTPSA id w5sm113552829pfl.31.2016.12.30.07.22.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Dec 2016 07:22:02 -0800 (PST) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id 15FECA24A; Fri, 30 Dec 2016 09:21:57 -0600 (CST) Received: by t430.minyard.net (Postfix, from userid 1000) id E6959300097; Fri, 30 Dec 2016 09:21:54 -0600 (CST) From: minyard@acm.org To: qemu-devel@nongnu.org Date: Fri, 30 Dec 2016 09:21:50 -0600 Message-Id: <1483111310-24808-20-git-send-email-minyard@acm.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1483111310-24808-1-git-send-email-minyard@acm.org> References: <1483111310-24808-1-git-send-email-minyard@acm.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c05::241 Subject: [Qemu-devel] [PATCH 19/19] ipmi_smbus: Add alert capability to the IPMI SSIF code X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Corey Minyard , minyard@acm.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Corey Minyard This lets you add "alertname=" to specify an alert device to use for letting the host know that the IPMI device has data ready. Signed-off-by: Corey Minyard --- hw/ipmi/smbus_ipmi.c | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/hw/ipmi/smbus_ipmi.c b/hw/ipmi/smbus_ipmi.c index 4d99b48..5c7b7c2 100644 --- a/hw/ipmi/smbus_ipmi.c +++ b/hw/ipmi/smbus_ipmi.c @@ -24,6 +24,7 @@ #include "qemu/osdep.h" #include "hw/hw.h" #include "hw/i2c/smbus.h" +#include "hw/i2c/smbus_alert.h" #include "qapi/error.h" #include "qemu/error-report.h" #include "hw/ipmi/ipmi.h" @@ -49,6 +50,8 @@ typedef struct SMBusIPMIDevice { uint8_t inmsg[MAX_IPMI_MSG_SIZE]; uint32_t inlen; + bool irqs_enabled; + /* * This is a response number that we send with the command to make * sure that the response matches the command. @@ -56,11 +59,15 @@ typedef struct SMBusIPMIDevice { uint8_t waiting_rsp; uint32_t uuid; + + SMBusAlertEntry alert_entry; + SMBusAlertDevice *alertdev; + SMBusAlertDeviceClass *alertdevclass; } SMBusIPMIDevice; static void smbus_ipmi_handle_event(IPMIInterface *ii) { - /* No interrupts, so nothing to do here. */ + /* Nothing to do here, we don't use events for SMBus. */ } static void smbus_ipmi_handle_rsp(IPMIInterface *ii, uint8_t msg_id, @@ -74,16 +81,27 @@ static void smbus_ipmi_handle_rsp(IPMIInterface *ii, uint8_t msg_id, memcpy(sid->outmsg, rsp, rsp_len); sid->outlen = rsp_len; sid->outpos = 0; + + if (sid->alertdev && sid->irqs_enabled) { + sid->alertdevclass->alert(sid->alertdev, &sid->alert_entry); + } } } static void smbus_ipmi_set_atn(IPMIInterface *ii, int val, int irq) { - /* This is where PEC would go. */ + SMBusIPMIDevice *sid = SMBUS_IPMI(ii); + + if (sid->alertdev && sid->irqs_enabled) { + sid->alertdevclass->alert(sid->alertdev, &sid->alert_entry); + } } static void smbus_ipmi_set_irq_enable(IPMIInterface *ii, int val) { + SMBusIPMIDevice *sid = SMBUS_IPMI(ii); + + sid->irqs_enabled = val; } static void ipmi_quick_cmd(SMBusDevice *dev, uint8_t read) @@ -149,6 +167,12 @@ static const VMStateDescription vmstate_smbus_ipmi = { .minimum_version_id = 1, .fields = (VMStateField[]) { VMSTATE_UINT8(waiting_rsp, SMBusIPMIDevice), + VMSTATE_BOOL(irqs_enabled, SMBusIPMIDevice), + VMSTATE_UINT32(outpos, SMBusIPMIDevice), + VMSTATE_VBUFFER_UINT32(outmsg, SMBusIPMIDevice, 1, NULL, 0, + outlen), + VMSTATE_VBUFFER_UINT32(inmsg, SMBusIPMIDevice, 1, NULL, 0, + inlen), VMSTATE_END_OF_LIST() } }; @@ -165,14 +189,31 @@ static void smbus_ipmi_realize(DeviceState *dev, Error **errp) sid->uuid = ipmi_next_uuid(); + if (sid->alertdev) { + sid->alertdevclass = SMBUS_ALERT_DEVICE_GET_CLASS(sid->alertdev); + } + + sid->alert_entry.val = sid->parent.i2c.address << 1; + sid->bmc->intf = ii; } +static void alert_check(Object *obj, const char *name, + Object *val, Error **errp) +{ + /* Always succeed. */ +} + static void smbus_ipmi_init(Object *obj) { SMBusIPMIDevice *sid = SMBUS_IPMI(obj); ipmi_bmc_find_and_link(OBJECT(obj), (Object **) &sid->bmc); + + object_property_add_link(obj, "alert", TYPE_SMBUS_ALERT_DEVICE, + (Object **) &sid->alertdev, alert_check, + OBJ_PROP_LINK_UNREF_ON_RELEASE, + &error_abort); } static void smbus_ipmi_get_fwinfo(struct IPMIInterface *ii, IPMIFwInfo *info)