mirror of
https://github.com/ipmitool/ipmitool.git
synced 2026-01-21 16:42:19 +08:00
Added 'sdr fill sensors nosats' support to speed up SDR discovery
Added SDR name display during discovery (with -v)
This commit is contained in:
parent
ab48fc0f55
commit
9b56a57890
@ -882,6 +882,9 @@ uint8_t *ipmi_sdr_get_record(struct ipmi_intf *intf, struct sdr_get_rs *header,
|
||||
struct ipmi_sdr_iterator *i);
|
||||
void ipmi_sdr_end(struct ipmi_intf *intf, struct ipmi_sdr_iterator *i);
|
||||
int ipmi_sdr_print_sdr(struct ipmi_intf *intf, uint8_t type);
|
||||
|
||||
int ipmi_sdr_print_name_from_rawentry(struct ipmi_intf *intf,uint16_t id,
|
||||
uint8_t type,uint8_t * raw);
|
||||
int ipmi_sdr_print_rawentry(struct ipmi_intf *intf, uint8_t type, uint8_t * raw,
|
||||
int len);
|
||||
int ipmi_sdr_print_listentry(struct ipmi_intf *intf,
|
||||
|
||||
@ -1172,12 +1172,12 @@ ipmi_sdr_print_sensor_full(struct ipmi_intf *intf,
|
||||
/* Sensor Scanning Disabled */
|
||||
validread = 0;
|
||||
if (rsp->data[0] != 0) {
|
||||
/* we might still get a valid reading */
|
||||
/* we might still get a valid reading , but even 0 might be a valid reading */
|
||||
if (sensor->linearization>=SDR_SENSOR_L_NONLINEAR && sensor->linearization<=0x7F)
|
||||
ipmi_sensor_get_sensor_reading_factors(intf, sensor, rsp->data[0]);
|
||||
val = sdr_convert_sensor_reading(sensor,
|
||||
rsp->data[0]);
|
||||
if (val != 0.0)
|
||||
if (val != 0.0) /* .. an 0.0 might as well be valid */
|
||||
validread = 1;
|
||||
}
|
||||
} else {
|
||||
@ -1187,8 +1187,8 @@ ipmi_sdr_print_sensor_full(struct ipmi_intf *intf,
|
||||
validread = 0;
|
||||
}
|
||||
}
|
||||
/* convert RAW reading into units */
|
||||
val = sdr_convert_sensor_reading(sensor, rsp->data[0]);
|
||||
/* convert RAW reading into units */
|
||||
val = sdr_convert_sensor_reading(sensor, rsp->data[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2280,6 +2280,64 @@ ipmi_sdr_print_sensor_oem(struct ipmi_intf *intf, struct sdr_record_oem *oem)
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* ipmi_sdr_print_name_from_rawentry - Print SDR name from raw data
|
||||
*
|
||||
* @intf: ipmi interface
|
||||
* @type: sensor type
|
||||
* @raw: raw sensor data
|
||||
*
|
||||
* returns 0 on success
|
||||
* returns -1 on error
|
||||
*/
|
||||
int
|
||||
ipmi_sdr_print_name_from_rawentry(struct ipmi_intf *intf,uint16_t id,
|
||||
uint8_t type,uint8_t * raw)
|
||||
{
|
||||
union {
|
||||
struct sdr_record_full_sensor *full;
|
||||
struct sdr_record_compact_sensor *compact;
|
||||
struct sdr_record_eventonly_sensor *eventonly;
|
||||
struct sdr_record_generic_locator *genloc;
|
||||
struct sdr_record_fru_locator *fruloc;
|
||||
struct sdr_record_mc_locator *mcloc;
|
||||
struct sdr_record_entity_assoc *entassoc;
|
||||
struct sdr_record_oem *oem;
|
||||
} record;
|
||||
|
||||
int rc =0;
|
||||
char desc[17];
|
||||
memset(desc, ' ', sizeof (desc));
|
||||
|
||||
switch ( type) {
|
||||
case SDR_RECORD_TYPE_FULL_SENSOR:
|
||||
record.full = (struct sdr_record_full_sensor *) raw;
|
||||
snprintf(desc, (record.full->id_code & 0x1f) +1, "%s",
|
||||
(const char *)record.full->id_string);
|
||||
break;
|
||||
case SDR_RECORD_TYPE_COMPACT_SENSOR:
|
||||
record.compact = (struct sdr_record_compact_sensor *) raw ;
|
||||
snprintf(desc, (record.compact->id_code & 0x1f) +1, "%s",
|
||||
(const char *)record.compact->id_string);
|
||||
break;
|
||||
case SDR_RECORD_TYPE_EVENTONLY_SENSOR:
|
||||
record.eventonly = (struct sdr_record_eventonly_sensor *) raw ;
|
||||
snprintf(desc, (record.eventonly->id_code & 0x1f) +1, "%s",
|
||||
(const char *)record.eventonly->id_string);
|
||||
break;
|
||||
case SDR_RECORD_TYPE_MC_DEVICE_LOCATOR:
|
||||
record.mcloc = (struct sdr_record_mc_locator *) raw ;
|
||||
snprintf(desc, (record.mcloc->id_code & 0x1f) +1, "%s",
|
||||
(const char *)record.mcloc->id_string);
|
||||
break;
|
||||
default:
|
||||
rc = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
lprintf(LOG_INFO, "ID: 0x%04x , NAME: %-16s", id, desc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* ipmi_sdr_print_rawentry - Print SDR entry from raw data
|
||||
*
|
||||
* @intf: ipmi interface
|
||||
@ -2453,6 +2511,7 @@ ipmi_sdr_print_sdr(struct ipmi_intf *intf, uint8_t type)
|
||||
|
||||
rec = ipmi_sdr_get_record(intf, header, sdr_list_itr);
|
||||
if (rec == NULL) {
|
||||
lprintf(LOG_ERR, "ipmitool: ipmi_sdr_get_record() failed");
|
||||
rc = -1;
|
||||
continue;
|
||||
}
|
||||
@ -2500,6 +2559,8 @@ ipmi_sdr_print_sdr(struct ipmi_intf *intf, uint8_t type)
|
||||
continue;
|
||||
}
|
||||
|
||||
lprintf(LOG_DEBUG, "SDR record ID : 0x%04x", sdrr->id);
|
||||
|
||||
if (type == header->type || type == 0xff ||
|
||||
(type == 0xfe &&
|
||||
(header->type == SDR_RECORD_TYPE_FULL_SENSOR ||
|
||||
@ -2656,6 +2717,17 @@ ipmi_sdr_start(struct ipmi_intf *intf, int use_builtin)
|
||||
|
||||
lprintf(LOG_DEBUG, "SDR free space: %d", sdr_info.free);
|
||||
lprintf(LOG_DEBUG, "SDR records : %d", sdr_info.count);
|
||||
|
||||
/* Build SDRR if there is no record in repository */
|
||||
if( sdr_info.count == 0 ) {
|
||||
lprintf(LOG_DEBUG, "Rebuilding SDRR...");
|
||||
|
||||
if( ipmi_sdr_add_from_sensors( intf, 0 ) != 0 ) {
|
||||
lprintf(LOG_ERR, "Could not build SDRR!");
|
||||
free(itr);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
struct sdr_device_info_rs sdr_info;
|
||||
/* get device sdr info */
|
||||
@ -4325,6 +4397,9 @@ ipmi_sdr_main(struct ipmi_intf *intf, int argc, char **argv)
|
||||
lprintf(LOG_ERR, " fill");
|
||||
lprintf(LOG_ERR,
|
||||
" sensors Creates the SDR repository for the current configuration");
|
||||
lprintf(LOG_ERR,
|
||||
" nosat Creates the SDR repository for the current configuration, without satellite scan");
|
||||
|
||||
lprintf(LOG_ERR,
|
||||
" file <file> Load SDR repository from a file");
|
||||
} else if (strncmp(argv[0], "list", 4) == 0
|
||||
@ -4382,6 +4457,8 @@ ipmi_sdr_main(struct ipmi_intf *intf, int argc, char **argv)
|
||||
rc = -1;
|
||||
} else if (strncmp(argv[1], "sensors", 7) == 0) {
|
||||
rc = ipmi_sdr_add_from_sensors(intf, 21);
|
||||
} else if (strncmp(argv[1], "nosats", 6) == 0) {
|
||||
rc = ipmi_sdr_add_from_sensors(intf, 0);
|
||||
} else if (strncmp(argv[1], "file", 4) == 0) {
|
||||
if (argc < 3) {
|
||||
lprintf(LOG_ERR, "sdr fill: Missing filename");
|
||||
|
||||
@ -101,11 +101,15 @@ ipmi_sdr_add_record(struct ipmi_intf *intf, struct sdr_record_list *sdrr)
|
||||
int rc = 0;
|
||||
|
||||
/* actually no SDR to program */
|
||||
if (len < 1 || !sdrr->raw)
|
||||
if (len < 1 || !sdrr->raw) {
|
||||
lprintf(LOG_ERR, "ipmitool: bad record , skipped");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ipmi_sdr_get_reservation(intf, 0, &reserve_id))
|
||||
if (ipmi_sdr_get_reservation(intf, 0, &reserve_id)) {
|
||||
lprintf(LOG_ERR, "ipmitool: reservation failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
sdr_rq = (struct sdr_add_rq *)malloc(sizeof(*sdr_rq) + sdr_max_write_len);
|
||||
if (sdr_rq == NULL) {
|
||||
@ -131,6 +135,7 @@ ipmi_sdr_add_record(struct ipmi_intf *intf, struct sdr_record_list *sdrr)
|
||||
req.msg.data_len = 5 + sizeof(*sdr_rq) - 1;
|
||||
|
||||
if (partial_send(intf, &req, &id)) {
|
||||
lprintf(LOG_ERR, "ipmitool: partial send error");
|
||||
free(sdr_rq);
|
||||
return -1;
|
||||
}
|
||||
@ -139,11 +144,8 @@ ipmi_sdr_add_record(struct ipmi_intf *intf, struct sdr_record_list *sdrr)
|
||||
|
||||
/* sdr entry */
|
||||
while (i < len) {
|
||||
int data_len = 0;
|
||||
|
||||
/* JMA - Add = here since it was not setting the bit when lenght was fitting
|
||||
boundary. This was causing some sensors to be rejected from SDRR */
|
||||
if (len - i <= sdr_max_write_len) {
|
||||
int data_len = 0;
|
||||
if ( (len - i) <= sdr_max_write_len) {
|
||||
/* last crunch */
|
||||
data_len = len - i;
|
||||
sdr_rq->in_progress = LAST_RECORD;
|
||||
@ -157,11 +159,13 @@ ipmi_sdr_add_record(struct ipmi_intf *intf, struct sdr_record_list *sdrr)
|
||||
req.msg.data_len = data_len + sizeof(*sdr_rq) - 1;
|
||||
|
||||
if ((rc = partial_send(intf, &req, &id)) != 0) {
|
||||
lprintf(LOG_ERR, "ipmitool: partial add failed");
|
||||
break;
|
||||
}
|
||||
|
||||
i += data_len;
|
||||
}
|
||||
|
||||
free(sdr_rq);
|
||||
return rc;
|
||||
}
|
||||
@ -248,11 +252,13 @@ sdrr_get_records(struct ipmi_intf *intf, struct ipmi_sdr_iterator *itr,
|
||||
return -1;
|
||||
}
|
||||
memset(sdrr, 0, sizeof (struct sdr_record_list));
|
||||
|
||||
sdrr->id = header->id;
|
||||
sdrr->version = header->version;
|
||||
sdrr->type = header->type;
|
||||
sdrr->length = header->length;
|
||||
sdrr->raw = ipmi_sdr_get_record(intf, header, itr);
|
||||
(void)ipmi_sdr_print_name_from_rawentry(intf, sdrr->id, sdrr->type,sdrr->raw);
|
||||
|
||||
/* put in the record queue */
|
||||
if (queue->head == NULL)
|
||||
@ -276,6 +282,8 @@ sdr_copy_to_sdrr(struct ipmi_intf *intf, int use_builtin,
|
||||
|
||||
/* generate list of records for this target */
|
||||
intf->target_addr = from_addr;
|
||||
|
||||
/* initialize iterator */
|
||||
itr = ipmi_sdr_start(intf, use_builtin);
|
||||
if (itr == 0)
|
||||
return 0;
|
||||
@ -283,6 +291,7 @@ sdr_copy_to_sdrr(struct ipmi_intf *intf, int use_builtin,
|
||||
printf("Load SDRs from 0x%x\n", from_addr);
|
||||
rc = sdrr_get_records(intf, itr, &sdrr_queue);
|
||||
ipmi_sdr_end(intf, itr);
|
||||
/* ... */
|
||||
|
||||
/* write the SDRs to the destination SDR Repository */
|
||||
intf->target_addr = to_addr;
|
||||
@ -314,13 +323,15 @@ ipmi_sdr_add_from_sensors(struct ipmi_intf *intf, int maxslot)
|
||||
rc = sdr_copy_to_sdrr(intf, 1, myaddr, myaddr);
|
||||
|
||||
/* Now fill the SDRR with remote sensors */
|
||||
for (i = 0, slave_addr = 0xB0; i < maxslot; i++, slave_addr += 2) {
|
||||
/* Hole in the PICMG 2.9 mapping */
|
||||
if (slave_addr == 0xC2) slave_addr += 2;
|
||||
if(sdr_copy_to_sdrr(intf, 0, slave_addr, myaddr) < 0)
|
||||
{
|
||||
rc = -1;
|
||||
}
|
||||
if( maxslot != 0 ) {
|
||||
for (i = 0, slave_addr = 0xB0; i < maxslot; i++, slave_addr += 2) {
|
||||
/* Hole in the PICMG 2.9 mapping */
|
||||
if (slave_addr == 0xC2) slave_addr += 2;
|
||||
if(sdr_copy_to_sdrr(intf, 0, slave_addr, myaddr) < 0)
|
||||
{
|
||||
rc = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user