mirror of
https://github.com/ipmitool/ipmitool.git
synced 2025-05-10 18:47:22 +00:00
Fixes ID:3421347 Sensor list command should use channel field from SDR
Running an "ipmitool sensor list" command on a system where remote sensors are not on channel 0 results in unexpected behavior. The SDR functions were fixed in January of 2009 (lib/ipmi_sdr.c, rev 1.86) to use target I2C addresses and LUNs for non-BMC-owned sensors. Sensors owned by satellite controllers on other channels were read as if they were on channel 0. I've fitted patch, posted alongside bug report, to CVS version.
This commit is contained in:
parent
09fc12a929
commit
904cbebce5
@ -912,13 +912,14 @@ struct ipmi_rs *ipmi_sdr_get_sensor_reading(struct ipmi_intf *intf,
|
||||
struct ipmi_rs *ipmi_sdr_get_sensor_reading_ipmb(struct ipmi_intf *intf,
|
||||
uint8_t sensor,
|
||||
uint8_t target,
|
||||
uint8_t lun);
|
||||
uint8_t lun,
|
||||
uint8_t channel);
|
||||
struct ipmi_rs *ipmi_sdr_get_sensor_thresholds(struct ipmi_intf *intf,
|
||||
uint8_t sensor,
|
||||
uint8_t target, uint8_t lun);
|
||||
uint8_t target, uint8_t lun, uint8_t channel);
|
||||
struct ipmi_rs *ipmi_sdr_get_sensor_hysteresis(struct ipmi_intf *intf,
|
||||
uint8_t sensor,
|
||||
uint8_t target, uint8_t lun);
|
||||
uint8_t target, uint8_t lun, uint8_t channel);
|
||||
const char *ipmi_sdr_get_sensor_type_desc(const uint8_t type);
|
||||
int ipmi_sdr_get_reservation(struct ipmi_intf *intf, int use_builtin,
|
||||
uint16_t * reserve_id);
|
||||
@ -962,10 +963,10 @@ void ipmi_sdr_print_discrete_state_mini(const char *separator,
|
||||
int ipmi_sdr_print_sensor_event_status(struct ipmi_intf *intf,
|
||||
uint8_t sensor_num, uint8_t sensor_type,
|
||||
uint8_t event_type, int numeric_fmt,
|
||||
uint8_t target, uint8_t lun);
|
||||
uint8_t target, uint8_t lun, uint8_t channel);
|
||||
int ipmi_sdr_print_sensor_event_enable(struct ipmi_intf *intf,
|
||||
uint8_t sensor_num, uint8_t sensor_type,
|
||||
uint8_t event_type, int numeric_fmt,
|
||||
uint8_t target, uint8_t lun);
|
||||
uint8_t target, uint8_t lun, uint8_t channel);
|
||||
|
||||
#endif /* IPMI_SDR_H */
|
||||
|
@ -3610,7 +3610,8 @@ static int ipmi_get_power_consumption_data(struct ipmi_intf* intf,uint8_t unit)
|
||||
rsp = ipmi_sdr_get_sensor_thresholds(intf,
|
||||
sdr->record.full->keys.sensor_num,
|
||||
sdr->record.full->keys.owner_id,
|
||||
sdr->record.full->keys.lun);
|
||||
sdr->record.full->keys.lun,
|
||||
sdr->record.full->keys.channel);
|
||||
|
||||
if (rsp != NULL && rsp->ccode == 0)
|
||||
{
|
||||
|
@ -241,7 +241,7 @@ ipmi_event_fromsensor(struct ipmi_intf * intf, char * id, char * state, char * e
|
||||
struct sdr_record_list * sdr;
|
||||
struct platform_event_msg emsg;
|
||||
int off;
|
||||
uint8_t target, lun;
|
||||
uint8_t target, lun, channel;
|
||||
|
||||
if (id == NULL) {
|
||||
lprintf(LOG_ERR, "No sensor ID supplied");
|
||||
@ -279,6 +279,7 @@ ipmi_event_fromsensor(struct ipmi_intf * intf, char * id, char * state, char * e
|
||||
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:
|
||||
@ -288,6 +289,7 @@ ipmi_event_fromsensor(struct ipmi_intf * intf, char * id, char * state, char * e
|
||||
emsg.event_type = sdr->record.compact->event_type;
|
||||
target = sdr->record.compact->keys.owner_id;
|
||||
lun = sdr->record.compact->keys.lun;
|
||||
channel = sdr->record.compact->keys.channel;
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -353,7 +355,7 @@ ipmi_event_fromsensor(struct ipmi_intf * intf, char * id, char * state, char * e
|
||||
}
|
||||
|
||||
rsp = ipmi_sdr_get_sensor_thresholds(intf, emsg.sensor_num,
|
||||
target, lun);
|
||||
target, lun, channel);
|
||||
|
||||
if (rsp != NULL && rsp->ccode == 0) {
|
||||
|
||||
@ -361,7 +363,7 @@ ipmi_event_fromsensor(struct ipmi_intf * intf, char * id, char * state, char * e
|
||||
emsg.event_data[2] = rsp->data[(emsg.event_data[0] / 2) + 1];
|
||||
|
||||
rsp = ipmi_sdr_get_sensor_hysteresis(intf, emsg.sensor_num,
|
||||
target, lun);
|
||||
target, lun, channel);
|
||||
if (rsp != NULL && rsp->ccode == 0)
|
||||
off = dir ? rsp->data[0] : rsp->data[1];
|
||||
if (off <= 0)
|
||||
|
@ -366,19 +366,23 @@ sdr_convert_sensor_value_to_raw(struct sdr_record_full_sensor * sensor,
|
||||
* @sensor: sensor number
|
||||
* @target: sensor owner ID
|
||||
* @lun: sensor lun
|
||||
* @channel: channel number
|
||||
*
|
||||
* returns pointer to ipmi response
|
||||
*/
|
||||
struct ipmi_rs *
|
||||
ipmi_sdr_get_sensor_thresholds(struct ipmi_intf *intf, uint8_t sensor,
|
||||
uint8_t target, uint8_t lun)
|
||||
uint8_t target, uint8_t lun, uint8_t channel)
|
||||
{
|
||||
struct ipmi_rq req;
|
||||
struct ipmi_rs *rsp;
|
||||
uint8_t save_addr;
|
||||
uint8_t save_channel;
|
||||
|
||||
save_addr = intf->target_addr;
|
||||
intf->target_addr = target;
|
||||
save_channel = intf->target_channel;
|
||||
intf->target_channel = channel;
|
||||
|
||||
memset(&req, 0, sizeof (req));
|
||||
req.msg.netfn = IPMI_NETFN_SE;
|
||||
@ -388,6 +392,7 @@ ipmi_sdr_get_sensor_thresholds(struct ipmi_intf *intf, uint8_t sensor,
|
||||
|
||||
rsp = intf->sendrecv(intf, &req);
|
||||
intf->target_addr = save_addr;
|
||||
intf->target_channel = save_channel;
|
||||
return rsp;
|
||||
}
|
||||
|
||||
@ -397,20 +402,24 @@ ipmi_sdr_get_sensor_thresholds(struct ipmi_intf *intf, uint8_t sensor,
|
||||
* @sensor: sensor number
|
||||
* @target: sensor owner ID
|
||||
* @lun: sensor lun
|
||||
* @channel: channel number
|
||||
*
|
||||
* returns pointer to ipmi response
|
||||
*/
|
||||
struct ipmi_rs *
|
||||
ipmi_sdr_get_sensor_hysteresis(struct ipmi_intf *intf, uint8_t sensor,
|
||||
uint8_t target, uint8_t lun)
|
||||
uint8_t target, uint8_t lun, uint8_t channel)
|
||||
{
|
||||
struct ipmi_rq req;
|
||||
uint8_t rqdata[2];
|
||||
struct ipmi_rs *rsp;
|
||||
uint8_t save_addr;
|
||||
uint8_t save_channel;
|
||||
|
||||
save_addr = intf->target_addr;
|
||||
intf->target_addr = target;
|
||||
save_channel = intf->target_channel;
|
||||
intf->target_channel = channel;
|
||||
|
||||
rqdata[0] = sensor;
|
||||
rqdata[1] = 0xff; /* reserved */
|
||||
@ -423,6 +432,7 @@ ipmi_sdr_get_sensor_hysteresis(struct ipmi_intf *intf, uint8_t sensor,
|
||||
|
||||
rsp = intf->sendrecv(intf, &req);
|
||||
intf->target_addr = save_addr;
|
||||
intf->target_channel = save_channel;
|
||||
return rsp;
|
||||
}
|
||||
|
||||
@ -452,23 +462,27 @@ ipmi_sdr_get_sensor_reading(struct ipmi_intf *intf, uint8_t sensor)
|
||||
* @intf: ipmi interface
|
||||
* @sensor: sensor id
|
||||
* @target: IPMB target address
|
||||
* @lun: sensor lun
|
||||
* @lun: sensor lun
|
||||
* @channel: channel number
|
||||
*
|
||||
* returns ipmi response structure
|
||||
*/
|
||||
struct ipmi_rs *
|
||||
ipmi_sdr_get_sensor_reading_ipmb(struct ipmi_intf *intf, uint8_t sensor,
|
||||
uint8_t target, uint8_t lun)
|
||||
uint8_t target, uint8_t lun, uint8_t channel)
|
||||
{
|
||||
struct ipmi_rq req;
|
||||
struct ipmi_rs *rsp;
|
||||
uint8_t save_addr;
|
||||
uint8_t save_channel;
|
||||
|
||||
if ((strncmp(intf->name, "ipmb", 4)) != 0)
|
||||
return ipmi_sdr_get_sensor_reading(intf, sensor);
|
||||
|
||||
save_addr = intf->target_addr;
|
||||
intf->target_addr = target;
|
||||
save_channel = intf->target_channel;
|
||||
intf->target_channel = channel;
|
||||
|
||||
memset(&req, 0, sizeof (req));
|
||||
req.msg.netfn = IPMI_NETFN_SE;
|
||||
@ -478,6 +492,7 @@ ipmi_sdr_get_sensor_reading_ipmb(struct ipmi_intf *intf, uint8_t sensor,
|
||||
|
||||
rsp = intf->sendrecv(intf, &req);
|
||||
intf->target_addr = save_addr;
|
||||
intf->target_channel = save_channel;
|
||||
return rsp;
|
||||
}
|
||||
|
||||
@ -487,19 +502,23 @@ ipmi_sdr_get_sensor_reading_ipmb(struct ipmi_intf *intf, uint8_t sensor,
|
||||
* @sensor: sensor id
|
||||
* @target: sensor owner ID
|
||||
* @lun: sensor lun
|
||||
* @channel: channel number
|
||||
*
|
||||
* returns ipmi response structure
|
||||
*/
|
||||
struct ipmi_rs *
|
||||
ipmi_sdr_get_sensor_event_status(struct ipmi_intf *intf, uint8_t sensor,
|
||||
uint8_t target, uint8_t lun)
|
||||
uint8_t target, uint8_t lun, uint8_t channel)
|
||||
{
|
||||
struct ipmi_rq req;
|
||||
struct ipmi_rs *rsp;
|
||||
uint8_t save_addr;
|
||||
uint8_t save_channel;
|
||||
|
||||
save_addr = intf->target_addr;
|
||||
intf->target_addr = target;
|
||||
save_channel = intf->target_channel;
|
||||
intf->target_channel = channel;
|
||||
|
||||
memset(&req, 0, sizeof (req));
|
||||
req.msg.netfn = IPMI_NETFN_SE;
|
||||
@ -509,6 +528,7 @@ ipmi_sdr_get_sensor_event_status(struct ipmi_intf *intf, uint8_t sensor,
|
||||
|
||||
rsp = intf->sendrecv(intf, &req);
|
||||
intf->target_addr = save_addr;
|
||||
intf->target_channel = save_channel;
|
||||
return rsp;
|
||||
}
|
||||
|
||||
@ -518,19 +538,23 @@ ipmi_sdr_get_sensor_event_status(struct ipmi_intf *intf, uint8_t sensor,
|
||||
* @sensor: sensor id
|
||||
* @target: sensor owner ID
|
||||
* @lun: sensor lun
|
||||
* @channel: channel number
|
||||
*
|
||||
* returns ipmi response structure
|
||||
*/
|
||||
struct ipmi_rs *
|
||||
ipmi_sdr_get_sensor_event_enable(struct ipmi_intf *intf, uint8_t sensor,
|
||||
uint8_t target, uint8_t lun)
|
||||
uint8_t target, uint8_t lun, uint8_t channel)
|
||||
{
|
||||
struct ipmi_rq req;
|
||||
struct ipmi_rs *rsp;
|
||||
uint8_t save_addr;
|
||||
uint8_t save_channel;
|
||||
|
||||
save_addr = intf->target_addr;
|
||||
intf->target_addr = target;
|
||||
save_channel = intf->target_channel;
|
||||
intf->target_channel = channel;
|
||||
|
||||
memset(&req, 0, sizeof (req));
|
||||
req.msg.netfn = IPMI_NETFN_SE;
|
||||
@ -540,6 +564,7 @@ ipmi_sdr_get_sensor_event_enable(struct ipmi_intf *intf, uint8_t sensor,
|
||||
|
||||
rsp = intf->sendrecv(intf, &req);
|
||||
intf->target_addr = save_addr;
|
||||
intf->target_channel = save_channel;
|
||||
return rsp;
|
||||
}
|
||||
|
||||
@ -786,7 +811,7 @@ ipmi_sdr_print_sensor_event_status(struct ipmi_intf *intf,
|
||||
uint8_t sensor_num,
|
||||
uint8_t sensor_type,
|
||||
uint8_t event_type, int numeric_fmt,
|
||||
uint8_t target, uint8_t lun)
|
||||
uint8_t target, uint8_t lun, uint8_t channel)
|
||||
{
|
||||
struct ipmi_rs *rsp;
|
||||
int i;
|
||||
@ -810,7 +835,7 @@ ipmi_sdr_print_sensor_event_status(struct ipmi_intf *intf,
|
||||
};
|
||||
|
||||
rsp = ipmi_sdr_get_sensor_event_status(intf, sensor_num,
|
||||
target, lun);
|
||||
target, lun, channel);
|
||||
|
||||
if (rsp == NULL) {
|
||||
lprintf(LOG_DEBUG,
|
||||
@ -998,7 +1023,7 @@ ipmi_sdr_print_sensor_event_enable(struct ipmi_intf *intf,
|
||||
uint8_t sensor_num,
|
||||
uint8_t sensor_type,
|
||||
uint8_t event_type, int numeric_fmt,
|
||||
uint8_t target, uint8_t lun)
|
||||
uint8_t target, uint8_t lun, uint8_t channel)
|
||||
{
|
||||
struct ipmi_rs *rsp;
|
||||
int i;
|
||||
@ -1022,7 +1047,7 @@ ipmi_sdr_print_sensor_event_enable(struct ipmi_intf *intf,
|
||||
};
|
||||
|
||||
rsp = ipmi_sdr_get_sensor_event_enable(intf, sensor_num,
|
||||
target, lun);
|
||||
target, lun, channel);
|
||||
|
||||
if (rsp == NULL) {
|
||||
lprintf(LOG_DEBUG,
|
||||
@ -1133,13 +1158,14 @@ ipmi_sdr_print_sensor_full(struct ipmi_intf *intf,
|
||||
int i = 0, validread = 1, do_unit = 1;
|
||||
double val = 0.0, creading = 0.0;
|
||||
struct ipmi_rs *rsp;
|
||||
uint8_t target, lun;
|
||||
uint8_t target, lun, channel;
|
||||
|
||||
if (sensor == NULL)
|
||||
return -1;
|
||||
|
||||
target = sensor->keys.owner_id;
|
||||
lun = sensor->keys.lun;
|
||||
channel = sensor->keys.channel;
|
||||
|
||||
memset(desc, 0, sizeof (desc));
|
||||
snprintf(desc, (sensor->id_code & 0x1f) + 1, "%s", sensor->id_string);
|
||||
@ -1148,7 +1174,7 @@ ipmi_sdr_print_sensor_full(struct ipmi_intf *intf,
|
||||
|
||||
/* get sensor reading */
|
||||
rsp = ipmi_sdr_get_sensor_reading_ipmb(intf, sensor->keys.sensor_num,
|
||||
sensor->keys.owner_id, sensor->keys.lun);
|
||||
sensor->keys.owner_id, sensor->keys.lun, sensor->keys.channel);
|
||||
|
||||
if (rsp == NULL) {
|
||||
lprintf(LOG_DEBUG, "Error reading sensor %s (#%02x)",
|
||||
@ -1382,14 +1408,16 @@ ipmi_sdr_print_sensor_full(struct ipmi_intf *intf,
|
||||
sensor->event_type,
|
||||
DISCRETE_SENSOR,
|
||||
target,
|
||||
lun);
|
||||
lun,
|
||||
channel);
|
||||
ipmi_sdr_print_sensor_event_enable(intf,
|
||||
sensor->keys.sensor_num,
|
||||
sensor->sensor.type,
|
||||
sensor->event_type,
|
||||
DISCRETE_SENSOR,
|
||||
target,
|
||||
lun);
|
||||
lun,
|
||||
channel);
|
||||
printf(" OEM : %X\n",
|
||||
sensor->oem);
|
||||
printf("\n");
|
||||
@ -1562,14 +1590,14 @@ ipmi_sdr_print_sensor_full(struct ipmi_intf *intf,
|
||||
sensor->sensor.type,
|
||||
sensor->event_type, ANALOG_SENSOR,
|
||||
target,
|
||||
lun);
|
||||
lun, channel);
|
||||
|
||||
ipmi_sdr_print_sensor_event_enable(intf,
|
||||
sensor->keys.sensor_num,
|
||||
sensor->sensor.type,
|
||||
sensor->event_type, ANALOG_SENSOR,
|
||||
target,
|
||||
lun);
|
||||
lun, channel);
|
||||
|
||||
printf("\n");
|
||||
return 0;
|
||||
@ -1718,20 +1746,21 @@ ipmi_sdr_print_sensor_compact(struct ipmi_intf *intf,
|
||||
struct ipmi_rs *rsp;
|
||||
char desc[17];
|
||||
int validread = 1;
|
||||
uint8_t target, lun;
|
||||
uint8_t target, lun, channel;
|
||||
|
||||
if (sensor == NULL)
|
||||
return -1;
|
||||
|
||||
target = sensor->keys.owner_id;
|
||||
lun = sensor->keys.lun;
|
||||
channel = sensor->keys.channel;
|
||||
|
||||
memset(desc, 0, sizeof (desc));
|
||||
snprintf(desc, (sensor->id_code & 0x1f) + 1, "%s", sensor->id_string);
|
||||
|
||||
/* get sensor reading */
|
||||
rsp = ipmi_sdr_get_sensor_reading_ipmb(intf, sensor->keys.sensor_num,
|
||||
sensor->keys.owner_id, sensor->keys.lun);
|
||||
sensor->keys.owner_id, sensor->keys.lun, sensor->keys.channel);
|
||||
if (rsp == NULL) {
|
||||
lprintf(LOG_DEBUG, "Error reading sensor %s (#%02x)",
|
||||
desc, sensor->keys.sensor_num);
|
||||
@ -1791,14 +1820,16 @@ ipmi_sdr_print_sensor_compact(struct ipmi_intf *intf,
|
||||
sensor->event_type,
|
||||
DISCRETE_SENSOR,
|
||||
target,
|
||||
lun);
|
||||
lun,
|
||||
channel);
|
||||
ipmi_sdr_print_sensor_event_enable(intf,
|
||||
sensor->keys.sensor_num,
|
||||
sensor->sensor.type,
|
||||
sensor->event_type,
|
||||
DISCRETE_SENSOR,
|
||||
target,
|
||||
lun);
|
||||
lun,
|
||||
channel);
|
||||
printf(" OEM : %X\n",
|
||||
sensor->oem);
|
||||
printf("\n");
|
||||
|
@ -163,7 +163,8 @@ ipmi_sensor_print_full_discrete(struct ipmi_intf *intf,
|
||||
rsp = ipmi_sdr_get_sensor_reading_ipmb(intf,
|
||||
sensor->keys.sensor_num,
|
||||
sensor->keys.owner_id,
|
||||
sensor->keys.lun);
|
||||
sensor->keys.lun,
|
||||
sensor->keys.channel);
|
||||
if (rsp == NULL) {
|
||||
lprintf(LOG_ERR, "Error reading sensor %s (#%02x)",
|
||||
id, sensor->keys.sensor_num);
|
||||
@ -246,7 +247,8 @@ ipmi_sensor_print_full_analog(struct ipmi_intf *intf,
|
||||
rsp = ipmi_sdr_get_sensor_reading_ipmb(intf,
|
||||
sensor->keys.sensor_num,
|
||||
sensor->keys.owner_id,
|
||||
sensor->keys.lun);
|
||||
sensor->keys.lun,
|
||||
sensor->keys.channel);
|
||||
if (rsp == NULL) {
|
||||
lprintf(LOG_ERR, "Error reading sensor %s (#%02x)",
|
||||
id, sensor->keys.sensor_num);
|
||||
@ -298,7 +300,7 @@ ipmi_sensor_print_full_analog(struct ipmi_intf *intf,
|
||||
* Get sensor thresholds
|
||||
*/
|
||||
rsp = ipmi_sdr_get_sensor_thresholds(intf, sensor->keys.sensor_num,
|
||||
sensor->keys.owner_id, sensor->keys.lun);
|
||||
sensor->keys.owner_id, sensor->keys.lun, sensor->keys.channel);
|
||||
if ((rsp == NULL) || (rsp->ccode > 0))
|
||||
thresh_available = 0;
|
||||
|
||||
@ -470,7 +472,8 @@ ipmi_sensor_print_full_analog(struct ipmi_intf *intf,
|
||||
sensor->event_type,
|
||||
ANALOG_SENSOR,
|
||||
sensor->keys.owner_id,
|
||||
sensor->keys.lun);
|
||||
sensor->keys.lun,
|
||||
sensor->keys.channel);
|
||||
ipmi_sdr_print_sensor_event_enable(intf,
|
||||
sensor->keys.
|
||||
sensor_num,
|
||||
@ -478,7 +481,8 @@ ipmi_sensor_print_full_analog(struct ipmi_intf *intf,
|
||||
sensor->event_type,
|
||||
ANALOG_SENSOR,
|
||||
sensor->keys.owner_id,
|
||||
sensor->keys.lun);
|
||||
sensor->keys.lun,
|
||||
sensor->keys.channel);
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
@ -519,7 +523,8 @@ ipmi_sensor_print_compact(struct ipmi_intf *intf,
|
||||
rsp = ipmi_sdr_get_sensor_reading_ipmb(intf,
|
||||
sensor->keys.sensor_num,
|
||||
sensor->keys.owner_id,
|
||||
sensor->keys.lun);
|
||||
sensor->keys.lun,
|
||||
sensor->keys.channel);
|
||||
if (rsp == NULL) {
|
||||
lprintf(LOG_ERR, "Error reading sensor %s (#%02x)",
|
||||
id, sensor->keys.sensor_num);
|
||||
@ -893,7 +898,8 @@ ipmi_sensor_get_reading(struct ipmi_intf *intf, int argc, char **argv)
|
||||
rsp = ipmi_sdr_get_sensor_reading_ipmb(intf,
|
||||
sdr->record.full->keys.sensor_num,
|
||||
sdr->record.full->keys.owner_id,
|
||||
sdr->record.full->keys.lun);
|
||||
sdr->record.full->keys.lun,
|
||||
sdr->record.full->keys.channel);
|
||||
if (rsp == NULL) {
|
||||
lprintf(LOG_ERR, "Error reading sensor \"%s\"", argv[i]);
|
||||
rc = -1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user