diff mbox

[v2,6/9] ipmi: add get and set SENSOR_TYPE commands

Message ID 1453396734-9363-7-git-send-email-clg@fr.ibm.com
State New
Headers show

Commit Message

Cédric Le Goater Jan. 21, 2016, 5:18 p.m. UTC
Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
Acked-by: Corey Minyard <cminyard@mvista.com>
---
 hw/ipmi/ipmi_bmc_sim.c | 45 ++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 44 insertions(+), 1 deletion(-)

Comments

Greg Kurz Jan. 22, 2016, 11:07 a.m. UTC | #1
On Thu, 21 Jan 2016 18:18:51 +0100
Cédric Le Goater <clg@fr.ibm.com> wrote:

> Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
> Acked-by: Corey Minyard <cminyard@mvista.com>
> ---

Reviewed-by: Greg Kurz <gkurz@linux.vnet.ibm.com>

Just two nits below.

>  hw/ipmi/ipmi_bmc_sim.c | 45 ++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 44 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/ipmi/ipmi_bmc_sim.c b/hw/ipmi/ipmi_bmc_sim.c
> index 803c7e5130c0..7c0f2a1d9799 100644
> --- a/hw/ipmi/ipmi_bmc_sim.c
> +++ b/hw/ipmi/ipmi_bmc_sim.c
> @@ -42,6 +42,8 @@
>  #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 */
> 
> @@ -1527,6 +1529,45 @@ static void get_sensor_reading(IPMIBmcSim *ibs,
>      }
>  }
> 
> +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) ||

This has been a recurring remark on many patches lately, and all the people
don't necessarily agree but the extra parenthesis are not needed here...

> +            !IPMI_SENSOR_GET_PRESENT(ibs->sensors + cmd[2])) {
> +        rsp[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT;
> +        return;
> +    }
> +    sens = ibs->sensors + cmd[2];
> +    sens->sensor_type = cmd[3];
> +    sens->evt_reading_type_code = cmd[4] & 0x7f;
> +}
> +
> +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) ||

and here.

> +            !IPMI_SENSOR_GET_PRESENT(ibs->sensors + cmd[2])) {
> +        rsp[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT;
> +        return;
> +    }
> +    sens = ibs->sensors + cmd[2];
> +    IPMI_ADD_RSP_DATA(sens->sensor_type);
> +    IPMI_ADD_RSP_DATA(sens->evt_reading_type_code);
> +}
> +
> +
>  static const IPMICmdHandler chassis_cmds[] = {
>      [IPMI_CMD_GET_CHASSIS_CAPABILITIES] = chassis_capabilities,
>      [IPMI_CMD_GET_CHASSIS_STATUS] = chassis_status,
> @@ -1542,7 +1583,9 @@ static const IPMICmdHandler sensor_event_cmds[] = {
>      [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 = ARRAY_SIZE(sensor_event_cmds),
Cédric Le Goater Jan. 22, 2016, 11:13 a.m. UTC | #2
On 01/22/2016 12:07 PM, Greg Kurz wrote:
> On Thu, 21 Jan 2016 18:18:51 +0100
> Cédric Le Goater <clg@fr.ibm.com> wrote:
> 
>> Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
>> Acked-by: Corey Minyard <cminyard@mvista.com>
>> ---
> 
> Reviewed-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
> 
> Just two nits below.
> 
>>  hw/ipmi/ipmi_bmc_sim.c | 45 ++++++++++++++++++++++++++++++++++++++++++++-
>>  1 file changed, 44 insertions(+), 1 deletion(-)
>>
>> diff --git a/hw/ipmi/ipmi_bmc_sim.c b/hw/ipmi/ipmi_bmc_sim.c
>> index 803c7e5130c0..7c0f2a1d9799 100644
>> --- a/hw/ipmi/ipmi_bmc_sim.c
>> +++ b/hw/ipmi/ipmi_bmc_sim.c
>> @@ -42,6 +42,8 @@
>>  #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 */
>>
>> @@ -1527,6 +1529,45 @@ static void get_sensor_reading(IPMIBmcSim *ibs,
>>      }
>>  }
>>
>> +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) ||
> 
> This has been a recurring remark on many patches lately, and all the people
> don't necessarily agree but the extra parenthesis are not needed here...

Damn. Am I contaminated ? :)

C.

>> +            !IPMI_SENSOR_GET_PRESENT(ibs->sensors + cmd[2])) {
>> +        rsp[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT;
>> +        return;
>> +    }
>> +    sens = ibs->sensors + cmd[2];
>> +    sens->sensor_type = cmd[3];
>> +    sens->evt_reading_type_code = cmd[4] & 0x7f;
>> +}
>> +
>> +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) ||
> 
> and here.
> 
>> +            !IPMI_SENSOR_GET_PRESENT(ibs->sensors + cmd[2])) {
>> +        rsp[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT;
>> +        return;
>> +    }
>> +    sens = ibs->sensors + cmd[2];
>> +    IPMI_ADD_RSP_DATA(sens->sensor_type);
>> +    IPMI_ADD_RSP_DATA(sens->evt_reading_type_code);
>> +}
>> +
>> +
>>  static const IPMICmdHandler chassis_cmds[] = {
>>      [IPMI_CMD_GET_CHASSIS_CAPABILITIES] = chassis_capabilities,
>>      [IPMI_CMD_GET_CHASSIS_STATUS] = chassis_status,
>> @@ -1542,7 +1583,9 @@ static const IPMICmdHandler sensor_event_cmds[] = {
>>      [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 = ARRAY_SIZE(sensor_event_cmds),
>
diff mbox

Patch

diff --git a/hw/ipmi/ipmi_bmc_sim.c b/hw/ipmi/ipmi_bmc_sim.c
index 803c7e5130c0..7c0f2a1d9799 100644
--- a/hw/ipmi/ipmi_bmc_sim.c
+++ b/hw/ipmi/ipmi_bmc_sim.c
@@ -42,6 +42,8 @@ 
 #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 */
 
@@ -1527,6 +1529,45 @@  static void get_sensor_reading(IPMIBmcSim *ibs,
     }
 }
 
+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;
+        return;
+    }
+    sens = ibs->sensors + cmd[2];
+    sens->sensor_type = cmd[3];
+    sens->evt_reading_type_code = cmd[4] & 0x7f;
+}
+
+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;
+        return;
+    }
+    sens = ibs->sensors + cmd[2];
+    IPMI_ADD_RSP_DATA(sens->sensor_type);
+    IPMI_ADD_RSP_DATA(sens->evt_reading_type_code);
+}
+
+
 static const IPMICmdHandler chassis_cmds[] = {
     [IPMI_CMD_GET_CHASSIS_CAPABILITIES] = chassis_capabilities,
     [IPMI_CMD_GET_CHASSIS_STATUS] = chassis_status,
@@ -1542,7 +1583,9 @@  static const IPMICmdHandler sensor_event_cmds[] = {
     [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 = ARRAY_SIZE(sensor_event_cmds),