mirror of
https://github.com/ipmitool/ipmitool.git
synced 2025-05-11 11:07:23 +00:00
ipmi_sdr.c: Fix ipmi_sdr_get_sensor_reading_ipmb() to keep track of device lun.
ipmi_sdr.c: Better error handling to avoid coredump when sensor description is missing. ipmi_sensor.c: use new ipmi_sdr_get_sensor_reading_ipmb() interface ipmi_sunoem.c: keep track of device lun ipmi_sel.h: add "OEM Specific" device description ipmi_sdr.h: modify ipmi_sdr_get_sensor_reading_ipmb() prototype
This commit is contained in:
parent
e667785bd3
commit
65d1b0a623
@ -803,7 +803,8 @@ struct ipmi_rs *ipmi_sdr_get_sensor_reading(struct ipmi_intf *intf,
|
|||||||
uint8_t sensor);
|
uint8_t sensor);
|
||||||
struct ipmi_rs *ipmi_sdr_get_sensor_reading_ipmb(struct ipmi_intf *intf,
|
struct ipmi_rs *ipmi_sdr_get_sensor_reading_ipmb(struct ipmi_intf *intf,
|
||||||
uint8_t sensor,
|
uint8_t sensor,
|
||||||
uint8_t target);
|
uint8_t target,
|
||||||
|
uint8_t lun);
|
||||||
struct ipmi_rs *ipmi_sdr_get_sensor_thresholds(struct ipmi_intf *intf,
|
struct ipmi_rs *ipmi_sdr_get_sensor_thresholds(struct ipmi_intf *intf,
|
||||||
uint8_t sensor);
|
uint8_t sensor);
|
||||||
struct ipmi_rs *ipmi_sdr_get_sensor_hysteresis(struct ipmi_intf *intf,
|
struct ipmi_rs *ipmi_sdr_get_sensor_hysteresis(struct ipmi_intf *intf,
|
||||||
|
@ -516,7 +516,7 @@ static struct ipmi_event_sensor_types sensor_specific_types[] __attribute__((unu
|
|||||||
{ 0xF2, 0x01, 0xff, IPMI_EVENT_CLASS_DISCRETE, "Module Hot Swap", "Module Handle Opened" },
|
{ 0xF2, 0x01, 0xff, IPMI_EVENT_CLASS_DISCRETE, "Module Hot Swap", "Module Handle Opened" },
|
||||||
{ 0xF2, 0x02, 0xff, IPMI_EVENT_CLASS_DISCRETE, "Module Hot Swap", "Quiesced" },
|
{ 0xF2, 0x02, 0xff, IPMI_EVENT_CLASS_DISCRETE, "Module Hot Swap", "Quiesced" },
|
||||||
|
|
||||||
{ 0xC0, 0x00, 0xff, 0x00, "OEM", NULL },
|
{ 0xC0, 0x00, 0xff, 0x00, "OEM", "OEM Specific" },
|
||||||
|
|
||||||
{ 0x00, 0x00, 0x00, 0x00, NULL, NULL },
|
{ 0x00, 0x00, 0x00, 0x00, NULL, NULL },
|
||||||
};
|
};
|
||||||
|
@ -278,12 +278,13 @@ ipmi_sdr_get_sensor_reading(struct ipmi_intf *intf, uint8_t sensor)
|
|||||||
* @intf: ipmi interface
|
* @intf: ipmi interface
|
||||||
* @sensor: sensor id
|
* @sensor: sensor id
|
||||||
* @target: IPMB target address
|
* @target: IPMB target address
|
||||||
|
* @lun: sensor lun
|
||||||
*
|
*
|
||||||
* returns ipmi response structure
|
* returns ipmi response structure
|
||||||
*/
|
*/
|
||||||
struct ipmi_rs *
|
struct ipmi_rs *
|
||||||
ipmi_sdr_get_sensor_reading_ipmb(struct ipmi_intf *intf, uint8_t sensor,
|
ipmi_sdr_get_sensor_reading_ipmb(struct ipmi_intf *intf, uint8_t sensor,
|
||||||
uint8_t target)
|
uint8_t target, uint8_t lun)
|
||||||
{
|
{
|
||||||
struct ipmi_rq req;
|
struct ipmi_rq req;
|
||||||
struct ipmi_rs *rsp;
|
struct ipmi_rs *rsp;
|
||||||
@ -1449,13 +1450,27 @@ ipmi_sdr_print_discrete_state(const char *desc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (evt->offset > 7) {
|
if (evt->offset > 7) {
|
||||||
if ((1 << (evt->offset - 8)) & state2)
|
if ((1 << (evt->offset - 8)) & state2) {
|
||||||
printf(" [%s]\n",
|
if (evt->desc) {
|
||||||
evt->desc);
|
printf(" "
|
||||||
|
"[%s]\n",
|
||||||
|
evt->desc);
|
||||||
|
} else {
|
||||||
|
printf(" "
|
||||||
|
"[no description]\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if ((1 << evt->offset) & state1)
|
if ((1 << evt->offset) & state1) {
|
||||||
printf(" [%s]\n",
|
if (evt->desc) {
|
||||||
evt->desc);
|
printf(" "
|
||||||
|
"[%s]\n",
|
||||||
|
evt->desc);
|
||||||
|
} else {
|
||||||
|
printf(" "
|
||||||
|
"[no description]\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
c++;
|
c++;
|
||||||
}
|
}
|
||||||
@ -1490,21 +1505,30 @@ ipmi_sdr_print_sensor_compact(struct ipmi_intf *intf,
|
|||||||
desc, sensor->keys.sensor_num);
|
desc, sensor->keys.sensor_num);
|
||||||
validread = 0;
|
validread = 0;
|
||||||
}
|
}
|
||||||
else if (rsp->ccode > 0 && rsp->ccode != 0xcd) {
|
|
||||||
/* completion code 0xcd is special case */
|
else if (rsp->ccode > 0) {
|
||||||
lprintf(LOG_DEBUG, "Error reading sensor %s (#%02x): %s",
|
/* completion code 0xcd is special case */
|
||||||
desc, sensor->keys.sensor_num,
|
if (rsp->ccode == 0xcd) {
|
||||||
val2str(rsp->ccode, completion_code_vals));
|
/* sensor not found */
|
||||||
validread = 0;
|
validread = 0;
|
||||||
|
} else {
|
||||||
|
lprintf(LOG_DEBUG, "Error reading sensor %s (#%02x): %s",
|
||||||
|
desc, sensor->keys.sensor_num,
|
||||||
|
val2str(rsp->ccode, completion_code_vals));
|
||||||
|
validread = 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (IS_READING_UNAVAILABLE(rsp->data[1])) {
|
||||||
|
/* sensor reading unavailable */
|
||||||
|
validread = 0;
|
||||||
|
} else if (IS_SCANNING_DISABLED(rsp->data[1])) {
|
||||||
|
validread = 0;
|
||||||
|
/* check for sensor scanning disabled bit */
|
||||||
|
lprintf(LOG_DEBUG, "Sensor %s (#%02x) scanning disabled",
|
||||||
|
desc, sensor->keys.sensor_num);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check for sensor scanning disabled bit */
|
|
||||||
if (rsp && IS_SCANNING_DISABLED(rsp->data[1])) {
|
|
||||||
lprintf(LOG_DEBUG, "Sensor %s (#%02x) scanning disabled",
|
|
||||||
desc, sensor->keys.sensor_num);
|
|
||||||
validread = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
printf("Sensor ID : %s (0x%x)\n",
|
printf("Sensor ID : %s (0x%x)\n",
|
||||||
(sensor->id_code) ? desc : "", sensor->keys.sensor_num);
|
(sensor->id_code) ? desc : "", sensor->keys.sensor_num);
|
||||||
|
@ -102,7 +102,8 @@ ipmi_sensor_print_full_discrete(struct ipmi_intf *intf,
|
|||||||
*/
|
*/
|
||||||
rsp = ipmi_sdr_get_sensor_reading_ipmb(intf,
|
rsp = ipmi_sdr_get_sensor_reading_ipmb(intf,
|
||||||
sensor->keys.sensor_num,
|
sensor->keys.sensor_num,
|
||||||
sensor->keys.owner_id);
|
sensor->keys.owner_id,
|
||||||
|
sensor->keys.lun);
|
||||||
if (rsp == NULL) {
|
if (rsp == NULL) {
|
||||||
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);
|
||||||
@ -181,7 +182,8 @@ ipmi_sensor_print_full_analog(struct ipmi_intf *intf,
|
|||||||
*/
|
*/
|
||||||
rsp = ipmi_sdr_get_sensor_reading_ipmb(intf,
|
rsp = ipmi_sdr_get_sensor_reading_ipmb(intf,
|
||||||
sensor->keys.sensor_num,
|
sensor->keys.sensor_num,
|
||||||
sensor->keys.owner_id);
|
sensor->keys.owner_id,
|
||||||
|
sensor->keys.lun);
|
||||||
if (rsp == NULL) {
|
if (rsp == NULL) {
|
||||||
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);
|
||||||
@ -417,7 +419,8 @@ ipmi_sensor_print_compact(struct ipmi_intf *intf,
|
|||||||
*/
|
*/
|
||||||
rsp = ipmi_sdr_get_sensor_reading_ipmb(intf,
|
rsp = ipmi_sdr_get_sensor_reading_ipmb(intf,
|
||||||
sensor->keys.sensor_num,
|
sensor->keys.sensor_num,
|
||||||
sensor->keys.owner_id);
|
sensor->keys.owner_id,
|
||||||
|
sensor->keys.lun);
|
||||||
if (rsp == NULL) {
|
if (rsp == NULL) {
|
||||||
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);
|
||||||
@ -758,7 +761,8 @@ ipmi_sensor_get_reading(struct ipmi_intf *intf, int argc, char **argv)
|
|||||||
}
|
}
|
||||||
rsp = ipmi_sdr_get_sensor_reading_ipmb(intf,
|
rsp = ipmi_sdr_get_sensor_reading_ipmb(intf,
|
||||||
sdr->record.full->keys.sensor_num,
|
sdr->record.full->keys.sensor_num,
|
||||||
sdr->record.full->keys.owner_id);
|
sdr->record.full->keys.owner_id,
|
||||||
|
sdr->record.full->keys.lun);
|
||||||
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;
|
||||||
|
@ -221,6 +221,7 @@ sunoem_led_get(struct ipmi_intf * intf,
|
|||||||
|
|
||||||
req.msg.netfn = IPMI_NETFN_SUNOEM;
|
req.msg.netfn = IPMI_NETFN_SUNOEM;
|
||||||
req.msg.cmd = IPMI_SUNOEM_LED_GET;
|
req.msg.cmd = IPMI_SUNOEM_LED_GET;
|
||||||
|
req.msg.lun = dev->lun;
|
||||||
req.msg.data = rqdata;
|
req.msg.data = rqdata;
|
||||||
req.msg.data_len = rqdata_len;
|
req.msg.data_len = rqdata_len;
|
||||||
|
|
||||||
@ -273,6 +274,7 @@ sunoem_led_set(struct ipmi_intf * intf,
|
|||||||
|
|
||||||
req.msg.netfn = IPMI_NETFN_SUNOEM;
|
req.msg.netfn = IPMI_NETFN_SUNOEM;
|
||||||
req.msg.cmd = IPMI_SUNOEM_LED_SET;
|
req.msg.cmd = IPMI_SUNOEM_LED_SET;
|
||||||
|
req.msg.lun = dev->lun;
|
||||||
req.msg.data = rqdata;
|
req.msg.data = rqdata;
|
||||||
req.msg.data_len = rqdata_len;
|
req.msg.data_len = rqdata_len;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user