From: Corey Minyard <cminyard@mvista.com>
To: "Cédric Le Goater" <clg@fr.ibm.com>
Cc: qemu-devel@nongnu.org, "Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 6/8] ipmi: add SET_SENSOR_READING command (tentative try)
Date: Fri, 8 Jan 2016 13:50:08 -0600 [thread overview]
Message-ID: <569012F0.6080400@mvista.com> (raw)
In-Reply-To: <1452015002-28493-7-git-send-email-clg@fr.ibm.com>
Acked-by: Corey Minyard <cminyard@mvista.com>
This looks good. Though this file is getting uncomfortably large, I may
have to look at splitting it up.
-corey
On 01/05/2016 11:30 AM, Cédric Le Goater wrote:
> SET_SENSOR_READING is a complex IPMI command (IPMI spec : "35.17 Set
> Sensor Reading And Event Status Command"). Here is a very minimum
> framework fitting the Open PowerNV platform needs. This command is
> used on this platform to set the "System Firmware Progress" sensor and
> the "Boot Count" sensor.
>
> Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
> ---
> hw/ipmi/ipmi_bmc_sim.c | 141 ++++++++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 140 insertions(+), 1 deletion(-)
>
> diff --git a/hw/ipmi/ipmi_bmc_sim.c b/hw/ipmi/ipmi_bmc_sim.c
> index c3a06d0ac7e4..4f7c74da4b6b 100644
> --- a/hw/ipmi/ipmi_bmc_sim.c
> +++ b/hw/ipmi/ipmi_bmc_sim.c
> @@ -39,7 +39,7 @@
> #define IPMI_CMD_GET_SYS_RESTART_CAUSE 0x09
>
> #define IPMI_NETFN_SENSOR_EVENT 0x04
> -#define IPMI_NETFN_SENSOR_EVENT_MAXCMD 0x30
> +#define IPMI_NETFN_SENSOR_EVENT_MAXCMD 0x31
>
> #define IPMI_CMD_SET_SENSOR_EVT_ENABLE 0x28
> #define IPMI_CMD_GET_SENSOR_EVT_ENABLE 0x29
> @@ -48,6 +48,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 */
> #define IPMI_NETFN_APP_MAXCMD 0x36
> @@ -1794,6 +1795,143 @@ static void get_sensor_type(IPMIBmcSim *ibs,
> return;
> }
>
> +static void set_sensor_reading(IPMIBmcSim *ibs,
> + uint8_t *cmd, unsigned int cmd_len,
> + uint8_t *rsp, unsigned int *rsp_len,
> + unsigned int max_rsp_len)
> +{
> + IPMISensor *sens;
> + uint8_t evd1;
> + uint8_t evd2;
> + uint8_t evd3;
> +
> + IPMI_CHECK_CMD_LEN(5);
> + if ((cmd[2] > MAX_SENSORS) ||
> + !IPMI_SENSOR_GET_PRESENT(ibs->sensors + cmd[2])) {
> + rsp[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT;
> + goto out;
> + }
> +
> + sens = ibs->sensors + cmd[2];
> +
> + /* Sensor Reading operation */
> + switch ((cmd[3]) & 0x3) {
> + case 0: /* Do not change */
> + break;
> + case 1: /* write given value to sensor reading byte */
> + sens->reading = cmd[4];
> + break;
> + case 2:
> + case 3:
> + rsp[2] = IPMI_CC_INVALID_DATA_FIELD;
> + goto out;
> + }
> +
> + /* Deassertion bits operation */
> + switch ((cmd[3] >> 2) & 0x3) {
> + case 0: /* Do not change */
> + break;
> + case 1: /* write given value */
> + if (cmd_len > 7) {
> + sens->deassert_states = cmd[7];
> + }
> + if (cmd_len > 8) {
> + sens->deassert_states = cmd[8] << 8;
> + }
> +
> + case 2: /* mask on */
> + if (cmd_len > 7) {
> + sens->deassert_states |= cmd[7];
> + }
> + if (cmd_len > 8) {
> + sens->deassert_states |= cmd[8] << 8;
> + }
> + break;
> + case 3: /* mask off */
> + if (cmd_len > 7) {
> + sens->deassert_states &= cmd[7];
> + }
> + if (cmd_len > 8) {
> + sens->deassert_states &= (cmd[8] << 8);
> + }
> + break;
> + }
> +
> + /* Assertion bits operation */
> + switch ((cmd[3] >> 4) & 0x3) {
> + case 0: /* Do not change */
> + break;
> + case 1: /* write given value */
> + if (cmd_len > 5) {
> + sens->assert_states = cmd[5];
> + }
> + if (cmd_len > 6) {
> + sens->assert_states = cmd[6] << 8;
> + }
> +
> + case 2: /* mask on */
> + if (cmd_len > 5) {
> + sens->assert_states |= cmd[5];
> + }
> + if (cmd_len > 6) {
> + sens->assert_states |= cmd[6] << 8;
> + }
> + break;
> + case 3: /* mask off */
> + if (cmd_len > 5) {
> + sens->assert_states &= cmd[5];
> + }
> + if (cmd_len > 6) {
> + sens->assert_states &= (cmd[6] << 8);
> + }
> + break;
> + }
> +
> + evd1 = evd2 = evd3 = 0x0;
> + if (cmd_len > 9) {
> + evd1 = cmd[9];
> + }
> + if (cmd_len > 10) {
> + evd2 = cmd[10];
> + }
> + if (cmd_len > 11) {
> + evd3 = cmd[11];
> + }
> +
> + /* Event Data Bytes operation */
> + switch ((cmd[3] >> 6) & 0x3) {
> + case 0: /* Do not use the event data in message */
> + evd1 = evd2 = evd3 = 0x0;
> + break;
> + case 1: /* Write given values to event data bytes excluding bits
> + * [3:0] Event Data 1. */
> + evd1 &= 0xf0;
> + break;
> + case 2: /* Write given values to event data bytes including bits
> + * [3:0] Event Data 1. */
> + break;
> + case 3:
> + rsp[2] = IPMI_CC_INVALID_DATA_FIELD;
> + goto out;
> + }
> +
> + if (IPMI_SENSOR_IS_DISCRETE(sens)) {
> + 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);
> + }
> + }
> +
> +out:
> + return;
> +}
> +
> static const IPMICmdHandler chassis_cmds[IPMI_NETFN_CHASSIS_MAXCMD] = {
> [IPMI_CMD_GET_CHASSIS_CAPABILITIES] = chassis_capabilities,
> [IPMI_CMD_GET_CHASSIS_STATUS] = chassis_status,
> @@ -1814,6 +1952,7 @@ sensor_event_cmds[IPMI_NETFN_SENSOR_EVENT_MAXCMD] = {
> [IPMI_CMD_GET_SENSOR_READING] = get_sensor_reading,
> [IPMI_CMD_SET_SENSOR_TYPE] = set_sensor_type,
> [IPMI_CMD_GET_SENSOR_TYPE] = get_sensor_type,
> + [IPMI_CMD_SET_SENSOR_READING] = set_sensor_reading
> };
> static const IPMINetfn sensor_event_netfn = {
> .cmd_nums = IPMI_NETFN_SENSOR_EVENT_MAXCMD,
prev parent reply other threads:[~2016-01-08 19:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-05 17:30 [Qemu-devel] [PATCH 6/8] ipmi: add SET_SENSOR_READING command (tentative try) Cédric Le Goater
2016-01-08 19:50 ` Corey 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=569012F0.6080400@mvista.com \
--to=cminyard@mvista.com \
--cc=clg@fr.ibm.com \
--cc=mst@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.