IPMI patch queue
cover IPMI patch queue
Sending this out for review, nothing big, but these would be good for the next release.
-corey
PATCH 1/5 ipmi: Add man page pieces for the IPMI PCI devices
From: Corey Minyard <[email protected]>
This was forgotten when the devices were added.
--- qemu-options.hx | 13 +++++++++++++ 1 file changed, 13 insertions(+)
qemu-options.hx +13 -0
@@ -795,6 +795,19 @@ set this to 0. Like the KCS interface, but defines a BT interface. The default port is 0xe4 and the default interrupt is 5. +@item -device pci-ipmi-kcs,bmc=@var{id} + +Add a KCS IPMI interafce on the PCI bus. + +@table @option +@item bmc=@var{id} +The BMC to connect to, one of ipmi-bmc-sim or ipmi-bmc-extern above. +@end table + +@item -device pci-ipmi-bt,bmc=@var{id} + +Like the KCS interface, but defines a BT interface on the PCI bus. + ETEXI DEF("name", HAS_ARG, QEMU_OPTION_name,
Signature · 1 line
2.17.1
PATCH 2/5 smbus-eeprom: remove PROP_PTR
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Instead, set the initial data field directly.
(the initial data is an array of 256 bytes. As I don't know if it may change over time, I keep the pointer to original buffer as is, but it might be worth to consider to copy it instead)
Message-Id: <[email protected]>
--- hw/i2c/smbus_eeprom.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
hw/i2c/smbus_eeprom.c +8 -9
@@ -44,7 +44,7 @@typedef struct SMBusEEPROMDevice {SMBusDevice smbusdev;uint8_t data[SMBUS_EEPROM_SIZE ]; -void *init_data; +uint8_t *init_data;uint8_t offset;bool accessed; }SMBusEEPROMDevice ;
@@ -129,14 +129,14 @@ static void smbus_eeprom_reset(DeviceState *dev)static void smbus_eeprom_realize (DeviceState *dev,Error **errp) { +SMBusEEPROMDevice *eeprom =SMBUS_EEPROM (dev); +smbus_eeprom_reset (dev); +if (eeprom->init_data ==NULL ) { +error_setg (errp,"init_data cannot be NULL" ); + } } -static Property smbus_eeprom_properties[] = { -DEFINE_PROP_PTR ("data" , SMBusEEPROMDevice, init_data), -DEFINE_PROP_END_OF_LIST (), -}; -static void smbus_eeprom_class_initfn (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass);
@@ -146,9 +146,8 @@ static void smbus_eeprom_class_initfn(ObjectClass *klass, void *data) dc->reset = smbus_eeprom_reset; sc->receive_byte = eeprom_receive_byte; sc->write_data = eeprom_write_data; - dc->props = smbus_eeprom_properties; dc->vmsd = &vmstate_smbus_eeprom; -/* Reason: pointer property "data" */ +/* Reason: init_data */ dc->user_creatable = false; }
@@ -172,7 +171,7 @@ void smbus_eeprom_init_one(I2CBus *smbus, uint8_t address, uint8_t *eeprom_buf) dev =qdev_create ((BusState *) smbus,TYPE_SMBUS_EEPROM );qdev_prop_set_uint8 (dev,"address" , address); -qdev_prop_set_ptr (dev,"data" , eeprom_buf); +SMBUS_EEPROM (dev)->init_data = eeprom_buf;qdev_init_nofail (dev); }
Signature · 1 line
2.17.1
PATCH 3/5 ipmi: add SET_SENSOR_READING command
In reply to [email protected]From: Cédric Le Goater <[email protected]>
SET_SENSOR_READING is a complex IPMI command (see IPMI spec 35.17) which enables the host software to set the reading value and the event status of sensors supporting it.
Below is a proposal for all the operations (reading, assert, deassert, event data) with the following limitations :
- No event are generated for threshold-based sensors.
- The case in which the BMC needs to generate its own events is not supported.
Message-Id: <[email protected]>
[Moved the break statement for case SENSOR_GEN_EVENT_DATA above the
closing brace to keep the indention consistent.]
--- hw/ipmi/ipmi_bmc_sim.c | 223 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 223 insertions(+)
hw/ipmi/ipmi_bmc_sim.c +223 -0
@@ -49,6 +49,7 @@#define IPMI_CMD_GET_SENSOR_READING 0x2d#define IPMI_CMD_SET_SENSOR_TYPE 0x2e#define IPMI_CMD_GET_SENSOR_TYPE 0x2f +#define IPMI_CMD_SET_SENSOR_READING 0x30/* #define IPMI_NETFN_APP 0x06 In ipmi.h */
@@ -1747,6 +1748,227 @@ static void get_sensor_type(IPMIBmcSim *ibs,rsp_buffer_push (rsp, sens->evt_reading_type_code); } +/* +* bytes parameter +* 1 sensor number +* 2 operation (see below for bits meaning) +* 3 sensor reading +* 4:5 assertion states (optional) +* 6:7 deassertion states (optional) +* 8:10 event data 1,2,3 (optional) +*/ +static void set_sensor_reading (IPMIBmcSim *ibs, +uint8_t *cmd,unsigned int cmd_len, +RspBuffer *rsp) +{ +IPMISensor *sens; +uint8_t evd1 =0 ; +uint8_t evd2 =0 ; +uint8_t evd3 =0 ; +uint8_t new_reading =0 ; +uint16_t new_assert_states =0 ; +uint16_t new_deassert_states =0 ; +bool change_reading = false; +bool change_assert = false; +bool change_deassert = false; +enum { +SENSOR_GEN_EVENT_NONE , +SENSOR_GEN_EVENT_DATA , +SENSOR_GEN_EVENT_BMC , + } do_gen_event =SENSOR_GEN_EVENT_NONE ; + +if ((cmd[2 ] >=MAX_SENSORS ) || + !IPMI_SENSOR_GET_PRESENT (ibs->sensors + cmd[2 ])) { +rsp_buffer_set_error (rsp,IPMI_CC_REQ_ENTRY_NOT_PRESENT ); +return ; + } + + sens = ibs->sensors + cmd[2 ]; + +/* [1:0] Sensor Reading operation */ +switch ((cmd[3 ]) &0x3 ) { +case 0 :/* Do not change */ +break ; +case 1 :/* write given value to sensor reading byte */ + new_reading = cmd[4 ]; +if (sens->reading != new_reading) { + change_reading = true; + } +break ; +case 2 : +case 3 : +rsp_buffer_set_error (rsp,IPMI_CC_INVALID_DATA_FIELD ); +return ; + } + +/* [3:2] Deassertion bits operation */ +switch ((cmd[3 ] >>2 ) &0x3 ) { +case 0 :/* Do not change */ +break ; +case 1 :/* write given value */ +if (cmd_len >7 ) { + new_deassert_states = cmd[7 ]; + change_deassert = true; + } +if (cmd_len >8 ) { + new_deassert_states |= (cmd[8 ] <<8 ); + } +break ; + +case 2 :/* mask on */ +if (cmd_len >7 ) { + new_deassert_states = (sens->deassert_states | cmd[7 ]); + change_deassert = true; + } +if (cmd_len >8 ) { + new_deassert_states |= (sens->deassert_states | (cmd[8 ] <<8 )); + } +break ; + +case 3 :/* mask off */ +if (cmd_len >7 ) { + new_deassert_states = (sens->deassert_states & cmd[7 ]); + change_deassert = true; + } +if (cmd_len >8 ) { + new_deassert_states |= (sens->deassert_states & (cmd[8 ] <<8 )); + } +break ; + } + +if (change_deassert && (new_deassert_states == sens->deassert_states)) { + change_deassert = false; + } + +/* [5:4] Assertion bits operation */ +switch ((cmd[3 ] >>4 ) &0x3 ) { +case 0 :/* Do not change */ +break ; +case 1 :/* write given value */ +if (cmd_len >5 ) { + new_assert_states = cmd[5 ]; + change_assert = true; + } +if (cmd_len >6 ) { + new_assert_states |= (cmd[6 ] <<8 ); + } +break ; + +case 2 :/* mask on */ +if (cmd_len >5 ) { + new_assert_states = (sens->assert_states | cmd[5 ]); + change_assert = true; + } +if (cmd_len >6 ) { + new_assert_states |= (sens->assert_states | (cmd[6 ] <<8 )); + } +break ; + +case 3 :/* mask off */ +if (cmd_len >5 ) { + new_assert_states = (sens->assert_states & cmd[5 ]); + change_assert = true; + } +if (cmd_len >6 ) { + new_assert_states |= (sens->assert_states & (cmd[6 ] <<8 )); + } +break ; + } + +if (change_assert && (new_assert_states == sens->assert_states)) { + change_assert = false; + } + +if (cmd_len >9 ) { + evd1 = cmd[9 ]; + } +if (cmd_len >10 ) { + evd2 = cmd[10 ]; + } +if (cmd_len >11 ) { + evd3 = cmd[11 ]; + } + +/* [7:6] Event Data Bytes operation */ +switch ((cmd[3 ] >>6 ) &0x3 ) { +case 0 :/* +* Don’t use Event Data bytes from this command. BMC will +* generate it's own Event Data bytes based on its sensor +* implementation. +*/ + evd1 = evd2 = evd3 =0x0 ; + do_gen_event =SENSOR_GEN_EVENT_BMC ; +break ; +case 1 :/* +* Write given values to event data bytes including bits +* [3:0] Event Data 1. +*/ + do_gen_event =SENSOR_GEN_EVENT_DATA ; +break ; +case 2 :/* +* Write given values to event data bytes excluding bits +* [3:0] Event Data 1. +*/ + evd1 &=0xf0 ; + do_gen_event =SENSOR_GEN_EVENT_DATA ; +break ; +case 3 : +rsp_buffer_set_error (rsp,IPMI_CC_INVALID_DATA_FIELD ); +return ; + } + +/* +* Event Data Bytes operation and parameter are inconsistent. The +* Specs are not clear on that topic but generating an error seems +* correct. +*/ +if (do_gen_event ==SENSOR_GEN_EVENT_DATA && cmd_len <10 ) { +rsp_buffer_set_error (rsp,IPMI_CC_INVALID_DATA_FIELD ); +return ; + } + +/* commit values */ +if (change_reading) { + sens->reading = new_reading; + } + +if (change_assert) { + sens->assert_states = new_assert_states; + } + +if (change_deassert) { + sens->deassert_states = new_deassert_states; + } + +/* TODO: handle threshold sensor */ +if (!IPMI_SENSOR_IS_DISCRETE (sens)) { +return ; + } + +switch (do_gen_event) { +case SENSOR_GEN_EVENT_DATA : { +unsigned int bit = evd1 &0xf ; +uint16_t mask = (1 << bit); + +if (sens->assert_states & mask & sens->assert_enable) { +gen_event (ibs, cmd[2 ],0 , evd1, evd2, evd3); + } + +if (sens->deassert_states & mask & sens->deassert_enable) { +gen_event (ibs, cmd[2 ],1 , evd1, evd2, evd3); + } +break ; + } +case SENSOR_GEN_EVENT_BMC : +/* +* TODO: generate event and event data bytes depending on the +* sensor +*/ +break ; +case SENSOR_GEN_EVENT_NONE : +break ; + } +}static const IPMICmdHandler chassis_cmds[] = { [IPMI_CMD_GET_CHASSIS_CAPABILITIES ] = { chassis_capabilities },
@@ -1768,6 +1990,7 @@ static const IPMICmdHandler sensor_event_cmds[] = { [IPMI_CMD_GET_SENSOR_READING] = { get_sensor_reading, 3 }, [IPMI_CMD_SET_SENSOR_TYPE] = { set_sensor_type, 5 }, [IPMI_CMD_GET_SENSOR_TYPE] = { get_sensor_type, 3 }, + [IPMI_CMD_SET_SENSOR_READING] = { set_sensor_reading, 5 }, };static const IPMINetfn sensor_event_netfn = { .cmd_nums =ARRAY_SIZE (sensor_event_cmds),
Signature · 1 line
2.17.1
PATCH 4/5 hw/i2c/Kconfig: Add an entry for the SMBus
In reply to [email protected]From: Philippe Mathieu-Daudé <[email protected]>
The System Management Bus is more or less a derivative of the I2C bus, thus the Kconfig entry depends of I2C.
Not all boards providing an I2C bus support SMBus.
Use two different Kconfig entries to be able to select I2C without selecting SMBus.
Message-Id: <[email protected]>
--- hw/i2c/Kconfig | 8 ++++++-- hw/i2c/Makefile.objs | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-)
hw/i2c/Kconfig +6 -2
@@ -1,9 +1,13 @@ config I2C bool +config SMBUS + bool + select I2C + config SMBUS_EEPROM bool - depends on I2C + select SMBUS config VERSATILE_I2C bool
@@ -11,7 +15,7 @@ config VERSATILE_I2C config ACPI_SMBUS bool - select I2C + select SMBUS config BITBANG_I2C bool
hw/i2c/Makefile.objs +2 -1
@@ -1,4 +1,5 @@ -common-obj-$(CONFIG_I2C) += core.o smbus_slave.o smbus_master.o +common-obj-$(CONFIG_I2C) += core.o +common-obj-$(CONFIG_SMBUS) += smbus_slave.o smbus_master.o common-obj-$(CONFIG_SMBUS_EEPROM) += smbus_eeprom.o common-obj-$(CONFIG_VERSATILE_I2C) += versatile_i2c.o common-obj-$(CONFIG_ACPI_X86_ICH) += smbus_ich9.o
Signature · 1 line
2.17.1
PATCH 5/5 i386:acpi: Remove _HID from the SMBus ACPI entry
In reply to [email protected]From: Corey Minyard <[email protected]>
Per the ACPI spec (version 6.1, section 6.1.5 _HID) it is not required on enumerated buses (like PCI in this case), _ADR is required (and is already there). And the _HID value is wrong. Linux appears to ignore the _HID entry, but Windows 10 detects it as 'Unknown Device' and there is no driver available. See https://bugs.launchpad.net/qemu/+bug/1856724
--- hw/i386/acpi-build.c | 1 - tests/data/acpi/q35/DSDT | Bin 7879 -> 7869 bytes tests/data/acpi/q35/DSDT.bridge | Bin 7896 -> 7886 bytes tests/data/acpi/q35/DSDT.cphp | Bin 8342 -> 8332 bytes tests/data/acpi/q35/DSDT.dimmpxm | Bin 9532 -> 9522 bytes tests/data/acpi/q35/DSDT.ipmibt | Bin 7954 -> 7944 bytes tests/data/acpi/q35/DSDT.memhp | Bin 9238 -> 9228 bytes tests/data/acpi/q35/DSDT.mmio64 | Bin 9009 -> 8999 bytes tests/data/acpi/q35/DSDT.numamem | Bin 7885 -> 7875 bytes 9 files changed, 1 deletion(-)
hw/i386/acpi-build.c +0 -1
@@ -1815,7 +1815,6 @@ static void build_smb0(Aml *table, I2CBus *smbus, int devnr, int func)Aml *scope =aml_scope ("_SB.PCI0" );Aml *dev =aml_device ("SMB0" ); -aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("APP0005" )));aml_append (dev,aml_name_decl ("_ADR" ,aml_int (devnr <<16 | func)));build_acpi_ipmi_devices (dev,BUS (smbus),"\\_SB.PCI0.SMB0" );aml_append (scope, dev);
tests/data/acpi/q35/DSDT binary +0 -0
tests/data/acpi/q35/DSDT.bridge binary +0 -0
tests/data/acpi/q35/DSDT.cphp binary +0 -0
tests/data/acpi/q35/DSDT.dimmpxm binary +0 -0
tests/data/acpi/q35/DSDT.ipmibt binary +0 -0
tests/data/acpi/q35/DSDT.memhp binary +0 -0
tests/data/acpi/q35/DSDT.mmio64 binary +0 -0
tests/data/acpi/q35/DSDT.numamem binary +0 -0
Signature · 1 line
2.17.1
Re: [PATCH 5/5] i386:acpi: Remove _HID from the SMBus ACPI entry
Quoted 8 lines · On Mon, Jan 20, 2020 at 11:07:25AM -0600, [email protected] wrote:
From: Corey Minyard <[email protected]>
Per the ACPI spec (version 6.1, section 6.1.5
_HID) it is not required on enumerated buses (like PCI in this case),_ADRis required (and is already there). And the_HIDvalue is wrong. Linux appears to ignore the_HIDentry, but Windows 10 detects it as 'Unknown Device' and there is no driver available. See https://bugs.launchpad.net/qemu/+bug/1856724
Quoted 4 lines
Signed-off-by Corey Minyard <[email protected]>Cc Michael S. Tsirkin <[email protected]>Cc Igor Mammedov <[email protected]>Reviewed-by Igor Mammedov <[email protected]>
Applied this one. In the future pls follow the process in tests/qtest/bios-tables-test.c.
Quoted 106 lines
--- hw/i386/acpi-build.c | 1 - tests/data/acpi/q35/DSDT | Bin 7879 -> 7869 bytes tests/data/acpi/q35/DSDT.bridge | Bin 7896 -> 7886 bytes tests/data/acpi/q35/DSDT.cphp | Bin 8342 -> 8332 bytes tests/data/acpi/q35/DSDT.dimmpxm | Bin 9532 -> 9522 bytes tests/data/acpi/q35/DSDT.ipmibt | Bin 7954 -> 7944 bytes tests/data/acpi/q35/DSDT.memhp | Bin 9238 -> 9228 bytes tests/data/acpi/q35/DSDT.mmio64 | Bin 9009 -> 8999 bytes tests/data/acpi/q35/DSDT.numamem | Bin 7885 -> 7875 bytes 9 files changed, 1 deletion(-)hw/i386/acpi-build.c +0
-1@@ -1815,7 +1815,6 @@ static void build_smb0(Aml *table, I2CBus *smbus, int devnr, int func)Aml *scope =aml_scope ("_SB.PCI0" );Aml *dev =aml_device ("SMB0" ); -aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("APP0005" )));aml_append (dev,aml_name_decl ("_ADR" ,aml_int (devnr <<16 | func)));build_acpi_ipmi_devices (dev,BUS (smbus),"\\_SB.PCI0.SMB0" );aml_append (scope, dev);tests/data/acpi/q35/DSDT binary +0
-0tests/data/acpi/q35/DSDT.bridge binary +0
-0tests/data/acpi/q35/DSDT.cphp binary +0
-0tests/data/acpi/q35/DSDT.dimmpxm binary +0
-0tests/data/acpi/q35/DSDT.ipmibt binary +0
-0tests/data/acpi/q35/DSDT.memhp binary +0
-0tests/data/acpi/q35/DSDT.mmio64 binary +0
-0tests/data/acpi/q35/DSDT.numamem binary +0
-0Signature · 2 lines
-- 2.17.1