Skip to contentSkip to conversation

hw/ipmi: add an aspeed IPMI iBT device model

RFC In review Titus Rwantare 2 participants 4 messages Sep 28, 2021 – Sep 29, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover hw/ipmi: add an aspeed IPMI iBT device model

This patch follows the Handing IPMI for emulating BMC patch set by Hao Wu. Building on top of the work in [PATCH] hw/misc: Add an iBT device model posted by Cédric Le Goater, this iBT model works as a backend to ipmi-host-extern.

Needed to run:
- [PATCH 4/8] hw/ipmi: Refactor IPMI interface, Hao Wu
- [PATCH 5/8] hw/ipmi: Take out common from ipmi_bmc_extern.c, Hao Wu
- [PATCH 6/8] hw/ipmi: Move handle_command to IPMICoreClass, Hao Wu
- [PATCH 7/8] hw/ipmi: Add an IPMI external host device, Hao Wu

Host commandline

    -chardev socket,id=ipmichr1,host=localhost,port=9999,reconnect=10 \
    -device ipmi-bmc-extern,chardev=ipmichr1,id=bmc0 \
    -device isa-ipmi-bt,bmc=bmc0,irq=10 -nodefaults

BMC commandline

    -chardev socket,id=ipmichr1,host=localhost,port=9999,server=on,wait=off \
    -device "ipmi-host-extern,chardev=ipmichr1,responder=/machine/soc/ibt"

Currently, IRQs are not functional, but it is able to connect. The following printout is from the host:

[    6.869742] ipmi_si IPI0001:00: IPMI message handler: Found new BMC (man_id:
 0x002b79, prod_id: 0x0000, dev_id: 0x00)
[   12.393281] ipmi_si IPI0001:00: IPMI bt interface initialized

This patch is an RFC because of the missing IRQs and the need for other patches to get merged.

Thank you all.

Titus Rwantare (1):
hw/ipmi: add an aspeed ipmi iBT device model

 hw/ipmi/ipmi_extern.h        |   1 +
 include/hw/arm/aspeed_soc.h  |   2 +
 include/hw/ipmi/aspeed_ibt.h |  77 +++++++++
 hw/arm/aspeed_ast2600.c      |  12 ++
 hw/arm/aspeed_soc.c          |  12 ++
 hw/ipmi/aspeed_ibt.c         | 311 +++++++++++++++++++++++++++++++++++
 hw/ipmi/meson.build          |   1 +
 hw/ipmi/trace-events         |   7 +
 8 files changed, 423 insertions(+)
 create mode 100644 include/hw/ipmi/aspeed_ibt.h
 create mode 100644 hw/ipmi/aspeed_ibt.c
Signature · 1 line
2.33.0.800.g4c38ced690-goog
#1 lore raw

RFC 1/1 hw/ipmi: add an aspeed ipmi iBT device model

Modifies [PATCH] hw/misc: Add an iBT device model
posted by Cédric Le Goater, to use IPMIInterface.

---
 hw/ipmi/ipmi_extern.h        |   1 +
 include/hw/arm/aspeed_soc.h  |   2 +
 include/hw/ipmi/aspeed_ibt.h |  77 +++++++++
 hw/arm/aspeed_ast2600.c      |  12 ++
 hw/arm/aspeed_soc.c          |  12 ++
 hw/ipmi/aspeed_ibt.c         | 311 +++++++++++++++++++++++++++++++++++
 hw/ipmi/meson.build          |   1 +
 hw/ipmi/trace-events         |   7 +
 8 files changed, 423 insertions(+)
 create mode 100644 include/hw/ipmi/aspeed_ibt.h
 create mode 100644 hw/ipmi/aspeed_ibt.c
hw/ipmi/ipmi_extern.h +1 -0
index e4aa80a0f6..40157ab0b3 100644
@@ -27,6 +27,7 @@
 
 #include "qemu/osdep.h"
 #include "hw/ipmi/ipmi.h"
+#include "chardev/char-fe.h"
 
 #define VM_MSG_CHAR        0xA0 /* Marks end of message */
 #define VM_CMD_CHAR        0xA1 /* Marks end of a command */
include/hw/arm/aspeed_soc.h +2 -0
index 87d76c9259..f650ff83ae 100644
@@ -30,6 +30,7 @@
 #include "hw/usb/hcd-ehci.h"
 #include "qom/object.h"
 #include "hw/misc/aspeed_lpc.h"
+#include "hw/ipmi/aspeed_ibt.h"
 
 #define ASPEED_SPIS_NUM  2
 #define ASPEED_EHCIS_NUM 2
