> Date: Mon, 21 Dec 2015 22:47:19 +0900
> From: Masao Uebayashi <uebay...@tombiinc.com>
> 
> ipmi(4) has checked thresholds of some sensing values and reported false
> alarms.  This patch reverts those checks.
> 
> This also changes ipmi(4) to handle disabled sensors while allowing them to
> supply readings if they want.
> 
> >From Jonathan Matthew.
> 
> OK?

Sorry, but I don't understand what the problem is here.

Is the code wrong?  Or did you encounter a machine that has bogus
thresholds?

> diff --git a/sys/dev/ipmi.c b/sys/dev/ipmi.c
> index d88b7c1..1bac603 100644
> --- a/sys/dev/ipmi.c
> +++ b/sys/dev/ipmi.c
> @@ -108,6 +108,7 @@ int       ipmi_enabled = 0;
>  #define IPMI_ENTITY_PWRSUPPLY                0x0A
>  
>  #define IPMI_INVALID_SENSOR          (1L << 5)
> +#define IPMI_DISABLED_SENSOR         (1L << 6)
>  
>  #define IPMI_SDR_TYPEFULL            1
>  #define IPMI_SDR_TYPECOMPACT         2
> @@ -175,7 +176,6 @@ void      ipmi_unmap_regs(struct ipmi_softc *);
>  
>  void *scan_sig(long, long, int, int, const void *);
>  
> -int  ipmi_test_threshold(u_int8_t, u_int8_t, u_int8_t, u_int8_t, int);
>  int  ipmi_sensor_status(struct ipmi_softc *, struct ipmi_sensor *,
>      u_int8_t *);
>  
> @@ -1222,26 +1222,11 @@ ipmi_convert(u_int8_t v, struct sdrtype1 *s1, long 
> adj)
>  }
>  
>  int
> -ipmi_test_threshold(u_int8_t v, u_int8_t valid, u_int8_t hi, u_int8_t lo,
> -    int sign)
> -{
> -     dbg_printf(10, "thresh: %.2x %.2x %.2x %d %d\n", v, lo, hi,valid, sign);
> -     if (sign)
> -             return ((valid & 1 && lo != 0x00 && (int8_t)v <= (int8_t)lo) ||
> -                 (valid & 8 && hi != 0xFF && (int8_t)v >= (int8_t)hi));
> -
> -     return ((valid & 1 && lo != 0x00 && v <= lo) ||
> -         (valid & 8 && hi != 0xFF && v >= hi));
> -}
> -
> -int
>  ipmi_sensor_status(struct ipmi_softc *sc, struct ipmi_sensor *psensor,
>      u_int8_t *reading)
>  {
> -     u_int8_t        data[32];
>       struct sdrtype1 *s1 = (struct sdrtype1 *)psensor->i_sdr;
> -     int             rxlen, etype;
> -     int             sign = s1->units1 >> 7 & 1;
> +     int             etype;
>  
>       /* Get reading of sensor */
>       switch (psensor->i_sensor.type) {
> @@ -1269,28 +1254,12 @@ ipmi_sensor_status(struct ipmi_softc *sc, struct 
> ipmi_sensor *psensor,
>       case IPMI_SENSOR_TYPE_TEMP:
>       case IPMI_SENSOR_TYPE_VOLT:
>       case IPMI_SENSOR_TYPE_FAN:
> -             data[0] = psensor->i_num;
> -             if (ipmi_sendcmd(sc, s1->owner_id, s1->owner_lun,
> -                 SE_NETFN, SE_GET_SENSOR_THRESHOLD, 1, data) ||
> -                 ipmi_recvcmd(sc, sizeof(data), &rxlen, data))
> -                     return (SENSOR_S_UNKNOWN);
> -
> -             dbg_printf(25, "recvdata: %.2x %.2x %.2x %.2x %.2x %.2x %.2x\n",
> -                 data[0], data[1], data[2], data[3], data[4], data[5],
> -                 data[6]);
> -
> -             if (ipmi_test_threshold(*reading, data[0] >> 2 ,
> -                 data[6], data[3], sign))
> +             if (reading[2] & ((1 << 5) | (1 << 2)))
>                       return (SENSOR_S_CRIT);
> -
> -             if (ipmi_test_threshold(*reading, data[0] >> 1,
> -                 data[5], data[2], sign))
> +             else if (reading[2] & ((1 << 4) | (1 << 1)))
>                       return (SENSOR_S_CRIT);
> -
> -             if (ipmi_test_threshold(*reading, data[0] ,
> -                 data[4], data[1], sign))
> +             else if (reading[2] & ((1 << 3) | (1 << 0)))
>                       return (SENSOR_S_WARN);
> -
>               break;
>  
>       case IPMI_SENSOR_TYPE_INTRUSION:
> @@ -1342,10 +1311,9 @@ read_sensor(struct ipmi_softc *sc, struct ipmi_sensor 
> *psensor)
>       dbg_printf(10, "values=%.2x %.2x %.2x %.2x %s\n",
>           data[0],data[1],data[2],data[3], psensor->i_sensor.desc);
>       psensor->i_sensor.flags &= ~SENSOR_FINVALID;
> -     if (data[1] & IPMI_INVALID_SENSOR) {
> -             /* Check if sensor is valid */
> +     if ((data[1] & IPMI_INVALID_SENSOR) ||
> +         ((data[1] & IPMI_DISABLED_SENSOR) == 0 && data[0] == 0))
>               psensor->i_sensor.flags |= SENSOR_FINVALID;
> -     }
>       psensor->i_sensor.status = ipmi_sensor_status(sc, psensor, data);
>       rv = 0;
>  done:
> 
> 

Reply via email to