From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36849) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aHdZ0-0004xX-Fs for qemu-devel@nongnu.org; Fri, 08 Jan 2016 15:23:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aHdYz-0001m7-HT for qemu-devel@nongnu.org; Fri, 08 Jan 2016 15:23:10 -0500 Received: from mail-ob0-x234.google.com ([2607:f8b0:4003:c01::234]:32932) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aHdYz-0001m3-Bu for qemu-devel@nongnu.org; Fri, 08 Jan 2016 15:23:09 -0500 Received: by mail-ob0-x234.google.com with SMTP id bx1so336231159obb.0 for ; Fri, 08 Jan 2016 12:23:09 -0800 (PST) References: <1452015002-28493-3-git-send-email-clg@fr.ibm.com> From: Corey Minyard Message-ID: <56901AAB.3000909@mvista.com> Date: Fri, 8 Jan 2016 14:23:07 -0600 MIME-Version: 1.0 In-Reply-To: <1452015002-28493-3-git-send-email-clg@fr.ibm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH 2/8] ipmi: add get and set SENSOR_TYPE commands List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?Q?C=c3=a9dric_Le_Goater?= Cc: qemu-devel@nongnu.org, "Michael S. Tsirkin" Acked-by: Corey Minyard I agree with Greg's comments, too. -corey On 01/05/2016 11:29 AM, Cédric Le Goater wrote: > Signed-off-by: Cédric Le Goater > --- > hw/ipmi/ipmi_bmc_sim.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++-- > 1 file changed, 49 insertions(+), 2 deletions(-) > > diff --git a/hw/ipmi/ipmi_bmc_sim.c b/hw/ipmi/ipmi_bmc_sim.c > index 559e1398d669..061db8437479 100644 > --- a/hw/ipmi/ipmi_bmc_sim.c > +++ b/hw/ipmi/ipmi_bmc_sim.c > @@ -37,13 +37,15 @@ > #define IPMI_CMD_CHASSIS_CONTROL 0x02 > > #define IPMI_NETFN_SENSOR_EVENT 0x04 > -#define IPMI_NETFN_SENSOR_EVENT_MAXCMD 0x2e > +#define IPMI_NETFN_SENSOR_EVENT_MAXCMD 0x30 > > #define IPMI_CMD_SET_SENSOR_EVT_ENABLE 0x28 > #define IPMI_CMD_GET_SENSOR_EVT_ENABLE 0x29 > #define IPMI_CMD_REARM_SENSOR_EVTS 0x2a > #define IPMI_CMD_GET_SENSOR_EVT_STATUS 0x2b > #define IPMI_CMD_GET_SENSOR_READING 0x2d > +#define IPMI_CMD_SET_SENSOR_TYPE 0x2e > +#define IPMI_CMD_GET_SENSOR_TYPE 0x2f > > /* #define IPMI_NETFN_APP 0x06 In ipmi.h */ > #define IPMI_NETFN_APP_MAXCMD 0x36 > @@ -1576,6 +1578,49 @@ static void get_sensor_reading(IPMIBmcSim *ibs, > return; > } > > +static void set_sensor_type(IPMIBmcSim *ibs, > + uint8_t *cmd, unsigned int cmd_len, > + uint8_t *rsp, unsigned int *rsp_len, > + unsigned int max_rsp_len) > +{ > + IPMISensor *sens; > + > + > + 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]; > + sens->sensor_type = cmd[3]; > + sens->evt_reading_type_code = cmd[4] & 0x7f; > + > + out: > + return; > +} > + > +static void get_sensor_type(IPMIBmcSim *ibs, > + uint8_t *cmd, unsigned int cmd_len, > + uint8_t *rsp, unsigned int *rsp_len, > + unsigned int max_rsp_len) > +{ > + IPMISensor *sens; > + > + > + IPMI_CHECK_CMD_LEN(3); > + 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]; > + IPMI_ADD_RSP_DATA(sens->sensor_type); > + IPMI_ADD_RSP_DATA(sens->evt_reading_type_code); > + 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, > @@ -1592,7 +1637,9 @@ sensor_event_cmds[IPMI_NETFN_SENSOR_EVENT_MAXCMD] = { > [IPMI_CMD_GET_SENSOR_EVT_ENABLE] = get_sensor_evt_enable, > [IPMI_CMD_REARM_SENSOR_EVTS] = rearm_sensor_evts, > [IPMI_CMD_GET_SENSOR_EVT_STATUS] = get_sensor_evt_status, > - [IPMI_CMD_GET_SENSOR_READING] = get_sensor_reading > + [IPMI_CMD_GET_SENSOR_READING] = get_sensor_reading, > + [IPMI_CMD_SET_SENSOR_TYPE] = set_sensor_type, > + [IPMI_CMD_GET_SENSOR_TYPE] = get_sensor_type, > }; > static const IPMINetfn sensor_event_netfn = { > .cmd_nums = IPMI_NETFN_SENSOR_EVENT_MAXCMD,