mirror of
https://github.com/ipmitool/ipmitool.git
synced 2025-05-11 02:57:22 +00:00
Correct Threshold/Discrete Sensor Display - Patch Tracker ID - 3508759
This commit is contained in:
parent
8de0428bdc
commit
5f11bb25b0
@ -322,7 +322,7 @@ struct sdr_record_mask {
|
|||||||
#ifdef HAVE_PRAGMA_PACK
|
#ifdef HAVE_PRAGMA_PACK
|
||||||
#pragma pack(1)
|
#pragma pack(1)
|
||||||
#endif
|
#endif
|
||||||
struct sdr_record_compact_sensor {
|
struct sdr_record_common_sensor {
|
||||||
struct {
|
struct {
|
||||||
uint8_t owner_id;
|
uint8_t owner_id;
|
||||||
#if WORDS_BIGENDIAN
|
#if WORDS_BIGENDIAN
|
||||||
@ -376,7 +376,7 @@ struct sdr_record_compact_sensor {
|
|||||||
uint8_t ignore:1;
|
uint8_t ignore:1;
|
||||||
#endif
|
#endif
|
||||||
} ATTRIBUTE_PACKING capabilities;
|
} ATTRIBUTE_PACKING capabilities;
|
||||||
uint8_t type; /* sensor type */
|
uint8_t type;
|
||||||
} ATTRIBUTE_PACKING sensor;
|
} ATTRIBUTE_PACKING sensor;
|
||||||
|
|
||||||
uint8_t event_type; /* event/reading type code */
|
uint8_t event_type; /* event/reading type code */
|
||||||
@ -400,7 +400,21 @@ struct sdr_record_compact_sensor {
|
|||||||
uint8_t modifier;
|
uint8_t modifier;
|
||||||
} ATTRIBUTE_PACKING type;
|
} ATTRIBUTE_PACKING type;
|
||||||
} ATTRIBUTE_PACKING unit;
|
} ATTRIBUTE_PACKING unit;
|
||||||
|
} ATTRIBUTE_PACKING;
|
||||||
|
|
||||||
|
/* SDR Record Common Sensor header macros */
|
||||||
|
#define IS_THRESHOLD_SENSOR(s) ((s)->event_type == 1)
|
||||||
|
#define UNITS_ARE_DISCRETE(s) ((s)->unit.analog == 3)
|
||||||
|
|
||||||
|
#ifdef HAVE_PRAGMA_PACK
|
||||||
|
#pragma pack(0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_PRAGMA_PACK
|
||||||
|
#pragma pack(1)
|
||||||
|
#endif
|
||||||
|
struct sdr_record_compact_sensor {
|
||||||
|
struct sdr_record_common_sensor cmn;
|
||||||
struct {
|
struct {
|
||||||
#if WORDS_BIGENDIAN
|
#if WORDS_BIGENDIAN
|
||||||
uint8_t __reserved:2;
|
uint8_t __reserved:2;
|
||||||
@ -492,83 +506,7 @@ struct sdr_record_eventonly_sensor {
|
|||||||
#pragma pack(1)
|
#pragma pack(1)
|
||||||
#endif
|
#endif
|
||||||
struct sdr_record_full_sensor {
|
struct sdr_record_full_sensor {
|
||||||
struct {
|
struct sdr_record_common_sensor cmn;
|
||||||
uint8_t owner_id;
|
|
||||||
#if WORDS_BIGENDIAN
|
|
||||||
uint8_t channel:4; /* channel number */
|
|
||||||
uint8_t __reserved:2;
|
|
||||||
uint8_t lun:2; /* sensor owner lun */
|
|
||||||
#else
|
|
||||||
uint8_t lun:2; /* sensor owner lun */
|
|
||||||
uint8_t __reserved:2;
|
|
||||||
uint8_t channel:4; /* channel number */
|
|
||||||
#endif
|
|
||||||
uint8_t sensor_num; /* unique sensor number */
|
|
||||||
} ATTRIBUTE_PACKING keys;
|
|
||||||
|
|
||||||
struct entity_id entity;
|
|
||||||
|
|
||||||
struct {
|
|
||||||
struct {
|
|
||||||
#if WORDS_BIGENDIAN
|
|
||||||
uint8_t __reserved:1;
|
|
||||||
uint8_t scanning:1;
|
|
||||||
uint8_t events:1;
|
|
||||||
uint8_t thresholds:1;
|
|
||||||
uint8_t hysteresis:1;
|
|
||||||
uint8_t type:1;
|
|
||||||
uint8_t event_gen:1;
|
|
||||||
uint8_t sensor_scan:1;
|
|
||||||
#else
|
|
||||||
uint8_t sensor_scan:1;
|
|
||||||
uint8_t event_gen:1;
|
|
||||||
uint8_t type:1;
|
|
||||||
uint8_t hysteresis:1;
|
|
||||||
uint8_t thresholds:1;
|
|
||||||
uint8_t events:1;
|
|
||||||
uint8_t scanning:1;
|
|
||||||
uint8_t __reserved:1;
|
|
||||||
#endif
|
|
||||||
} ATTRIBUTE_PACKING init;
|
|
||||||
struct {
|
|
||||||
#if WORDS_BIGENDIAN
|
|
||||||
uint8_t ignore:1;
|
|
||||||
uint8_t rearm:1;
|
|
||||||
uint8_t hysteresis:2;
|
|
||||||
uint8_t threshold:2;
|
|
||||||
uint8_t event_msg:2;
|
|
||||||
#else
|
|
||||||
uint8_t event_msg:2;
|
|
||||||
uint8_t threshold:2;
|
|
||||||
uint8_t hysteresis:2;
|
|
||||||
uint8_t rearm:1;
|
|
||||||
uint8_t ignore:1;
|
|
||||||
#endif
|
|
||||||
} ATTRIBUTE_PACKING capabilities;
|
|
||||||
uint8_t type;
|
|
||||||
} ATTRIBUTE_PACKING sensor;
|
|
||||||
|
|
||||||
uint8_t event_type; /* event/reading type code */
|
|
||||||
|
|
||||||
struct sdr_record_mask mask;
|
|
||||||
|
|
||||||
struct {
|
|
||||||
#if WORDS_BIGENDIAN
|
|
||||||
uint8_t analog:2;
|
|
||||||
uint8_t rate:3;
|
|
||||||
uint8_t modifier:2;
|
|
||||||
uint8_t pct:1;
|
|
||||||
#else
|
|
||||||
uint8_t pct:1;
|
|
||||||
uint8_t modifier:2;
|
|
||||||
uint8_t rate:3;
|
|
||||||
uint8_t analog:2;
|
|
||||||
#endif
|
|
||||||
struct {
|
|
||||||
uint8_t base;
|
|
||||||
uint8_t modifier;
|
|
||||||
} ATTRIBUTE_PACKING type;
|
|
||||||
} ATTRIBUTE_PACKING unit;
|
|
||||||
|
|
||||||
#define SDR_SENSOR_L_LINEAR 0x00
|
#define SDR_SENSOR_L_LINEAR 0x00
|
||||||
#define SDR_SENSOR_L_LN 0x01
|
#define SDR_SENSOR_L_LN 0x01
|
||||||
@ -822,6 +760,7 @@ struct sdr_record_list {
|
|||||||
uint8_t *raw;
|
uint8_t *raw;
|
||||||
struct sdr_record_list *next;
|
struct sdr_record_list *next;
|
||||||
union {
|
union {
|
||||||
|
struct sdr_record_common_sensor *common;
|
||||||
struct sdr_record_full_sensor *full;
|
struct sdr_record_full_sensor *full;
|
||||||
struct sdr_record_compact_sensor *compact;
|
struct sdr_record_compact_sensor *compact;
|
||||||
struct sdr_record_eventonly_sensor *eventonly;
|
struct sdr_record_eventonly_sensor *eventonly;
|
||||||
@ -896,14 +835,22 @@ int ipmi_sdr_print_rawentry(struct ipmi_intf *intf, uint8_t type, uint8_t * raw,
|
|||||||
int len);
|
int len);
|
||||||
int ipmi_sdr_print_listentry(struct ipmi_intf *intf,
|
int ipmi_sdr_print_listentry(struct ipmi_intf *intf,
|
||||||
struct sdr_record_list *entry);
|
struct sdr_record_list *entry);
|
||||||
const char *ipmi_sdr_get_unit_string(uint8_t pct, uint8_t type,
|
void ipmi_sdr_print_sensor_hysteresis(struct sdr_record_common_sensor *sensor,
|
||||||
|
struct sdr_record_full_sensor *full,
|
||||||
|
uint8_t hysteresis_value,
|
||||||
|
const char *hdrstr);
|
||||||
|
const char *ipmi_sdr_get_unit_string(uint8_t pct, uint8_t type,
|
||||||
uint8_t base, uint8_t modifier);
|
uint8_t base, uint8_t modifier);
|
||||||
const char *ipmi_sdr_get_status(struct sdr_record_full_sensor *sensor,
|
const char *ipmi_sdr_get_thresh_status(struct ipmi_rs *rsp,
|
||||||
uint8_t stat);
|
int validread, const char *invalidstr);
|
||||||
|
const char *ipmi_sdr_get_status(int, const char *, uint8_t stat);
|
||||||
double sdr_convert_sensor_tolerance(struct sdr_record_full_sensor *sensor,
|
double sdr_convert_sensor_tolerance(struct sdr_record_full_sensor *sensor,
|
||||||
uint8_t val);
|
uint8_t val);
|
||||||
double sdr_convert_sensor_reading(struct sdr_record_full_sensor *sensor,
|
double sdr_convert_sensor_reading(struct sdr_record_full_sensor *sensor,
|
||||||
uint8_t val);
|
uint8_t val);
|
||||||
|
double sdr_convert_analog_reading(struct ipmi_intf *intf,
|
||||||
|
struct sdr_record_full_sensor *sensor, uint8_t read,
|
||||||
|
int *convert_success);
|
||||||
double sdr_convert_sensor_hysterisis(struct sdr_record_full_sensor *sensor,
|
double sdr_convert_sensor_hysterisis(struct sdr_record_full_sensor *sensor,
|
||||||
uint8_t val);
|
uint8_t val);
|
||||||
uint8_t sdr_convert_sensor_value_to_raw(struct sdr_record_full_sensor *sensor,
|
uint8_t sdr_convert_sensor_value_to_raw(struct sdr_record_full_sensor *sensor,
|
||||||
@ -925,10 +872,6 @@ const char *ipmi_sdr_get_sensor_type_desc(const uint8_t type);
|
|||||||
int ipmi_sdr_get_reservation(struct ipmi_intf *intf, int use_builtin,
|
int ipmi_sdr_get_reservation(struct ipmi_intf *intf, int use_builtin,
|
||||||
uint16_t * reserve_id);
|
uint16_t * reserve_id);
|
||||||
|
|
||||||
int ipmi_sdr_print_sensor_full(struct ipmi_intf *intf,
|
|
||||||
struct sdr_record_full_sensor *sensor);
|
|
||||||
int ipmi_sdr_print_sensor_compact(struct ipmi_intf *intf,
|
|
||||||
struct sdr_record_compact_sensor *sensor);
|
|
||||||
int ipmi_sdr_print_sensor_eventonly(struct ipmi_intf *intf,
|
int ipmi_sdr_print_sensor_eventonly(struct ipmi_intf *intf,
|
||||||
struct sdr_record_eventonly_sensor *sensor);
|
struct sdr_record_eventonly_sensor *sensor);
|
||||||
int ipmi_sdr_print_sensor_generic_locator(struct ipmi_intf *intf,
|
int ipmi_sdr_print_sensor_generic_locator(struct ipmi_intf *intf,
|
||||||
|
@ -84,7 +84,6 @@ struct sensor_set_thresh_rq {
|
|||||||
|
|
||||||
|
|
||||||
int ipmi_sensor_main(struct ipmi_intf *, int, char **);
|
int ipmi_sensor_main(struct ipmi_intf *, int, char **);
|
||||||
int ipmi_sensor_print_full(struct ipmi_intf *, struct sdr_record_full_sensor *);
|
int ipmi_sensor_print_fc(struct ipmi_intf *, struct sdr_record_common_sensor *, uint8_t);
|
||||||
int ipmi_sensor_print_compact(struct ipmi_intf *, struct sdr_record_compact_sensor *);
|
|
||||||
int ipmi_sensor_get_sensor_reading_factors( struct ipmi_intf * intf, struct sdr_record_full_sensor * sensor, uint8_t reading);
|
int ipmi_sensor_get_sensor_reading_factors( struct ipmi_intf * intf, struct sdr_record_full_sensor * sensor, uint8_t reading);
|
||||||
#endif /* IPMI_SENSOR_H */
|
#endif /* IPMI_SENSOR_H */
|
||||||
|
@ -1997,14 +1997,13 @@ static int ipmi_print_sensor_info(struct ipmi_intf *intf, uint16_t rec_id)
|
|||||||
rc = -1;
|
rc = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(header->type == SDR_RECORD_TYPE_FULL_SENSOR) {
|
if((header->type == SDR_RECORD_TYPE_FULL_SENSOR) ||
|
||||||
r = ipmi_sensor_print_full(intf, (struct sdr_record_full_sensor *)rec);
|
(header->type == SDR_RECORD_TYPE_COMPACT_SENSOR)) {
|
||||||
}
|
r = ipmi_sensor_print_fc(intf,
|
||||||
else if(header->type == SDR_RECORD_TYPE_COMPACT_SENSOR) {
|
(struct sdr_record_common_sensor *)rec, header->type);
|
||||||
r = ipmi_sensor_print_compact(intf, (struct sdr_record_compact_sensor *)rec);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
rc = -1;
|
rc = -1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
rc = -1; /* record id not found */
|
rc = -1; /* record id not found */
|
||||||
|
@ -3579,20 +3579,20 @@ static int ipmi_get_power_consumption_data(struct ipmi_intf* intf,uint8_t unit)
|
|||||||
if (NULL ==sdr)
|
if (NULL ==sdr)
|
||||||
{
|
{
|
||||||
printf ("Error : Can not access the System Level sensor data \n\n");
|
printf ("Error : Can not access the System Level sensor data \n\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
sensor_number = sdr->record.full->keys.sensor_num;
|
sensor_number = sdr->record.common->keys.sensor_num;
|
||||||
ipmi_get_sensor_reading (intf,sensor_number,&sensorReadingData);
|
ipmi_get_sensor_reading (intf,sensor_number,&sensorReadingData);
|
||||||
|
|
||||||
rsp = ipmi_sdr_get_sensor_thresholds(intf,
|
rsp = ipmi_sdr_get_sensor_thresholds(intf,
|
||||||
sdr->record.full->keys.sensor_num,
|
sdr->record.common->keys.sensor_num,
|
||||||
sdr->record.full->keys.owner_id,
|
sdr->record.common->keys.owner_id,
|
||||||
sdr->record.full->keys.lun,
|
sdr->record.common->keys.lun,
|
||||||
sdr->record.full->keys.channel);
|
sdr->record.common->keys.channel);
|
||||||
|
|
||||||
if (rsp != NULL && rsp->ccode == 0)
|
if (rsp != NULL && rsp->ccode == 0)
|
||||||
{
|
{
|
||||||
readingbtuphr=sdr_convert_sensor_reading
|
readingbtuphr=sdr_convert_sensor_reading
|
||||||
(sdr->record.full, sensorReadingData.sensorReading);
|
(sdr->record.full, sensorReadingData.sensorReading);
|
||||||
warning_threshbtuphr=sdr_convert_sensor_reading
|
warning_threshbtuphr=sdr_convert_sensor_reading
|
||||||
|
@ -273,25 +273,15 @@ ipmi_event_fromsensor(struct ipmi_intf * intf, char * id, char * state, char * e
|
|||||||
switch (sdr->type)
|
switch (sdr->type)
|
||||||
{
|
{
|
||||||
case SDR_RECORD_TYPE_FULL_SENSOR:
|
case SDR_RECORD_TYPE_FULL_SENSOR:
|
||||||
|
|
||||||
emsg.sensor_type = sdr->record.full->sensor.type;
|
|
||||||
emsg.sensor_num = sdr->record.full->keys.sensor_num;
|
|
||||||
emsg.event_type = sdr->record.full->event_type;
|
|
||||||
target = sdr->record.full->keys.owner_id;
|
|
||||||
lun = sdr->record.full->keys.lun;
|
|
||||||
channel = sdr->record.full->keys.channel;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDR_RECORD_TYPE_COMPACT_SENSOR:
|
case SDR_RECORD_TYPE_COMPACT_SENSOR:
|
||||||
|
|
||||||
emsg.sensor_type = sdr->record.compact->sensor.type;
|
emsg.sensor_type = sdr->record.common->sensor.type;
|
||||||
emsg.sensor_num = sdr->record.compact->keys.sensor_num;
|
emsg.sensor_num = sdr->record.common->keys.sensor_num;
|
||||||
emsg.event_type = sdr->record.compact->event_type;
|
emsg.event_type = sdr->record.common->event_type;
|
||||||
target = sdr->record.compact->keys.owner_id;
|
target = sdr->record.common->keys.owner_id;
|
||||||
lun = sdr->record.compact->keys.lun;
|
lun = sdr->record.common->keys.lun;
|
||||||
channel = sdr->record.compact->keys.channel;
|
channel = sdr->record.common->keys.channel;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
lprintf(LOG_ERR, "Unknown sensor type for id '%s'", id);
|
lprintf(LOG_ERR, "Unknown sensor type for id '%s'", id);
|
||||||
return -1;
|
return -1;
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1124,10 +1124,10 @@ ipmi_sel_print_std_entry(struct ipmi_intf * intf, struct sel_event_record * evt)
|
|||||||
((evt->sel_type.standard_type.event_data[0] & 0xf) % 2) ? ">" : "<",
|
((evt->sel_type.standard_type.event_data[0] & 0xf) % 2) ? ">" : "<",
|
||||||
(threshold_reading==(int)threshold_reading) ? 0 : 2,
|
(threshold_reading==(int)threshold_reading) ? 0 : 2,
|
||||||
threshold_reading,
|
threshold_reading,
|
||||||
ipmi_sdr_get_unit_string(sdr->record.full->unit.pct,
|
ipmi_sdr_get_unit_string(sdr->record.common->unit.pct,
|
||||||
sdr->record.full->unit.modifier,
|
sdr->record.common->unit.modifier,
|
||||||
sdr->record.full->unit.type.base,
|
sdr->record.common->unit.type.base,
|
||||||
sdr->record.full->unit.type.modifier));
|
sdr->record.common->unit.type.modifier));
|
||||||
}
|
}
|
||||||
else if (evt->sel_type.standard_type.event_type == 0x6f) {
|
else if (evt->sel_type.standard_type.event_type == 0x6f) {
|
||||||
/*
|
/*
|
||||||
@ -1312,10 +1312,10 @@ ipmi_sel_print_extended_entry_verbose(struct ipmi_intf * intf, struct sel_event_
|
|||||||
sdr_convert_sensor_reading(sdr->record.full,
|
sdr_convert_sensor_reading(sdr->record.full,
|
||||||
evt->sel_type.standard_type.event_data[1]));
|
evt->sel_type.standard_type.event_data[1]));
|
||||||
/* determine units with possible modifiers */
|
/* determine units with possible modifiers */
|
||||||
printf ("%s\n", ipmi_sdr_get_unit_string(sdr->record.full->unit.pct,
|
printf ("%s\n", ipmi_sdr_get_unit_string(sdr->record.common->unit.pct,
|
||||||
sdr->record.full->unit.modifier,
|
sdr->record.common->unit.modifier,
|
||||||
sdr->record.full->unit.type.base,
|
sdr->record.common->unit.type.base,
|
||||||
sdr->record.full->unit.type.modifier));
|
sdr->record.common->unit.type.modifier));
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
/* oem code in byte 2 */
|
/* oem code in byte 2 */
|
||||||
@ -1338,10 +1338,10 @@ ipmi_sel_print_extended_entry_verbose(struct ipmi_intf * intf, struct sel_event_
|
|||||||
sdr_convert_sensor_reading(sdr->record.full,
|
sdr_convert_sensor_reading(sdr->record.full,
|
||||||
evt->sel_type.standard_type.event_data[2]));
|
evt->sel_type.standard_type.event_data[2]));
|
||||||
/* determine units with possible modifiers */
|
/* determine units with possible modifiers */
|
||||||
printf ("%s\n", ipmi_sdr_get_unit_string(sdr->record.full->unit.pct,
|
printf ("%s\n", ipmi_sdr_get_unit_string(sdr->record.common->unit.pct,
|
||||||
sdr->record.full->unit.modifier,
|
sdr->record.common->unit.modifier,
|
||||||
sdr->record.full->unit.type.base,
|
sdr->record.common->unit.type.base,
|
||||||
sdr->record.full->unit.type.modifier));
|
sdr->record.common->unit.type.modifier));
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
/* OEM code in byte 3 */
|
/* OEM code in byte 3 */
|
||||||
@ -2052,14 +2052,11 @@ ipmi_sel_show_entry(struct ipmi_intf * intf, int argc, char ** argv)
|
|||||||
verbose = verbose ? : 1;
|
verbose = verbose ? : 1;
|
||||||
switch (sdr->type) {
|
switch (sdr->type) {
|
||||||
case SDR_RECORD_TYPE_FULL_SENSOR:
|
case SDR_RECORD_TYPE_FULL_SENSOR:
|
||||||
ipmi_sensor_print_full(intf, sdr->record.full);
|
|
||||||
entity.id = sdr->record.full->entity.id;
|
|
||||||
entity.instance = sdr->record.full->entity.instance;
|
|
||||||
break;
|
|
||||||
case SDR_RECORD_TYPE_COMPACT_SENSOR:
|
case SDR_RECORD_TYPE_COMPACT_SENSOR:
|
||||||
ipmi_sensor_print_compact(intf, sdr->record.compact);
|
ipmi_sensor_print_fc(intf, sdr->record.common,
|
||||||
entity.id = sdr->record.compact->entity.id;
|
sdr->type);
|
||||||
entity.instance = sdr->record.compact->entity.instance;
|
entity.id = sdr->record.common->entity.id;
|
||||||
|
entity.instance = sdr->record.common->entity.instance;
|
||||||
break;
|
break;
|
||||||
case SDR_RECORD_TYPE_EVENTONLY_SENSOR:
|
case SDR_RECORD_TYPE_EVENTONLY_SENSOR:
|
||||||
ipmi_sdr_print_sensor_eventonly(intf, sdr->record.eventonly);
|
ipmi_sdr_print_sensor_eventonly(intf, sdr->record.eventonly);
|
||||||
|
@ -43,9 +43,6 @@
|
|||||||
|
|
||||||
extern int verbose;
|
extern int verbose;
|
||||||
|
|
||||||
#define SCANNING_DISABLED 0x40
|
|
||||||
#define READING_UNAVAILABLE 0x20
|
|
||||||
|
|
||||||
// static
|
// static
|
||||||
int
|
int
|
||||||
ipmi_sensor_get_sensor_reading_factors(
|
ipmi_sensor_get_sensor_reading_factors(
|
||||||
@ -65,7 +62,7 @@ ipmi_sensor_get_sensor_reading_factors(
|
|||||||
memset(id, 0, sizeof(id));
|
memset(id, 0, sizeof(id));
|
||||||
memcpy(id, sensor->id_string, 16);
|
memcpy(id, sensor->id_string, 16);
|
||||||
|
|
||||||
req_data[0] = sensor->keys.sensor_num;
|
req_data[0] = sensor->cmn.keys.sensor_num;
|
||||||
req_data[1] = reading;
|
req_data[1] = reading;
|
||||||
|
|
||||||
memset(&req, 0, sizeof(req));
|
memset(&req, 0, sizeof(req));
|
||||||
@ -78,7 +75,7 @@ ipmi_sensor_get_sensor_reading_factors(
|
|||||||
|
|
||||||
if (rsp == NULL) {
|
if (rsp == NULL) {
|
||||||
lprintf(LOG_ERR, "Error updating reading factor for sensor %s (#%02x)",
|
lprintf(LOG_ERR, "Error updating reading factor for sensor %s (#%02x)",
|
||||||
id, sensor->keys.sensor_num);
|
id, sensor->cmn.keys.sensor_num);
|
||||||
return -1;
|
return -1;
|
||||||
} else if (rsp->ccode) {
|
} else if (rsp->ccode) {
|
||||||
return -1;
|
return -1;
|
||||||
@ -142,20 +139,34 @@ ipmi_sensor_set_sensor_thresholds(struct ipmi_intf *intf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ipmi_sensor_print_full_discrete(struct ipmi_intf *intf,
|
ipmi_sensor_print_fc_discrete(struct ipmi_intf *intf,
|
||||||
struct sdr_record_full_sensor *sensor)
|
struct sdr_record_common_sensor *sensor,
|
||||||
|
uint8_t sdr_record_type)
|
||||||
{
|
{
|
||||||
char id[17];
|
char id[17];
|
||||||
char *unitstr = "discrete";
|
char *unitstr = "discrete";
|
||||||
int validread = 1;
|
int validread = 1;
|
||||||
uint8_t val = 0;
|
uint8_t val = 0;
|
||||||
struct ipmi_rs *rsp;
|
struct ipmi_rs *rsp;
|
||||||
|
struct sdr_record_full_sensor *full = NULL;
|
||||||
|
struct sdr_record_compact_sensor *compact = NULL;
|
||||||
|
|
||||||
if (sensor == NULL)
|
if (sensor == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
switch (sdr_record_type) {
|
||||||
|
case (SDR_RECORD_TYPE_FULL_SENSOR):
|
||||||
|
full = (struct sdr_record_full_sensor *)sensor;
|
||||||
|
break;
|
||||||
|
case SDR_RECORD_TYPE_COMPACT_SENSOR:
|
||||||
|
compact = (struct sdr_record_compact_sensor *)sensor;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
memset(id, 0, sizeof (id));
|
memset(id, 0, sizeof (id));
|
||||||
memcpy(id, sensor->id_string, 16);
|
memcpy(id, full ? full->id_string : compact->id_string, 16);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get current reading
|
* Get current reading
|
||||||
@ -166,12 +177,17 @@ ipmi_sensor_print_full_discrete(struct ipmi_intf *intf,
|
|||||||
sensor->keys.lun,
|
sensor->keys.lun,
|
||||||
sensor->keys.channel);
|
sensor->keys.channel);
|
||||||
if (rsp == NULL) {
|
if (rsp == NULL) {
|
||||||
|
/*
|
||||||
|
* Why can't we just set validread equal to zero and fall
|
||||||
|
* though in the same way ipmi_sdr_print_sensor_fc does?
|
||||||
|
* All the cases below correctly handle validread.
|
||||||
|
*/
|
||||||
lprintf(LOG_ERR, "Error reading sensor %s (#%02x)",
|
lprintf(LOG_ERR, "Error reading sensor %s (#%02x)",
|
||||||
id, sensor->keys.sensor_num);
|
id, sensor->keys.sensor_num);
|
||||||
return -1;
|
return -1;
|
||||||
} else if (rsp->ccode > 0 || (rsp->data[1] & READING_UNAVAILABLE)) {
|
} else if (rsp->ccode || IS_READING_UNAVAILABLE(rsp->data[1])) {
|
||||||
validread = 0;
|
validread = 0;
|
||||||
} else if (!(rsp->data[1] & SCANNING_DISABLED)) {
|
} else if (IS_SCANNING_DISABLED(rsp->data[1])) {
|
||||||
validread = 0;
|
validread = 0;
|
||||||
} else {
|
} else {
|
||||||
/* convert RAW reading into units */
|
/* convert RAW reading into units */
|
||||||
@ -206,41 +222,82 @@ ipmi_sensor_print_full_discrete(struct ipmi_intf *intf,
|
|||||||
printf(" Sensor Type (Discrete): %s\n",
|
printf(" Sensor Type (Discrete): %s\n",
|
||||||
ipmi_sdr_get_sensor_type_desc(sensor->sensor.
|
ipmi_sdr_get_sensor_type_desc(sensor->sensor.
|
||||||
type));
|
type));
|
||||||
if( validread )
|
if( validread )
|
||||||
{
|
{
|
||||||
ipmi_sdr_print_discrete_state("States Asserted",
|
ipmi_sdr_print_discrete_state("States Asserted",
|
||||||
sensor->sensor.type,
|
sensor->sensor.type,
|
||||||
sensor->event_type,
|
sensor->event_type,
|
||||||
rsp->data[2],
|
rsp->data[2],
|
||||||
rsp->data[3]);
|
rsp->data[3]);
|
||||||
|
if (compact) {
|
||||||
|
printf(" Raw Data: %X", rsp->data[1]);
|
||||||
|
if(rsp->data_len > 2)
|
||||||
|
printf(" %X", rsp->data[2]);
|
||||||
|
if(rsp->data_len > 3)
|
||||||
|
printf(" %X", rsp->data[3]);
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
} else {
|
} else {
|
||||||
printf(" Unable to read sensor: Device Not Present\n\n");
|
printf(" Unable to read sensor: Device Not Present\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (validread ? 0 : -1 );
|
return (validread ? 0 : -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_thresh_setting(struct sdr_record_full_sensor *full,
|
||||||
|
uint8_t thresh_is_avail, uint8_t setting,
|
||||||
|
const char *field_sep,
|
||||||
|
const char *analog_fmt,
|
||||||
|
const char *discrete_fmt,
|
||||||
|
const char *na_fmt)
|
||||||
|
{
|
||||||
|
printf("%s", field_sep);
|
||||||
|
if (!thresh_is_avail) {
|
||||||
|
printf(na_fmt, "na");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (full && !UNITS_ARE_DISCRETE(&full->cmn)) {
|
||||||
|
printf(analog_fmt, sdr_convert_sensor_reading (full, setting));
|
||||||
|
} else {
|
||||||
|
printf(discrete_fmt, setting);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ipmi_sensor_print_full_analog(struct ipmi_intf *intf,
|
ipmi_sensor_print_fc_threshold(struct ipmi_intf *intf,
|
||||||
struct sdr_record_full_sensor *sensor)
|
struct sdr_record_common_sensor *sensor,
|
||||||
|
uint8_t sdr_record_type)
|
||||||
{
|
{
|
||||||
const char *unitstr = NULL;
|
const char *unitstr = NULL;
|
||||||
char id[17];
|
char id[17];
|
||||||
int validread = 1, thresh_available = 1;
|
int validread = 1, thresh_available = 1;
|
||||||
double val = 0.0;
|
double val = 0.0; /* converted analog value if a valid read */
|
||||||
|
uint8_t get_sens_read = 0;/* discrete value if a valid read*/
|
||||||
struct ipmi_rs *rsp;
|
struct ipmi_rs *rsp;
|
||||||
char *status = NULL;
|
const char *thresh_status = "";
|
||||||
|
struct sdr_record_full_sensor *full = NULL;
|
||||||
|
struct sdr_record_compact_sensor *compact = NULL;
|
||||||
|
|
||||||
if (sensor == NULL)
|
if (sensor == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
memset(id, 0, sizeof (id));
|
switch (sdr_record_type) {
|
||||||
memcpy(id, sensor->id_string, 16);
|
case (SDR_RECORD_TYPE_FULL_SENSOR):
|
||||||
|
full = (struct sdr_record_full_sensor *)sensor;
|
||||||
|
break;
|
||||||
|
case SDR_RECORD_TYPE_COMPACT_SENSOR:
|
||||||
|
compact = (struct sdr_record_compact_sensor *)sensor;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(id, 0, sizeof (id));
|
||||||
|
memcpy(id, full ? full->id_string : compact->id_string, 16);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get current reading
|
* Get current reading
|
||||||
@ -251,28 +308,25 @@ ipmi_sensor_print_full_analog(struct ipmi_intf *intf,
|
|||||||
sensor->keys.lun,
|
sensor->keys.lun,
|
||||||
sensor->keys.channel);
|
sensor->keys.channel);
|
||||||
if (rsp == NULL) {
|
if (rsp == NULL) {
|
||||||
|
/*
|
||||||
|
* Why can't we just set validread equal to zero and fall
|
||||||
|
* though in the same way ipmi_sdr_print_sensor_fc does?
|
||||||
|
* All the cases below correctly handle validread.
|
||||||
|
*/
|
||||||
lprintf(LOG_ERR, "Error reading sensor %s (#%02x)",
|
lprintf(LOG_ERR, "Error reading sensor %s (#%02x)",
|
||||||
id, sensor->keys.sensor_num);
|
id, sensor->keys.sensor_num);
|
||||||
return -1;
|
return -1;
|
||||||
} else if (rsp->ccode || (rsp->data[1] & READING_UNAVAILABLE)) {
|
} else if (rsp->ccode || IS_READING_UNAVAILABLE(rsp->data[1])) {
|
||||||
validread = 0;
|
validread = 0;
|
||||||
} else if (!(rsp->data[1] & SCANNING_DISABLED)) {
|
} else if (IS_SCANNING_DISABLED(rsp->data[1])) {
|
||||||
validread = 0;
|
validread = 0;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
/* Non linear sensors might provide updated reading factors */
|
/* Store off for use later */
|
||||||
if (sensor->linearization>=SDR_SENSOR_L_NONLINEAR && sensor->linearization<=0x7F) {
|
get_sens_read = rsp->data[0];
|
||||||
if (ipmi_sensor_get_sensor_reading_factors(intf, sensor, rsp->data[0]) < 0){
|
|
||||||
printf("sensor %s non-linear!\n", id);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* convert RAW reading into units */
|
val = sdr_convert_analog_reading(intf, full, get_sens_read, &validread);
|
||||||
/* a raw reading of 0 is perfectly valid, and might be converted to a positive or
|
thresh_status = ipmi_sdr_get_thresh_status(rsp, validread, "ns");
|
||||||
negative value, as any other raw values */
|
|
||||||
val = sdr_convert_sensor_reading(sensor, rsp->data[0]);
|
|
||||||
status = (char *) ipmi_sdr_get_status(sensor, rsp->data[2]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -299,49 +353,28 @@ ipmi_sensor_print_full_analog(struct ipmi_intf *intf,
|
|||||||
*/
|
*/
|
||||||
printf("%-16s ", id);
|
printf("%-16s ", id);
|
||||||
if (validread) {
|
if (validread) {
|
||||||
printf("| %-10.3f | %-10s | %-6s",
|
if (full && !UNITS_ARE_DISCRETE(sensor))
|
||||||
val, unitstr, status ? : "");
|
printf("| %-10.3f | %-10s | %-6s",
|
||||||
|
val, unitstr, thresh_status);
|
||||||
|
else
|
||||||
|
printf("| 0x%-8x | %-10s | %-6s",
|
||||||
|
get_sens_read, unitstr, thresh_status);
|
||||||
} else {
|
} else {
|
||||||
printf("| %-10s | %-10s | %-6s",
|
printf("| %-10s | %-10s | %-6s",
|
||||||
"na", unitstr, "na");
|
"na", unitstr, "na");
|
||||||
}
|
}
|
||||||
if (thresh_available) {
|
if (thresh_available && full) {
|
||||||
if (rsp->data[0] & LOWER_NON_RECOV_SPECIFIED)
|
#define PTS(bit, dataidx) { \
|
||||||
printf("| %-10.3f",
|
print_thresh_setting(full, rsp->data[0] & (bit), \
|
||||||
sdr_convert_sensor_reading
|
rsp->data[(dataidx)], "| ", "%-10.3f", "0x-8x", "%-10s"); \
|
||||||
(sensor, rsp->data[3]));
|
}
|
||||||
else
|
PTS(LOWER_NON_RECOV_SPECIFIED, 3);
|
||||||
printf("| %-10s", "na");
|
PTS(LOWER_CRIT_SPECIFIED, 2);
|
||||||
if (rsp->data[0] & LOWER_CRIT_SPECIFIED)
|
PTS(LOWER_NON_CRIT_SPECIFIED, 1);
|
||||||
printf("| %-10.3f",
|
PTS(UPPER_NON_CRIT_SPECIFIED, 4);
|
||||||
sdr_convert_sensor_reading
|
PTS(UPPER_CRIT_SPECIFIED, 5);
|
||||||
(sensor, rsp->data[2]));
|
PTS(UPPER_NON_RECOV_SPECIFIED, 6);
|
||||||
else
|
#undef PTS
|
||||||
printf("| %-10s", "na");
|
|
||||||
if (rsp->data[0] & LOWER_NON_CRIT_SPECIFIED)
|
|
||||||
printf("| %-10.3f",
|
|
||||||
sdr_convert_sensor_reading
|
|
||||||
(sensor, rsp->data[1]));
|
|
||||||
else
|
|
||||||
printf("| %-10s", "na");
|
|
||||||
if (rsp->data[0] & UPPER_NON_CRIT_SPECIFIED)
|
|
||||||
printf("| %-10.3f",
|
|
||||||
sdr_convert_sensor_reading
|
|
||||||
(sensor, rsp->data[4]));
|
|
||||||
else
|
|
||||||
printf("| %-10s", "na");
|
|
||||||
if (rsp->data[0] & UPPER_CRIT_SPECIFIED)
|
|
||||||
printf("| %-10.3f",
|
|
||||||
sdr_convert_sensor_reading
|
|
||||||
(sensor, rsp->data[5]));
|
|
||||||
else
|
|
||||||
printf("| %-10s", "na");
|
|
||||||
if (rsp->data[0] & UPPER_NON_RECOV_SPECIFIED)
|
|
||||||
printf("| %-10.3f",
|
|
||||||
sdr_convert_sensor_reading
|
|
||||||
(sensor, rsp->data[6]));
|
|
||||||
else
|
|
||||||
printf("| %-10s", "na");
|
|
||||||
} else {
|
} else {
|
||||||
printf
|
printf
|
||||||
("| %-10s| %-10s| %-10s| %-10s| %-10s| %-10s",
|
("| %-10s| %-10s| %-10s| %-10s| %-10s| %-10s",
|
||||||
@ -356,99 +389,64 @@ ipmi_sensor_print_full_analog(struct ipmi_intf *intf,
|
|||||||
printf(" Entity ID : %d.%d\n",
|
printf(" Entity ID : %d.%d\n",
|
||||||
sensor->entity.id, sensor->entity.instance);
|
sensor->entity.id, sensor->entity.instance);
|
||||||
|
|
||||||
printf(" Sensor Type (Analog) : %s\n",
|
printf(" Sensor Type (Threshold) : %s\n",
|
||||||
ipmi_sdr_get_sensor_type_desc(sensor->sensor.
|
ipmi_sdr_get_sensor_type_desc(sensor->sensor.
|
||||||
type));
|
type));
|
||||||
|
|
||||||
printf(" Sensor Reading : ");
|
printf(" Sensor Reading : ");
|
||||||
if (validread) {
|
if (validread) {
|
||||||
uint16_t raw_tol = __TO_TOL(sensor->mtol);
|
if (full) {
|
||||||
double tol =
|
uint16_t raw_tol = __TO_TOL(full->mtol);
|
||||||
sdr_convert_sensor_tolerance(sensor,
|
if (!UNITS_ARE_DISCRETE(sensor)) {
|
||||||
raw_tol);
|
double tol =
|
||||||
printf("%.*f (+/- %.*f) %s\n",
|
sdr_convert_sensor_tolerance(full,
|
||||||
(val == (int) val) ? 0 : 3, val,
|
raw_tol);
|
||||||
(tol == (int) tol) ? 0 : 3, tol,
|
printf("%.*f (+/- %.*f) %s\n",
|
||||||
unitstr);
|
(val == (int) val) ? 0 : 3, val,
|
||||||
printf(" Status : %s\n",
|
(tol == (int) tol) ? 0 : 3, tol,
|
||||||
status ? : "");
|
unitstr);
|
||||||
|
} else {
|
||||||
|
printf("0x%x (+/- 0x%x) %s\n",
|
||||||
|
get_sens_read,
|
||||||
|
raw_tol,
|
||||||
|
unitstr);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
printf("0x%x %s\n", get_sens_read, unitstr);
|
||||||
|
}
|
||||||
|
printf(" Status : %s\n", thresh_status);
|
||||||
|
|
||||||
if (thresh_available) {
|
if (thresh_available) {
|
||||||
if (rsp->data[0] & LOWER_NON_RECOV_SPECIFIED)
|
if (full) {
|
||||||
printf
|
#define PTS(bit, dataidx, str) { \
|
||||||
(" Lower Non-Recoverable : %.3f\n",
|
print_thresh_setting(full, rsp->data[0] & (bit), \
|
||||||
sdr_convert_sensor_reading
|
rsp->data[(dataidx)], \
|
||||||
(sensor, rsp->data[3]));
|
(str), "%.3f\n", "0x%x\n", "%s\n"); \
|
||||||
else
|
}
|
||||||
printf
|
|
||||||
(" Lower Non-Recoverable : na\n");
|
|
||||||
if (rsp->data[0] & LOWER_CRIT_SPECIFIED)
|
|
||||||
printf
|
|
||||||
(" Lower Critical : %.3f\n",
|
|
||||||
sdr_convert_sensor_reading
|
|
||||||
(sensor, rsp->data[2]));
|
|
||||||
else
|
|
||||||
printf
|
|
||||||
(" Lower Critical : na\n");
|
|
||||||
if (rsp->data[0] & LOWER_NON_CRIT_SPECIFIED)
|
|
||||||
printf
|
|
||||||
(" Lower Non-Critical : %.3f\n",
|
|
||||||
sdr_convert_sensor_reading
|
|
||||||
(sensor, rsp->data[1]));
|
|
||||||
else
|
|
||||||
printf
|
|
||||||
(" Lower Non-Critical : na\n");
|
|
||||||
if (rsp->data[0] & UPPER_NON_CRIT_SPECIFIED)
|
|
||||||
printf
|
|
||||||
(" Upper Non-Critical : %.3f\n",
|
|
||||||
sdr_convert_sensor_reading
|
|
||||||
(sensor, rsp->data[4]));
|
|
||||||
else
|
|
||||||
printf
|
|
||||||
(" Upper Non-Critical : na\n");
|
|
||||||
if (rsp->data[0] & UPPER_CRIT_SPECIFIED)
|
|
||||||
printf
|
|
||||||
(" Upper Critical : %.3f\n",
|
|
||||||
sdr_convert_sensor_reading
|
|
||||||
(sensor, rsp->data[5]));
|
|
||||||
else
|
|
||||||
printf
|
|
||||||
(" Upper Critical : na\n");
|
|
||||||
if (rsp->data[0] & UPPER_NON_RECOV_SPECIFIED)
|
|
||||||
printf
|
|
||||||
(" Upper Non-Recoverable : %.3f\n",
|
|
||||||
sdr_convert_sensor_reading
|
|
||||||
(sensor, rsp->data[6]));
|
|
||||||
else
|
|
||||||
printf
|
|
||||||
(" Upper Non-Recoverable : na\n");
|
|
||||||
|
|
||||||
if (
|
PTS(LOWER_NON_RECOV_SPECIFIED, 3, " Lower Non-Recoverable : ");
|
||||||
sensor->threshold.hysteresis.positive == 0x00
|
PTS(LOWER_CRIT_SPECIFIED, 2, " Lower Critical : ");
|
||||||
||
|
PTS(LOWER_NON_CRIT_SPECIFIED, 1, " Lower Non-Critical : ");
|
||||||
sensor->threshold.hysteresis.positive == 0xff
|
PTS(UPPER_NON_CRIT_SPECIFIED, 4, " Upper Non-Critical : ");
|
||||||
)
|
PTS(UPPER_CRIT_SPECIFIED, 5, " Upper Critical : ");
|
||||||
printf(" Positive Hysteresis : Unspecified\n");
|
PTS(UPPER_NON_RECOV_SPECIFIED, 6, " Upper Non-Recoverable : ");
|
||||||
else
|
#undef PTS
|
||||||
printf(" Positive Hysteresis : %.3f\n",
|
|
||||||
sdr_convert_sensor_hysterisis
|
|
||||||
(sensor,sensor->threshold.hysteresis.positive));
|
|
||||||
|
|
||||||
if (
|
}
|
||||||
sensor->threshold.hysteresis.negative == 0x00
|
ipmi_sdr_print_sensor_hysteresis(sensor, full,
|
||||||
||
|
full ? full->threshold.hysteresis.positive :
|
||||||
sensor->threshold.hysteresis.negative == 0xff
|
compact->threshold.hysteresis.positive,
|
||||||
)
|
"Positive Hysteresis");
|
||||||
printf(" Negative Hysteresis : Unspecified\n");
|
|
||||||
else
|
ipmi_sdr_print_sensor_hysteresis(sensor, full,
|
||||||
printf(" Negative Hysteresis : %.3f\n",
|
full ? full->threshold.hysteresis.negative :
|
||||||
sdr_convert_sensor_hysterisis
|
compact->threshold.hysteresis.negative,
|
||||||
(sensor,sensor->threshold.hysteresis.negative));
|
"Negative Hysteresis");
|
||||||
} else {
|
} else {
|
||||||
printf(" Sensor Threshold Settings not available\n");
|
printf(" Sensor Threshold Settings not available\n");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
printf(" Unable to read sensor: Device Not Present\n\n");
|
printf(" Unable to read sensor: Device Not Present\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
ipmi_sdr_print_sensor_event_status(intf,
|
ipmi_sdr_print_sensor_event_status(intf,
|
||||||
@ -478,104 +476,14 @@ ipmi_sensor_print_full_analog(struct ipmi_intf *intf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
ipmi_sensor_print_full(struct ipmi_intf *intf,
|
ipmi_sensor_print_fc(struct ipmi_intf *intf,
|
||||||
struct sdr_record_full_sensor *sensor)
|
struct sdr_record_common_sensor *sensor,
|
||||||
|
uint8_t sdr_record_type)
|
||||||
{
|
{
|
||||||
if (sensor->unit.analog != 3)
|
if (IS_THRESHOLD_SENSOR(sensor))
|
||||||
return ipmi_sensor_print_full_analog(intf, sensor);
|
return ipmi_sensor_print_fc_threshold(intf, sensor, sdr_record_type);
|
||||||
else
|
else
|
||||||
return ipmi_sensor_print_full_discrete(intf, sensor);
|
return ipmi_sensor_print_fc_discrete(intf, sensor, sdr_record_type);
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
ipmi_sensor_print_compact(struct ipmi_intf *intf,
|
|
||||||
struct sdr_record_compact_sensor *sensor)
|
|
||||||
{
|
|
||||||
char id[17];
|
|
||||||
char *unitstr = "discrete";
|
|
||||||
int validread = 1;
|
|
||||||
uint8_t val = 0;
|
|
||||||
struct ipmi_rs *rsp;
|
|
||||||
|
|
||||||
if (sensor == NULL)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
memset(id, 0, sizeof (id));
|
|
||||||
memcpy(id, sensor->id_string, 16);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Get current reading
|
|
||||||
*/
|
|
||||||
rsp = ipmi_sdr_get_sensor_reading_ipmb(intf,
|
|
||||||
sensor->keys.sensor_num,
|
|
||||||
sensor->keys.owner_id,
|
|
||||||
sensor->keys.lun,
|
|
||||||
sensor->keys.channel);
|
|
||||||
if (rsp == NULL) {
|
|
||||||
lprintf(LOG_ERR, "Error reading sensor %s (#%02x)",
|
|
||||||
id, sensor->keys.sensor_num);
|
|
||||||
return -1;
|
|
||||||
} else if (rsp->ccode || (rsp->data[1] & READING_UNAVAILABLE)) {
|
|
||||||
validread = 0;
|
|
||||||
} else if (!(rsp->data[1] & SCANNING_DISABLED)) {
|
|
||||||
validread = 0;
|
|
||||||
} else {
|
|
||||||
/* convert RAW reading into units */
|
|
||||||
val = rsp->data[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (csv_output) {
|
|
||||||
/* NOT IMPLEMENTED */
|
|
||||||
} else {
|
|
||||||
if (!verbose) {
|
|
||||||
/* output format
|
|
||||||
* id value units status thresholds....
|
|
||||||
*/
|
|
||||||
printf("%-16s ", id);
|
|
||||||
|
|
||||||
if (validread) {
|
|
||||||
printf("| 0x%-8x | %-10s | 0x%02x%02x",
|
|
||||||
val, unitstr,
|
|
||||||
rsp->data[2], rsp->data[3]);
|
|
||||||
} else {
|
|
||||||
printf("| %-10s | %-10s | %-6s",
|
|
||||||
"na", unitstr, "na");
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("| %-10s| %-10s| %-10s| %-10s| %-10s| %-10s",
|
|
||||||
"na", "na", "na", "na", "na", "na");
|
|
||||||
printf("\n");
|
|
||||||
} else {
|
|
||||||
printf("Sensor ID : %s (0x%x)\n",
|
|
||||||
id, sensor->keys.sensor_num);
|
|
||||||
printf(" Entity ID : %d.%d\n",
|
|
||||||
sensor->entity.id, sensor->entity.instance);
|
|
||||||
printf(" Sensor Type (Discrete): %s\n",
|
|
||||||
ipmi_sdr_get_sensor_type_desc(sensor->sensor.
|
|
||||||
type));
|
|
||||||
|
|
||||||
if(validread)
|
|
||||||
{
|
|
||||||
ipmi_sdr_print_discrete_state("States Asserted",
|
|
||||||
sensor->sensor.type,
|
|
||||||
sensor->event_type,
|
|
||||||
rsp->data[2],
|
|
||||||
rsp->data[3]);
|
|
||||||
printf(" Raw Data: %X", rsp->data[1]);
|
|
||||||
if(rsp->data_len > 2)
|
|
||||||
printf(" %X", rsp->data[2]);
|
|
||||||
if(rsp->data_len > 3)
|
|
||||||
printf(" %X", rsp->data[3]);
|
|
||||||
printf("\n");
|
|
||||||
printf("\n");
|
|
||||||
} else {
|
|
||||||
printf(" Unable to read sensor: Device Not Present\n\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (validread ? 0 : -1 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -605,16 +513,12 @@ ipmi_sensor_list(struct ipmi_intf *intf)
|
|||||||
|
|
||||||
switch (header->type) {
|
switch (header->type) {
|
||||||
case SDR_RECORD_TYPE_FULL_SENSOR:
|
case SDR_RECORD_TYPE_FULL_SENSOR:
|
||||||
r = ipmi_sensor_print_full(intf,
|
|
||||||
(struct
|
|
||||||
sdr_record_full_sensor *)
|
|
||||||
rec);
|
|
||||||
break;
|
|
||||||
case SDR_RECORD_TYPE_COMPACT_SENSOR:
|
case SDR_RECORD_TYPE_COMPACT_SENSOR:
|
||||||
r = ipmi_sensor_print_compact(intf,
|
r = ipmi_sensor_print_fc(intf,
|
||||||
(struct
|
(struct
|
||||||
sdr_record_compact_sensor
|
sdr_record_common_sensor *)
|
||||||
*) rec);
|
rec,
|
||||||
|
header->type);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
free(rec);
|
free(rec);
|
||||||
@ -662,6 +566,28 @@ __ipmi_sensor_set_threshold(struct ipmi_intf *intf,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint8_t
|
||||||
|
__ipmi_sensor_threshold_value_to_raw(struct sdr_record_full_sensor *full, double value)
|
||||||
|
{
|
||||||
|
if (!UNITS_ARE_DISCRETE(&full->cmn)) { /* Has an analog reading */
|
||||||
|
/* Has an analog reading and supports mx+b */
|
||||||
|
return sdr_convert_sensor_value_to_raw(full, value);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* Does not have an analog reading and/or does not support mx+b */
|
||||||
|
if (value > 255) {
|
||||||
|
return 255;
|
||||||
|
}
|
||||||
|
else if (value < 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return (uint8_t )value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ipmi_sensor_set_threshold(struct ipmi_intf *intf, int argc, char **argv)
|
ipmi_sensor_set_threshold(struct ipmi_intf *intf, int argc, char **argv)
|
||||||
{
|
{
|
||||||
@ -763,90 +689,89 @@ ipmi_sensor_set_threshold(struct ipmi_intf *intf, int argc, char **argv)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!IS_THRESHOLD_SENSOR(sdr->record.common)) {
|
||||||
|
lprintf(LOG_ERR, "Invalid sensor event type %02x", sdr->record.common->event_type);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (allUpper) {
|
if (allUpper) {
|
||||||
settingMask = UPPER_NON_CRIT_SPECIFIED;
|
settingMask = UPPER_NON_CRIT_SPECIFIED;
|
||||||
printf("Setting sensor \"%s\" %s threshold to %.3f\n",
|
printf("Setting sensor \"%s\" %s threshold to %.3f\n",
|
||||||
sdr->record.full->id_string,
|
sdr->record.full->id_string,
|
||||||
val2str(settingMask, threshold_vals), setting1);
|
val2str(settingMask, threshold_vals), setting1);
|
||||||
ret = __ipmi_sensor_set_threshold(intf,
|
ret = __ipmi_sensor_set_threshold(intf,
|
||||||
sdr->record.full->keys.
|
sdr->record.common->keys.
|
||||||
sensor_num, settingMask,
|
sensor_num, settingMask,
|
||||||
sdr_convert_sensor_value_to_raw
|
__ipmi_sensor_threshold_value_to_raw(sdr->record.full, setting1),
|
||||||
(sdr->record.full, setting1),
|
sdr->record.common->keys.owner_id,
|
||||||
sdr->record.full->keys.owner_id,
|
sdr->record.common->keys.lun);
|
||||||
sdr->record.full->keys.lun);
|
|
||||||
|
|
||||||
settingMask = UPPER_CRIT_SPECIFIED;
|
settingMask = UPPER_CRIT_SPECIFIED;
|
||||||
printf("Setting sensor \"%s\" %s threshold to %.3f\n",
|
printf("Setting sensor \"%s\" %s threshold to %.3f\n",
|
||||||
sdr->record.full->id_string,
|
sdr->record.full->id_string,
|
||||||
val2str(settingMask, threshold_vals), setting2);
|
val2str(settingMask, threshold_vals), setting2);
|
||||||
ret = __ipmi_sensor_set_threshold(intf,
|
ret = __ipmi_sensor_set_threshold(intf,
|
||||||
sdr->record.full->keys.
|
sdr->record.common->keys.
|
||||||
sensor_num, settingMask,
|
sensor_num, settingMask,
|
||||||
sdr_convert_sensor_value_to_raw
|
__ipmi_sensor_threshold_value_to_raw(sdr->record.full, setting2),
|
||||||
(sdr->record.full, setting2),
|
sdr->record.common->keys.owner_id,
|
||||||
sdr->record.full->keys.owner_id,
|
sdr->record.common->keys.lun);
|
||||||
sdr->record.full->keys.lun);
|
|
||||||
|
|
||||||
settingMask = UPPER_NON_RECOV_SPECIFIED;
|
settingMask = UPPER_NON_RECOV_SPECIFIED;
|
||||||
printf("Setting sensor \"%s\" %s threshold to %.3f\n",
|
printf("Setting sensor \"%s\" %s threshold to %.3f\n",
|
||||||
sdr->record.full->id_string,
|
sdr->record.full->id_string,
|
||||||
val2str(settingMask, threshold_vals), setting3);
|
val2str(settingMask, threshold_vals), setting3);
|
||||||
ret = __ipmi_sensor_set_threshold(intf,
|
ret = __ipmi_sensor_set_threshold(intf,
|
||||||
sdr->record.full->keys.
|
sdr->record.common->keys.
|
||||||
sensor_num, settingMask,
|
sensor_num, settingMask,
|
||||||
sdr_convert_sensor_value_to_raw
|
__ipmi_sensor_threshold_value_to_raw(sdr->record.full, setting3),
|
||||||
(sdr->record.full, setting3),
|
sdr->record.common->keys.owner_id,
|
||||||
sdr->record.full->keys.owner_id,
|
sdr->record.common->keys.lun);
|
||||||
sdr->record.full->keys.lun);
|
|
||||||
} else if (allLower) {
|
} else if (allLower) {
|
||||||
settingMask = LOWER_NON_RECOV_SPECIFIED;
|
settingMask = LOWER_NON_RECOV_SPECIFIED;
|
||||||
printf("Setting sensor \"%s\" %s threshold to %.3f\n",
|
printf("Setting sensor \"%s\" %s threshold to %.3f\n",
|
||||||
sdr->record.full->id_string,
|
sdr->record.full->id_string,
|
||||||
val2str(settingMask, threshold_vals), setting1);
|
val2str(settingMask, threshold_vals), setting1);
|
||||||
ret = __ipmi_sensor_set_threshold(intf,
|
ret = __ipmi_sensor_set_threshold(intf,
|
||||||
sdr->record.full->keys.
|
sdr->record.common->keys.
|
||||||
sensor_num, settingMask,
|
sensor_num, settingMask,
|
||||||
sdr_convert_sensor_value_to_raw
|
__ipmi_sensor_threshold_value_to_raw(sdr->record.full, setting1),
|
||||||
(sdr->record.full, setting1),
|
sdr->record.common->keys.owner_id,
|
||||||
sdr->record.full->keys.owner_id,
|
sdr->record.common->keys.lun);
|
||||||
sdr->record.full->keys.lun);
|
|
||||||
|
|
||||||
settingMask = LOWER_CRIT_SPECIFIED;
|
settingMask = LOWER_CRIT_SPECIFIED;
|
||||||
printf("Setting sensor \"%s\" %s threshold to %.3f\n",
|
printf("Setting sensor \"%s\" %s threshold to %.3f\n",
|
||||||
sdr->record.full->id_string,
|
sdr->record.full->id_string,
|
||||||
val2str(settingMask, threshold_vals), setting2);
|
val2str(settingMask, threshold_vals), setting2);
|
||||||
ret = __ipmi_sensor_set_threshold(intf,
|
ret = __ipmi_sensor_set_threshold(intf,
|
||||||
sdr->record.full->keys.
|
sdr->record.common->keys.
|
||||||
sensor_num, settingMask,
|
sensor_num, settingMask,
|
||||||
sdr_convert_sensor_value_to_raw
|
__ipmi_sensor_threshold_value_to_raw(sdr->record.full, setting2),
|
||||||
(sdr->record.full, setting2),
|
sdr->record.common->keys.owner_id,
|
||||||
sdr->record.full->keys.owner_id,
|
sdr->record.common->keys.lun);
|
||||||
sdr->record.full->keys.lun);
|
|
||||||
|
|
||||||
settingMask = LOWER_NON_CRIT_SPECIFIED;
|
settingMask = LOWER_NON_CRIT_SPECIFIED;
|
||||||
printf("Setting sensor \"%s\" %s threshold to %.3f\n",
|
printf("Setting sensor \"%s\" %s threshold to %.3f\n",
|
||||||
sdr->record.full->id_string,
|
sdr->record.full->id_string,
|
||||||
val2str(settingMask, threshold_vals), setting3);
|
val2str(settingMask, threshold_vals), setting3);
|
||||||
ret = __ipmi_sensor_set_threshold(intf,
|
ret = __ipmi_sensor_set_threshold(intf,
|
||||||
sdr->record.full->keys.
|
sdr->record.common->keys.
|
||||||
sensor_num, settingMask,
|
sensor_num, settingMask,
|
||||||
sdr_convert_sensor_value_to_raw
|
__ipmi_sensor_threshold_value_to_raw(sdr->record.full, setting3),
|
||||||
(sdr->record.full, setting3),
|
sdr->record.common->keys.owner_id,
|
||||||
sdr->record.full->keys.owner_id,
|
sdr->record.common->keys.lun);
|
||||||
sdr->record.full->keys.lun);
|
|
||||||
} else {
|
} else {
|
||||||
printf("Setting sensor \"%s\" %s threshold to %.3f\n",
|
printf("Setting sensor \"%s\" %s threshold to %.3f\n",
|
||||||
sdr->record.full->id_string,
|
sdr->record.full->id_string,
|
||||||
val2str(settingMask, threshold_vals), setting1);
|
val2str(settingMask, threshold_vals), setting1);
|
||||||
|
|
||||||
ret = __ipmi_sensor_set_threshold(intf,
|
ret = __ipmi_sensor_set_threshold(intf,
|
||||||
sdr->record.full->keys.
|
sdr->record.common->keys.
|
||||||
sensor_num, settingMask,
|
sensor_num, settingMask,
|
||||||
sdr_convert_sensor_value_to_raw
|
__ipmi_sensor_threshold_value_to_raw(sdr->record.full, setting1),
|
||||||
(sdr->record.full, setting1),
|
sdr->record.common->keys.owner_id,
|
||||||
sdr->record.full->keys.owner_id,
|
sdr->record.common->keys.lun);
|
||||||
sdr->record.full->keys.lun);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -877,24 +802,29 @@ ipmi_sensor_get_reading(struct ipmi_intf *intf, int argc, char **argv)
|
|||||||
|
|
||||||
switch (sdr->type) {
|
switch (sdr->type) {
|
||||||
case SDR_RECORD_TYPE_FULL_SENSOR:
|
case SDR_RECORD_TYPE_FULL_SENSOR:
|
||||||
|
/* Only Threshold can return an analog reading */
|
||||||
|
if (!IS_THRESHOLD_SENSOR(sdr->record.common)) {
|
||||||
|
lprintf(LOG_ERR, "Sensor \"%s\" is a discrete sensor!", argv[i]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (sdr->record.full->linearization >= SDR_SENSOR_L_NONLINEAR) {
|
if (sdr->record.full->linearization >= SDR_SENSOR_L_NONLINEAR) {
|
||||||
lprintf(LOG_ERR, "Sensor \"%s\" non-linear!", argv[i]);
|
lprintf(LOG_ERR, "Sensor \"%s\" non-linear!", argv[i]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
rsp = ipmi_sdr_get_sensor_reading_ipmb(intf,
|
rsp = ipmi_sdr_get_sensor_reading_ipmb(intf,
|
||||||
sdr->record.full->keys.sensor_num,
|
sdr->record.common->keys.sensor_num,
|
||||||
sdr->record.full->keys.owner_id,
|
sdr->record.common->keys.owner_id,
|
||||||
sdr->record.full->keys.lun,
|
sdr->record.common->keys.lun,
|
||||||
sdr->record.full->keys.channel);
|
sdr->record.common->keys.channel);
|
||||||
if (rsp == NULL) {
|
if (rsp == NULL) {
|
||||||
lprintf(LOG_ERR, "Error reading sensor \"%s\"", argv[i]);
|
lprintf(LOG_ERR, "Error reading sensor \"%s\"", argv[i]);
|
||||||
rc = -1;
|
rc = -1;
|
||||||
continue;
|
continue;
|
||||||
} else if (rsp->ccode > 0) {
|
} else if (rsp->ccode > 0) {
|
||||||
continue;
|
continue;
|
||||||
} else if (rsp->data[1] & READING_UNAVAILABLE) {
|
} else if (IS_READING_UNAVAILABLE(rsp->data[1])) {
|
||||||
continue;
|
continue;
|
||||||
} else if (!(rsp->data[1] & SCANNING_DISABLED)) {
|
} else if (IS_SCANNING_DISABLED(rsp->data[1])) {
|
||||||
continue;
|
continue;
|
||||||
} else if (rsp->data[0] > 0) {
|
} else if (rsp->data[0] > 0) {
|
||||||
/* convert RAW reading into units */
|
/* convert RAW reading into units */
|
||||||
@ -953,11 +883,9 @@ ipmi_sensor_get(struct ipmi_intf *intf, int argc, char **argv)
|
|||||||
verbose = 1;
|
verbose = 1;
|
||||||
switch (sdr->type) {
|
switch (sdr->type) {
|
||||||
case SDR_RECORD_TYPE_FULL_SENSOR:
|
case SDR_RECORD_TYPE_FULL_SENSOR:
|
||||||
r = ipmi_sensor_print_full(intf, sdr->record.full);
|
|
||||||
break;
|
|
||||||
case SDR_RECORD_TYPE_COMPACT_SENSOR:
|
case SDR_RECORD_TYPE_COMPACT_SENSOR:
|
||||||
r = ipmi_sensor_print_compact(intf,
|
r = ipmi_sensor_print_fc(intf, sdr->record.common,
|
||||||
sdr->record.compact);
|
sdr->type);
|
||||||
break;
|
break;
|
||||||
case SDR_RECORD_TYPE_EVENTONLY_SENSOR:
|
case SDR_RECORD_TYPE_EVENTONLY_SENSOR:
|
||||||
r = ipmi_sdr_print_sensor_eventonly(intf,
|
r = ipmi_sdr_print_sensor_eventonly(intf,
|
||||||
|
@ -284,10 +284,10 @@ log_event(struct ipmi_event_intf * eintf, struct sel_event_record * evt)
|
|||||||
((evt->sel_type.standard_type.event_data[0] & 0xf) % 2) ? ">" : "<",
|
((evt->sel_type.standard_type.event_data[0] & 0xf) % 2) ? ">" : "<",
|
||||||
(threshold_reading==(int)threshold_reading) ? 0 : 2,
|
(threshold_reading==(int)threshold_reading) ? 0 : 2,
|
||||||
threshold_reading,
|
threshold_reading,
|
||||||
ipmi_sdr_get_unit_string(sdr->record.full->unit.pct,
|
ipmi_sdr_get_unit_string(sdr->record.common->unit.pct,
|
||||||
sdr->record.full->unit.modifier,
|
sdr->record.common->unit.modifier,
|
||||||
sdr->record.full->unit.type.base,
|
sdr->record.common->unit.type.base,
|
||||||
sdr->record.full->unit.type.modifier));
|
sdr->record.common->unit.type.modifier));
|
||||||
}
|
}
|
||||||
else if ((evt->sel_type.standard_type.event_type >= 0x2 && evt->sel_type.standard_type.event_type <= 0xc) ||
|
else if ((evt->sel_type.standard_type.event_type >= 0x2 && evt->sel_type.standard_type.event_type <= 0xc) ||
|
||||||
(evt->sel_type.standard_type.event_type == 0x6f)) {
|
(evt->sel_type.standard_type.event_type == 0x6f)) {
|
||||||
|
@ -746,7 +746,8 @@ ipmi_lan_poll_recv(struct ipmi_intf * intf)
|
|||||||
rsp->payload.ipmi_response.cmd == 0x34) {
|
rsp->payload.ipmi_response.cmd == 0x34) {
|
||||||
memcpy(rsp->data, &rsp->data[offset],
|
memcpy(rsp->data, &rsp->data[offset],
|
||||||
(rsp->data_len-offset));
|
(rsp->data_len-offset));
|
||||||
printbuf( &rsp->data[offset],
|
if (verbose > 2)
|
||||||
|
printbuf( &rsp->data[offset],
|
||||||
(rsp->data_len-offset),
|
(rsp->data_len-offset),
|
||||||
"bridge command response");
|
"bridge command response");
|
||||||
}
|
}
|
||||||
@ -2089,10 +2090,16 @@ ipmi_lanplus_send_payload(
|
|||||||
int try = 0;
|
int try = 0;
|
||||||
int xmit = 1;
|
int xmit = 1;
|
||||||
time_t ltime;
|
time_t ltime;
|
||||||
|
uint32_t timeout;
|
||||||
|
|
||||||
if (!intf->opened && intf->open && intf->open(intf) < 0)
|
if (!intf->opened && intf->open && intf->open(intf) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The session timeout is initialized in the above interface open,
|
||||||
|
* so it will only be valid after the open completes.
|
||||||
|
*/
|
||||||
|
timeout = session->timeout;
|
||||||
while (try < session->retry) {
|
while (try < session->retry) {
|
||||||
//ltime = time(NULL);
|
//ltime = time(NULL);
|
||||||
|
|
||||||
@ -2287,21 +2294,19 @@ ipmi_lanplus_send_payload(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
xmit = ((time(NULL) - ltime) >= intf->session->timeout);
|
/* only timeout if time exceeds the timeout value */
|
||||||
|
xmit = ((time(NULL) - ltime) > timeout);
|
||||||
|
|
||||||
usleep(5000);
|
usleep(5000);
|
||||||
|
|
||||||
if (xmit) {
|
if (xmit) {
|
||||||
/* incremet session timeout each retry */
|
/* increment session timeout by 1 second each retry */
|
||||||
intf->session->timeout++;
|
timeout++;
|
||||||
}
|
}
|
||||||
|
|
||||||
try++;
|
try++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reset timeout after retry loop completes */
|
|
||||||
intf->session->timeout = IPMI_LAN_TIMEOUT;
|
|
||||||
|
|
||||||
/* IPMI messages are deleted under ipmi_lan_poll_recv() */
|
/* IPMI messages are deleted under ipmi_lan_poll_recv() */
|
||||||
switch (payload->payload_type) {
|
switch (payload->payload_type) {
|
||||||
case IPMI_PAYLOAD_TYPE_RMCP_OPEN_REQUEST:
|
case IPMI_PAYLOAD_TYPE_RMCP_OPEN_REQUEST:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user