@@ -65,6 +66,7 @@ struct AspeedSoCState {
     AspeedSDHCIState sdhci;
     AspeedSDHCIState emmc;
     AspeedLPCState lpc;
+    AspeedIBTState ibt;
     uint32_t uart_default;
 };
 
include/hw/ipmi/aspeed_ibt.h new file +77 -0

77 lines not on this page · raw message

hw/arm/aspeed_ast2600.c +12 -0
index 9d70e8e060..f40fa69a53 100644
@@ -216,6 +216,8 @@ static void aspeed_soc_ast2600_init(Object *obj)
 
     snprintf(typename, sizeof(typename), "aspeed.hace-%s", socname);
     object_initialize_child(obj, "hace", &s->hace, typename);
+
+    object_initialize_child(obj, "ibt", &s->ibt, TYPE_ASPEED_IBT);
 }
 
 /*
@@ -507,6 +509,16 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
     sysbus_mmio_map(SYS_BUS_DEVICE(&s->hace), 0, sc->memmap[ASPEED_DEV_HACE]);
     sysbus_connect_irq(SYS_BUS_DEVICE(&s->hace), 0,
                        aspeed_soc_get_irq(s, ASPEED_DEV_HACE));
+
+    /* iBT */
+    if (!sysbus_realize(SYS_BUS_DEVICE(&s->ibt), errp)) {
+        return;
+    }
+    memory_region_add_subregion(&s->lpc.iomem,
+                   sc->memmap[ASPEED_DEV_IBT] - sc->memmap[ASPEED_DEV_LPC],
+                   &s->ibt.iomem);
+    sysbus_connect_irq(SYS_BUS_DEVICE(&s->ibt), 0,
+                       aspeed_soc_get_irq(s, ASPEED_DEV_IBT));
 }
 
 static void aspeed_soc_ast2600_class_init(ObjectClass *oc, void *data)
hw/arm/aspeed_soc.c +12 -0
index ed84502e23..13543d37c5 100644
@@ -216,6 +216,8 @@ static void aspeed_soc_init(Object *obj)
 
     snprintf(typename, sizeof(typename), "aspeed.hace-%s", socname);
     object_initialize_child(obj, "hace", &s->hace, typename);
+
+    object_initialize_child(obj, "ibt", &s->ibt, TYPE_ASPEED_IBT);
 }
 
 static void aspeed_soc_realize(DeviceState *dev, Error **errp)
@@ -426,6 +428,16 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
     sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 1 + aspeed_lpc_kcs_4,
                        qdev_get_gpio_in(DEVICE(&s->lpc), aspeed_lpc_kcs_4));
 
+    /* iBT */
+    if (!sysbus_realize(SYS_BUS_DEVICE(&s->ibt), errp)) {
+        return;
+    }
+    memory_region_add_subregion(&s->lpc.iomem,
+                   sc->memmap[ASPEED_DEV_IBT] - sc->memmap[ASPEED_DEV_LPC],
+                   &s->ibt.iomem);
+    sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 1 + aspeed_lpc_ibt,
+                       qdev_get_gpio_in(DEVICE(&s->lpc), aspeed_lpc_ibt));
+
     /* HACE */
     object_property_set_link(OBJECT(&s->hace), "dram", OBJECT(s->dram_mr),
                              &error_abort);
hw/ipmi/aspeed_ibt.c new file +311 -0

311 lines not on this page · raw message

hw/ipmi/meson.build +1 -0
index 3d8b030ba5..7e7bced38e 100644
@@ -9,5 +9,6 @@ ipmi_ss.add(when: 'CONFIG_PCI_IPMI_BT', if_true: files('pci_ipmi_bt.c'))
 ipmi_ss.add(when: 'CONFIG_IPMI_SSIF', if_true: files('smbus_ipmi.c'))
 ipmi_ss.add(when: 'CONFIG_IPMI_HOST', if_true: files('ipmi_host_extern.c'))
 ipmi_ss.add(when: 'CONFIG_NPCM7XX', if_true: files('npcm7xx_kcs.c'))
+ipmi_ss.add(when: 'CONFIG_IPMI_HOST', if_true: files('aspeed_ibt.c'))
 
 softmmu_ss.add_all(when: 'CONFIG_IPMI', if_true: ipmi_ss)
