Commit 6815b1f6 authored by Michael Ott's avatar Michael Ott
Browse files

Rename start and stop parameters to lsb and msb

parent a3504758
......@@ -302,13 +302,13 @@ Explanation of the values specific for the IPMI plugin:
| ipmiversion | IPMI version to use for LAN connections (1 or 2)
| cipher | Cipher to use for IPMI 2.0 LAN connections (currently supported: 0, 1, 2, 3, 6, 7, 8, 11, 12)
| cmd | One can define a raw IPMI-command (in hex-notation) to be sent. In this case also the start and stop fields for the response have to be defined. Alternatively, one can define the record-ID of the sensor (see below).
| start | Offset where the wanted return value of an IPMI raw command starts at in the IPMI response<sup>[1](#ipmifn1)</sup>
| stop | Offset where the wanted return value of an IPMI raw command stops at in the IPMI response<sup>[1](#ipmifn1)</sup>
| lsb | Offset where the least significant byte of the wanted return value of an IPMI raw command in the IPMI response<sup>[1](#ipmifn1)</sup>
| msb | Offset where the most significant byte of the wanted return value of an IPMI raw command in the IPMI response<sup>[1](#ipmifn1)</sup>
| recordId | Define the record-ID of the sensor to be read. One can look up the corresponding record-IDs for every sensor with the "ipmi-sensors" command line tool (ships with the freeipmi-library). Alternatively, one can define a raw IPMI-command (see above).
| factor | One can specify a factor to scale the read value before it is stored in the database (to adjust precision).
#### Footnotes <a name="ipmiFootnotes"></a>
<a name="ipmifn1">**1**</a>: &ensp; Use start > stop values if response is Little-endian (LSB first), use start < stop if response is Big-Endian (MSB first). Maximum length is 8 bytes.
<a name="ipmifn1">**1**</a>: &ensp; Use lsb > msb values if response is Little-endian (LSB first), use lsb < msb values if response is Big-Endian (MSB first). Maximum length is 8 bytes.
## Perf-event <a name="perf"></a>
The Perfevent functionality is tasked with collecting data from the CPUs various performance counters (PMUs).
......
......@@ -26,21 +26,21 @@ IPMIConfigurator::~IPMIConfigurator() {}
void IPMIConfigurator::sensorBase(IPMISensorBase& s, CFG_VAL config) {
ADD {
ATTRIBUTE("cmd", setRawCmd);
ATTRIBUTE("start", setStart);
ATTRIBUTE("stop", setStop);
ATTRIBUTE("lsb", setLsb);
ATTRIBUTE("msb", setMsb);
ATTRIBUTE("recordId", setRecordId);
ATTRIBUTE("factor", setFactor);
}
if (s.getStart() < s.getStop()) {
if (s.getStop() - s.getStart() >= 8) {
s.setStop(s.getStart() + 7);
LOG(warning) << "Maximum length of IPMI raw response interval is 8 bytes, setting stop offset to " << (int) s.getStop();
if (s.getLsb() < s.getMsb()) {
if (s.getMsb() - s.getLsb() >= 8) {
s.setMsb(s.getLsb() + 7);
LOG(warning) << "Maximum length of IPMI raw response interval is 8 bytes, setting msb offset to " << (int) s.getMsb();
}
} else {
if (s.getStart() - s.getStop() >= 8) {
s.setStart(s.getStop() + 7);
LOG(warning) << "Maximum length of IPMI raw response interval is 8 bytes, setting start offset to " << (int) s.getStart();
if (s.getLsb() - s.getMsb() >= 8) {
s.setLsb(s.getMsb() + 7);
LOG(warning) << "Maximum length of IPMI raw response interval is 8 bytes, setting lsb offset to " << (int) s.getLsb();
}
}
......
......@@ -151,8 +151,7 @@ bool IPMIHost::getSdrRecord(uint16_t recordId, std::vector<uint8_t>& record) {
return success;
}
int64_t IPMIHost::sendRawCmd(const std::vector<uint8_t>& rawCmd,
uint16_t start, uint16_t stop) {
int64_t IPMIHost::sendRawCmd(const std::vector<uint8_t>& rawCmd, uint8_t lsb, uint8_t msb) {
uint8_t buf[256];
int len = -1;
int i;
......@@ -192,9 +191,9 @@ int64_t IPMIHost::sendRawCmd(const std::vector<uint8_t>& rawCmd,
return 0;
}
if (stop > len) {
if (msb > len) {
std::stringstream ss;
ss << "Error processing IPMI raw data: stop=" << stop << " > len=" << len;
ss << "Error processing IPMI raw data: stop=" << msb << " > len=" << len;
throw std::runtime_error(ss.str());
return 0;
}
......@@ -202,13 +201,13 @@ int64_t IPMIHost::sendRawCmd(const std::vector<uint8_t>& rawCmd,
_errorCount = 0;
int64_t val = 0;
if (stop > start) {
for (i = start; i <= stop; i++) {
val |= ((int64_t) buf[i]) << (stop - i) * 8;
if (msb > lsb) {
for (i = lsb; i <= msb; i++) {
val |= ((int64_t) buf[i]) << (msb - i) * 8;
}
} else {
for (i = start; i >= stop; i--) {
val |= ((int64_t) buf[i]) << (i-stop) * 8;
for (i = lsb; i >= msb; i--) {
val |= ((int64_t) buf[i]) << (i-msb) * 8;
}
}
......
......@@ -22,7 +22,7 @@ public:
/* Translate recordId to SDR record */
bool getSdrRecord(uint16_t recordId, std::vector<uint8_t>& record);
/* Send raw command to BMC. Returns sensor reading as responded by BMC. */
int64_t sendRawCmd(const std::vector<uint8_t>& rawCmd, uint16_t start, uint16_t stop);
int64_t sendRawCmd(const std::vector<uint8_t>& rawCmd, uint8_t lsb, uint8_t msb);
/* Read the sensor specified by its record id. Returns sensor reading. */
double readSensorRecord(std::vector<uint8_t>& record);
......
......@@ -22,16 +22,16 @@ public:
SensorBase(name),
_recordId(0),
_factor(1),
_start(0),
_stop(0) {}
_lsb(0),
_msb(0) {}
IPMISensorBase(const IPMISensorBase& other) : SensorBase(other),
_recordId(other._recordId),
_sdrRecord(other._sdrRecord),
_factor(other._factor),
_rawCmd(other._rawCmd),
_start(other._start),
_stop(other._stop) {}
_lsb(other._lsb),
_msb(other._msb) {}
virtual ~IPMISensorBase() {}
......@@ -41,8 +41,8 @@ public:
_sdrRecord = other._sdrRecord;
_factor = other._factor;
_rawCmd = other._rawCmd;
_start = other._start;
_stop = other._stop;
_lsb = other._lsb;
_msb = other._msb;
return *this;
}
......@@ -51,8 +51,8 @@ public:
const std::vector<uint8_t>& getSdrRecord() const { return _sdrRecord; }
double getFactor() const { return _factor; }
const std::vector<uint8_t>& getRawCmd() const { return _rawCmd; }
uint8_t getStart() const { return _start; }
uint8_t getStop() const { return _stop; }
uint8_t getLsb() const { return _lsb; }
uint8_t getMsb() const { return _msb; }
void setRecordId(const std::string& recordId) { _recordId = stoul(recordId); }
void setSdrRecord(const std::vector<uint8_t>& sdrRecord) { _sdrRecord = sdrRecord; }
......@@ -65,10 +65,10 @@ public:
_rawCmd.push_back(stoi(*it++, NULL, 16));
}
}
void setStart(const std::string& start) { _start = stoi(start); }
void setStart(uint8_t start) { _start = start; }
void setStop(const std::string& stop) { _stop = stoi(stop); }
void setStop(uint8_t stop) { _stop = stop; }
void setLsb(const std::string& lsb) { _lsb = stoi(lsb); }
void setLsb(uint8_t lsb) { _lsb = lsb; }
void setMsb(const std::string& msb) { _msb = stoi(msb); }
void setMsb(uint8_t msb) { _msb = msb; }
protected:
uint16_t _recordId;
......@@ -76,8 +76,8 @@ protected:
double _factor;
std::vector<uint8_t> _rawCmd;
uint8_t _start;
uint8_t _stop;
uint8_t _lsb;
uint8_t _msb;
};
#endif /* SRC_SENSORS_IPMI_IPMISENSORBASE_H_ */
......@@ -84,7 +84,7 @@ void IPMISensorGroup::read() {
}
reading.value = _host->readSensorRecord(sdrRecord);
} else { /* use raw command */
reading.value = _host->sendRawCmd(s->getRawCmd(), s->getStart(), s->getStop());
reading.value = _host->sendRawCmd(s->getRawCmd(), s->getLsb(), s->getMsb());
}
#ifdef DEBUG
LOG(debug) << _groupName << "::" << s->getName() << " raw reading: \"" << reading.value << "\"";
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment