From: minyard@acm.org
To: qemu-devel@nongnu.org
Cc: minyard@acm.org, Corey Minyard <cminyard@mvista.com>
Subject: [Qemu-devel] [PATCH 19/19] ipmi_smbus: Add alert capability to the IPMI SSIF code
Date: Fri, 30 Dec 2016 09:21:50 -0600 [thread overview]
Message-ID: <1483111310-24808-20-git-send-email-minyard@acm.org> (raw)
In-Reply-To: <1483111310-24808-1-git-send-email-minyard@acm.org>
From: Corey Minyard <cminyard@mvista.com>
This lets you add "alertname=<name>" to specify an alert device
to use for letting the host know that the IPMI device has data
ready.
Signed-off-by: Corey Minyard <cminyard@mvista.com>
---
hw/ipmi/smbus_ipmi.c | 45 +++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 43 insertions(+), 2 deletions(-)
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)
--
2.7.4
prev parent reply other threads:[~2016-12-30 15:22 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-30 15:21 [Qemu-devel] [PATCH 01/18] Patch set to get full IPMI over SMBus minyard
2016-12-30 15:21 ` [Qemu-devel] [PATCH 01/19] i2c: Allow I2C devices to NAK start events minyard
2016-12-30 15:21 ` [Qemu-devel] [PATCH 02/19] i2c-smbus: Use a int for return minyard
2016-12-30 15:21 ` [Qemu-devel] [PATCH 03/19] i2c:pm_smbus: Clean up some style issues minyard
2016-12-30 15:21 ` [Qemu-devel] [PATCH 04/19] i2c:pm_smbus: Fix the semantics of block I2C transfers minyard
2016-12-30 15:21 ` [Qemu-devel] [PATCH 05/19] i2c:pm_smbus: Make the I2C block read command read-only minyard
2016-12-30 15:21 ` [Qemu-devel] [PATCH 06/19] i2c:pm_smbus: Add block transfer capability minyard
2016-12-30 15:21 ` [Qemu-devel] [PATCH 07/19] i2c:pm_smbus: Fix state transfer minyard
2016-12-30 15:21 ` [Qemu-devel] [PATCH 08/19] i2c:pm_smbus: Add interrupt handling minyard
2016-12-30 15:21 ` [Qemu-devel] [PATCH 09/19] i2c:pm_smbus: Add the ability to force block transfer enable minyard
2016-12-30 15:21 ` [Qemu-devel] [PATCH 10/19] ipmi: Add an SMBus IPMI interface minyard
2016-12-30 15:21 ` [Qemu-devel] [PATCH 11/19] acpi: Add i2c serial bus CRS handling minyard
2016-12-30 15:21 ` [Qemu-devel] [PATCH 12/19] ipmi: Fix SSIF ACPI handling to use the right CRS minyard
2016-12-30 15:21 ` [Qemu-devel] [PATCH 13/19] pc: Add _enabled to the end of some boolean flags minyard
2016-12-30 15:21 ` [Qemu-devel] [PATCH 14/19] pc: Add an SMB0 ACPI device to q35 minyard
2016-12-30 15:21 ` [Qemu-devel] [PATCH 15/19] hw: Add an IRQ interface minyard
2016-12-30 15:21 ` [Qemu-devel] [PATCH 16/19] isa: Add an irq device minyard
2016-12-30 15:21 ` [Qemu-devel] [PATCH 17/19] i2c: Allow SMBus device to NAK start events minyard
2016-12-30 15:21 ` [Qemu-devel] [PATCH 18/19] i2c: Add an SMBus alert device minyard
2016-12-30 15:21 ` minyard [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1483111310-24808-20-git-send-email-minyard@acm.org \
--to=minyard@acm.org \
--cc=cminyard@mvista.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).