hw/ipmi/trace-events +7 -0
index 66d40bccbc..efbedfdd62 100644
@@ -6,3 +6,10 @@ npcm7xx_kcs_write(const char *id, int channel, int reg, uint8_t value) " %s chan
 npcm7xx_kcs_handle_event(const char *id, uint8_t status) " %s: %" PRIu8
 npcm7xx_kcs_host_read_byte(const char *id, uint8_t value) " %s: value 0x%02" PRIx8
 npcm7xx_kcs_host_write_byte(const char *id, uint8_t value) " %s: value 0x%02" PRIx8
+
+# aspeed_ibt.c
+aspeed_ibt_chr_dump_msg(const char *func, const char *buf, uint32_t len) "%s: %s #%d bytes"
+aspeed_ibt_chr_event(bool connected) "connected:%d"
+aspeed_ibt_read(uint64_t offset, uint64_t value) "offset:0x%" PRIx64 " value:0x%" PRIx64
+aspeed_ibt_write(uint64_t offset, uint64_t value) "offset:0x%" PRIx64 " value:0x%" PRIx64
+aspeed_ibt_event(const char* event) "%s"
Signature · 1 line
2.33.0.800.g4c38ced690-goog
#2 lore raw
In reply to Titus Rwantare

Hello Titus,

Quoted 3 lines · Titus Rwantare

This patch follows the Handing IPMI for emulating BMC patch set by Hao Wu. Building on top of the work in [PATCH] hw/misc: Add an iBT device model posted by Cédric Le Goater, this iBT model works as a backend to ipmi-host-extern.

Could you please resend with my patch which is still available here :

https://github.com/legoater/qemu/commit/c6b679690f32534e8992d96752d90d2c4aa48130

or here :

http://patchwork.ozlabs.org/project/qemu-devel/patch/[email protected]/

and in another patch, the modifications you made on top of mine. That will help understand where the problem could be.

You can modify patches but you need to keep the original author name, commit log, signed-off-by to certify its origin. Then list the changes you have made and add your signed-off-by.

The patch you sent seems to be mostly mine and I don't see any of the above.

Here is some more info in the kernel documentation :

https://www.kernel.org/doc/html/v4.12/process/submitting-patches.html#sign-your-work-the-developer-s-certificate-of-origin

I don't think we have the same kind of documentation in QEMU but it's the same process.

Quoted 5 lines

Needed to run:
- [PATCH 4/8] hw/ipmi: Refactor IPMI interface, Hao Wu
- [PATCH 5/8] hw/ipmi: Take out common from ipmi_bmc_extern.c, Hao Wu
- [PATCH 6/8] hw/ipmi: Move handle_command to IPMICoreClass, Hao Wu
- [PATCH 7/8] hw/ipmi: Add an IPMI external host device, Hao Wu

I have no idea what these patches do and where they are. They seem to modify the core IPMI framework and it is important to understand the overall changes. Please include them in the patchset first since they are initial requirements.

Quoted 8 lines

Host commandline

     -chardev socket,id=ipmichr1,host=localhost,port=9999,reconnect=10 \
     -device ipmi-bmc-extern,chardev=ipmichr1,id=bmc0 \
     -device isa-ipmi-bt,bmc=bmc0,irq=10 -nodefaults

BMC commandline

     -chardev socket,id=ipmichr1,host=localhost,port=9999,server=on,wait=off \
     -device "ipmi-host-extern,chardev=ipmichr1,responder=/machine/soc/ibt"

Could we have the full command lines also ?

Quoted 9 lines

Currently, IRQs are not functional, but it is able to connect. The following printout is from the host:

[    6.869742] ipmi_si IPI0001:00: IPMI message handler: Found new BMC (man_id:
  0x002b79, prod_id: 0x0000, dev_id: 0x00)
[   12.393281] ipmi_si IPI0001:00: IPMI bt interface initialized

This patch is an RFC because of the missing IRQs and the need for other patches to get merged.

We will need the whole project to start reviewing.

Thanks,

C.

Quoted 18 lines

Thank you all.

Titus Rwantare (1):
hw/ipmi: add an aspeed ipmi iBT device model

  hw/ipmi/ipmi_extern.h        |   1 +
  include/hw/arm/aspeed_soc.h  |   2 +
  include/hw/ipmi/aspeed_ibt.h |  77 +++++++++
  hw/arm/aspeed_ast2600.c      |  12 ++
  hw/arm/aspeed_soc.c          |  12 ++
  hw/ipmi/aspeed_ibt.c         | 311 +++++++++++++++++++++++++++++++++++
  hw/ipmi/meson.build          |   1 +
  hw/ipmi/trace-events         |   7 +
  8 files changed, 423 insertions(+)

create mode 100644 include/hw/ipmi/aspeed_ibt.h
create mode 100644 hw/ipmi/aspeed_ibt.c

#3 lore raw
Quoted 26 lines · Cédric Le Goater

Hello Titus,

Quoted 3 lines · Titus Rwantare

This patch follows the Handing IPMI for emulating BMC patch set by Hao Wu. Building on top of the work in [PATCH] hw/misc: Add an iBT device model posted by Cédric Le Goater, this iBT model works as a backend to ipmi-host-extern.

Could you please resend with my patch which is still available here :

https://github.com/legoater/qemu/commit/c6b679690f32534e8992d96752d90d2c4aa48130

or here :

http://patchwork.ozlabs.org/project/qemu-devel/patch/[email protected]/

and in another patch, the modifications you made on top of mine. That will help understand where the problem could be.

You can modify patches but you need to keep the original author name, commit log, signed-off-by to certify its origin. Then list the changes you have made and add your signed-off-by.

The patch you sent seems to be mostly mine and I don't see any of the above.

Quoted 6 lines

Here is some more info in the kernel documentation :

https://www.kernel.org/doc/html/v4.12/process/submitting-patches.html#sign-your-work-the-developer-s-certificate-of-origin

I don't think we have the same kind of documentation in QEMU but it's the same process.

Thanks, I'm still learning.

Quoted 7 lines
Quoted 6 lines

Needed to run:
- [PATCH 4/8] hw/ipmi: Refactor IPMI interface, Hao Wu
- [PATCH 5/8] hw/ipmi: Take out common from ipmi_bmc_extern.c, Hao Wu
- [PATCH 6/8] hw/ipmi: Move handle_command to IPMICoreClass, Hao Wu
- [PATCH 7/8] hw/ipmi: Add an IPMI external host device, Hao Wu

Quoted 5 lines

I have no idea what these patches do and where they are. They seem to modify the core IPMI framework and it is important to understand the overall changes. Please include them in the patchset first since they are initial requirements.

I've pushed everything here: https://github.com/Rwantare/qemu/tree/aspeed-ibt
The other patches are out for review and will likely change before merging

Quoted 11 lines
Quoted 8 lines

Host commandline

     -chardev socket,id=ipmichr1,host=localhost,port=9999,reconnect=10 \
     -device ipmi-bmc-extern,chardev=ipmichr1,id=bmc0 \
     -device isa-ipmi-bt,bmc=bmc0,irq=10 -nodefaults

BMC commandline

     -chardev socket,id=ipmichr1,host=localhost,port=9999,server=on,wait=off \
     -device "ipmi-host-extern,chardev=ipmichr1,responder=/machine/soc/ibt"

Could we have the full command lines also ?

Sure, there's not much else there, one of the bmc firmwares I'm testing with is a quanta-q71l-bmc which should build from OpenBMC.

Host:
qemu-system-x86_64 \
-nographic -m 4G \
-kernel arch/x86/boot/bzImage -append "console=ttyS0 earlyprintk=ttyS0" \
-serial /dev/tty -monitor /dev/pts/9 -initrd u-root.cpio \
-chardev socket,id=ipmichr0,host=localhost,port=9999,reconnect=10 \
-device ipmi-bmc-extern,chardev=ipmichr0,id=bmc0 \
-device isa-ipmi-bt,bmc=bmc0,irq=10 -nodefaults

BMC:
qemu-system-arm \
-machine quanta-q71l-bmc \
-nographic \
-drive file=path/to/openbmc/image,if=mtd,bus=0,unit=0,snapshot=on \
-chardev socket,id=ipmichr1,host=localhost,port=9999,server=on,wait=off \
-device "ipmi-host-extern,chardev=ipmichr1,responder=/machine/soc/ibt"

Quoted 8 lines
Quoted 8 lines

Currently, IRQs are not functional, but it is able to connect. The following printout is from the host:

[    6.869742] ipmi_si IPI0001:00: IPMI message handler: Found new BMC (man_id:
  0x002b79, prod_id: 0x0000, dev_id: 0x00)
[   12.393281] ipmi_si IPI0001:00: IPMI bt interface initialized
Quoted 8 lines
Quoted 2 lines

This patch is an RFC because of the missing IRQs and the need for other patches to get merged.

We will need the whole project to start reviewing.

Thanks,

C.

Noted, I think I should be able to send the BT commits from
https://github.com/Rwantare/qemu/tree/aspeed-ibt
after the others are reviewed and merged.
For now, the irq setup is my point of confusion.

Thanks,
-Titus