Lines Matching +full:double +full:- +full:channel
8 // http://www.apache.org/licenses/LICENSE-2.0
19 #include "dbus-sdr/sensorcommands.hpp"
21 #include "dbus-sdr/sdrutils.hpp"
22 #include "dbus-sdr/sensorutils.hpp"
23 #include "dbus-sdr/storagecommands.hpp"
31 #include <phosphor-logging/lg2.hpp>
64 // Refer Table 6-14, DCMI Entity ID Extension, DCMI v1.5 spec
102 static constexpr size_t maxIPMISensors = ((3 * 256) - (3 * 1));
111 static constexpr int GENERAL_ERROR = -1;
172 path = getPathFromSensorNumber((ctx->lun << 8) | sensnum); in getSensorConnection()
182 connection = sensor.second.begin()->first; in getSensorConnection()
184 *interfaces = sensor.second.begin()->second; in getSensorConnection()
209 boost::container::flat_map<std::string, std::variant<bool, double>> in __anon2f2fc9af0302()
219 auto ptr = std::get_if<bool>(&(findAssert->second)); in __anon2f2fc9af0302()
230 thresholdDeassertMap[m.get_path()][findAssert->first] = *ptr; in __anon2f2fc9af0302()
235 thresholdDeassertMap[m.get_path()][findAssert->first]; in __anon2f2fc9af0302()
255 static void getSensorMaxMin(const DbusInterfaceMap& sensorMap, double& max, in getSensorMaxMin()
256 double& min) in getSensorMaxMin()
259 min = -128; in getSensorMaxMin()
269 auto maxMap = sensorObject->second.find("MaxValue"); in getSensorMaxMin()
270 auto minMap = sensorObject->second.find("MinValue"); in getSensorMaxMin()
272 if (maxMap != sensorObject->second.end()) in getSensorMaxMin()
274 max = std::visit(VariantToDoubleVisitor(), maxMap->second); in getSensorMaxMin()
276 if (minMap != sensorObject->second.end()) in getSensorMaxMin()
278 min = std::visit(VariantToDoubleVisitor(), minMap->second); in getSensorMaxMin()
283 auto lower = critical->second.find("CriticalLow"); in getSensorMaxMin()
284 auto upper = critical->second.find("CriticalHigh"); in getSensorMaxMin()
285 if (lower != critical->second.end()) in getSensorMaxMin()
287 double value = std::visit(VariantToDoubleVisitor(), lower->second); in getSensorMaxMin()
293 if (upper != critical->second.end()) in getSensorMaxMin()
295 double value = std::visit(VariantToDoubleVisitor(), upper->second); in getSensorMaxMin()
304 auto lower = warning->second.find("WarningLow"); in getSensorMaxMin()
305 auto upper = warning->second.find("WarningHigh"); in getSensorMaxMin()
306 if (lower != warning->second.end()) in getSensorMaxMin()
308 double value = std::visit(VariantToDoubleVisitor(), lower->second); in getSensorMaxMin()
314 if (upper != warning->second.end()) in getSensorMaxMin()
316 double value = std::visit(VariantToDoubleVisitor(), upper->second); in getSensorMaxMin()
350 lastUpdate = updateFind->second; in getSensorMap()
355 if (std::chrono::duration_cast<std::chrono::seconds>(now - lastUpdate) in getSensorMap()
361 // Documented in the phosphor-dbus-interfaces repository. in getSensorMap()
401 auto path = connection->second.find(sensorPath); in getSensorMap()
402 if (path == connection->second.end()) in getSensorMap()
406 sensorMap = path->second; in getSensorMap()
427 std::get_if<std::vector<std::string>>(&supportedProperty->second); in getSupportedVrProfiles()
452 (assertOffset & (assertOffset - 1))) in calculateVRMode()
465 if (index >= profiles->size()) in calculateVRMode()
471 return profiles->at(index); in calculateVRMode()
475 static std::optional<double>
485 double max = 0; in calculateValue()
486 double min = 0; in calculateValue()
500 double value = bSigned ? ((int8_t)reading) : reading; in calculateValue()
502 value *= ((double)mValue); in calculateValue()
503 value += ((double)bValue) * std::pow(10.0, bExp); in calculateValue()
517 name = path.substr(nameStart + 1, std::string::npos - nameStart); in parseSdrIdFromPath()
571 auto itr = std::find(profiles->begin(), profiles->end(), mode); in getVrEventStatus()
572 if (itr == profiles->end()) in getVrEventStatus()
579 static_cast<std::size_t>(std::distance(profiles->begin(), itr)); in getVrEventStatus()
604 * The D-Bus sensors work well for generating Type 01 SDRs.
607 * insertion of non-Type 01 records.
608 * Manage non-Type 01 records:
610 * Create a new file: dbus-sdr/sensorcommands_oem.cpp
616 * Enable 'sensors-oem' in your phosphor-ipmi-host bbappend file
617 * 'EXTRA_OEMESON:append = " -Dsensors-oem=enabled"'
636 ->getIpmiEntityRecords(); in getOtherSensorsCount()
655 ->getIpmiEntityRecords(); in getOtherSensorsDataRecord()
657 size_t sdrIndex(recordID - ipmi::getNumberOfSensors()); in getOtherSensorsDataRecord()
659 size_t fruCount{otherCount - ipmi::storage::type12Count - entityCount}; in getOtherSensorsDataRecord()
670 sdrIndex - fruCount - ipmi::storage::type12Count)); in getOtherSensorsDataRecord()
681 size_t type12Index = sdrIndex - fruCount; in getOtherSensorsDataRecord()
727 if (ipmi::getChannelInfo(ctx->channel, chInfo) != ipmi::ccSuccess) in ipmiSenPlatformEvent()
729 lg2::error("Failed to get Channel Info, channel: {CHANNEL}", "CHANNEL", in ipmiSenPlatformEvent()
730 ctx->channel); in ipmiSenPlatformEvent()
745 generatorID = (ctx->channel << 12) // Channel in ipmiSenPlatformEvent()
747 | (0x0 << 8) // 0x0 for sys-soft ID in ipmiSenPlatformEvent()
755 generatorID = (ctx->channel << 12) // Channel in ipmiSenPlatformEvent()
757 | ((ctx->lun & 0x3) << 8) // Lun in ipmiSenPlatformEvent()
758 | (ctx->rqSA << 1); in ipmiSenPlatformEvent()
811 (ctx->lun << 8) | sensorNumber)) in ipmiSetSensorReading()
817 sensor::calculateValue(reading, sensorMap, sensorObject->second); in ipmiSetSensorReading()
867 sensor::calculateVRMode(assertOffset, sensorObject->second); in ipmiSetSensorReading()
915 (sensor->second.mutability & ipmi::sensor::Mutability::Read)) in ipmiSenGetSensorReading()
924 sensor->second.getFunc(sensor->second); in ipmiSenGetSensorReading()
963 sensorObject->second.find("Value") == sensorObject->second.end()) in ipmiSenGetSensorReading()
967 auto& valueVariant = sensorObject->second["Value"]; in ipmiSenGetSensorReading()
968 double reading = std::visit(VariantToDoubleVisitor(), valueVariant); in ipmiSenGetSensorReading()
970 double max = 0; in ipmiSenGetSensorReading()
971 double min = 0; in ipmiSenGetSensorReading()
999 auto findAvailable = availableObject->second.find("Available"); in ipmiSenGetSensorReading()
1000 if (findAvailable != availableObject->second.end()) in ipmiSenGetSensorReading()
1002 bool* available = std::get_if<bool>(&(findAvailable->second)); in ipmiSenGetSensorReading()
1030 if (details::sdrStatsTable.updateReading((ctx->lun << 8) | sensnum, in ipmiSenGetSensorReading()
1034 double step = (max - min) / 255.0; in ipmiSenGetSensorReading()
1037 << details::sdrStatsTable.getName((ctx->lun << 8) | sensnum) in ipmiSenGetSensorReading()
1053 auto alarmHigh = warningObject->second.find("WarningAlarmHigh"); in ipmiSenGetSensorReading()
1054 auto alarmLow = warningObject->second.find("WarningAlarmLow"); in ipmiSenGetSensorReading()
1055 if (alarmHigh != warningObject->second.end()) in ipmiSenGetSensorReading()
1057 if (std::get<bool>(alarmHigh->second)) in ipmiSenGetSensorReading()
1063 if (alarmLow != warningObject->second.end()) in ipmiSenGetSensorReading()
1065 if (std::get<bool>(alarmLow->second)) in ipmiSenGetSensorReading()
1077 auto alarmHigh = criticalObject->second.find("CriticalAlarmHigh"); in ipmiSenGetSensorReading()
1078 auto alarmLow = criticalObject->second.find("CriticalAlarmLow"); in ipmiSenGetSensorReading()
1079 if (alarmHigh != criticalObject->second.end()) in ipmiSenGetSensorReading()
1081 if (std::get<bool>(alarmHigh->second)) in ipmiSenGetSensorReading()
1087 if (alarmLow != criticalObject->second.end()) in ipmiSenGetSensorReading()
1089 if (std::get<bool>(alarmLow->second)) in ipmiSenGetSensorReading()
1102 * @param sensorNumber - sensor number
1110 * @param lowerNonCritical - lower non-critical threshold
1111 * @param lowerCritical - Lower critical threshold
1112 * @param lowerNonRecoverable - Lower non recovarable threshold
1113 * @param upperNonCritical - Upper non-critical threshold
1114 * @param upperCritical - Upper critical
1115 * @param upperNonRecoverable - Upper Non-recoverable
1161 double max = 0; in ipmiSenSetSensorThresholds()
1162 double min = 0; in ipmiSenSetSensorThresholds()
1194 auto findLower = findThreshold->second.find("CriticalLow"); in ipmiSenSetSensorThresholds()
1195 if (findLower == findThreshold->second.end()) in ipmiSenSetSensorThresholds()
1200 findThreshold->first); in ipmiSenSetSensorThresholds()
1204 auto findUpper = findThreshold->second.find("CriticalHigh"); in ipmiSenSetSensorThresholds()
1205 if (findUpper == findThreshold->second.end()) in ipmiSenSetSensorThresholds()
1210 findThreshold->first); in ipmiSenSetSensorThresholds()
1223 auto findLower = findThreshold->second.find("WarningLow"); in ipmiSenSetSensorThresholds()
1224 if (findLower == findThreshold->second.end()) in ipmiSenSetSensorThresholds()
1229 findThreshold->first); in ipmiSenSetSensorThresholds()
1233 auto findUpper = findThreshold->second.find("WarningHigh"); in ipmiSenSetSensorThresholds()
1234 if (findUpper == findThreshold->second.end()) in ipmiSenSetSensorThresholds()
1239 findThreshold->first); in ipmiSenSetSensorThresholds()
1245 double valueToSet = ((mValue * std::get<thresholdValue>(property)) + in ipmiSenSetSensorThresholds()
1275 double max = 0; in getIPMIThresholds()
1276 double min = 0; in getIPMIThresholds()
1291 auto& warningMap = warningInterface->second; in getIPMIThresholds()
1298 double value = in getIPMIThresholds()
1299 std::visit(VariantToDoubleVisitor(), warningHigh->second); in getIPMIThresholds()
1308 double value = in getIPMIThresholds()
1309 std::visit(VariantToDoubleVisitor(), warningLow->second); in getIPMIThresholds()
1319 auto& criticalMap = criticalInterface->second; in getIPMIThresholds()
1326 double value = in getIPMIThresholds()
1327 std::visit(VariantToDoubleVisitor(), criticalHigh->second); in getIPMIThresholds()
1336 double value = in getIPMIThresholds()
1337 std::visit(VariantToDoubleVisitor(), criticalLow->second); in getIPMIThresholds()
1428 * @param sensorNumber - sensor number
1431 * - enabled - Sensor Event messages
1432 * - assertionEnabledLsb - Assertion event messages
1433 * - assertionEnabledMsb - Assertion event messages
1434 * - deassertionEnabledLsb - Deassertion event messages
1435 * - deassertionEnabledMsb - Deassertion event messages
1474 for (auto& offsetValMap : sensor->second.propertyInterfaces.begin() in ipmiSenGetSensorEventEnable()
1475 ->second.begin() in ipmiSenGetSensorEventEnable()
1476 ->second.second) in ipmiSenGetSensorEventEnable()
1507 auto& warningMap = warningInterface->second; in ipmiSenGetSensorEventEnable()
1513 double value = in ipmiSenGetSensorEventEnable()
1514 std::visit(VariantToDoubleVisitor(), warningHigh->second); in ipmiSenGetSensorEventEnable()
1527 double value = in ipmiSenGetSensorEventEnable()
1528 std::visit(VariantToDoubleVisitor(), warningLow->second); in ipmiSenGetSensorEventEnable()
1542 auto& criticalMap = criticalInterface->second; in ipmiSenGetSensorEventEnable()
1549 double value = in ipmiSenGetSensorEventEnable()
1550 std::visit(VariantToDoubleVisitor(), criticalHigh->second); in ipmiSenGetSensorEventEnable()
1562 double value = in ipmiSenGetSensorEventEnable()
1563 std::visit(VariantToDoubleVisitor(), criticalLow->second); in ipmiSenGetSensorEventEnable()
1582 * @param sensorNumber - sensor number, FFh = reserved
1585 * - sensorEventStatus - Sensor Event messages state
1586 * - assertions - Assertion event messages
1587 * - deassertions - Deassertion event messages
1618 sensor->second, path, sensor->second.sensorInterface); in ipmiSenGetSensorEventStatus()
1664 vrInterface->second, assertions)) in ipmiSenGetSensorEventStatus()
1716 auto& warningMap = warningInterface->second; in ipmiSenGetSensorEventStatus()
1725 warningHighAlarm = std::get<bool>(warningHigh->second); in ipmiSenGetSensorEventStatus()
1729 warningLowAlarm = std::get<bool>(warningLow->second); in ipmiSenGetSensorEventStatus()
1746 auto& criticalMap = criticalInterface->second; in ipmiSenGetSensorEventStatus()
1755 criticalHighAlarm = std::get<bool>(criticalHigh->second); in ipmiSenGetSensorEventStatus()
1759 criticalLowAlarm = std::get<bool>(criticalLow->second); in ipmiSenGetSensorEventStatus()
1790 record.header.record_length = sizeof(get_sdr::SensorDataFullRecord) - in constructSensorSdrHeaderKey()
1813 record.body.sensor_capabilities = 0x68; // auto rearm - todo hysteresis in constructSensorSdr()
1821 static_cast<uint8_t>(findUnits->second); in constructSensorSdr()
1844 double max = 0; in constructSensorSdr()
1845 double min = 0; in constructSensorSdr()
1861 // from sensorhandler.hpp in phosphor-ipmi-host. in constructSensorSdr()
1866 // Byte 22-24 are for other purposes in constructSensorSdr()
1913 get_sdr::body::set_id_type(3, &record.body); // "8-bit ASCII + Latin 1" in constructSensorSdr()
1926 mappedVariant<bool>(mutability->second, "Mutable", false); in constructSensorSdr()
2008 record.body.entity_id = sensor->second.entityType; in constructStaticSensorSdr()
2009 record.body.sensor_type = sensor->second.sensorType; in constructStaticSensorSdr()
2010 record.body.event_reading_type = sensor->second.sensorReadingType; in constructStaticSensorSdr()
2011 record.body.entity_instance = sensor->second.instance; in constructStaticSensorSdr()
2013 (sensor->second.mutability & ipmi::sensor::Mutability::Write)) in constructStaticSensorSdr()
2018 auto id_string = sensor->second.sensorName; in constructStaticSensorSdr()
2022 id_string = sensor->second.sensorNameFunc(sensor->second); in constructStaticSensorSdr()
2034 get_sdr::body::set_id_type(3, &record.body); // "8-bit ASCII + Latin 1" in constructStaticSensorSdr()
2052 record.header.record_length = sizeof(get_sdr::SensorDataEventRecord) - in constructEventSdrHeaderKey()
2100 get_sdr::body::set_id_type(3, &record.body); // "8-bit ASCII + Latin 1" in constructVrSdr()
2123 ipmi::sensor::getOtherSensorsCount(ctx) - 1; in getSensorDataRecord()
2164 ctx->lun = lun1; in getSensorDataRecord()
2172 ctx->lun = lun3; in getSensorDataRecord()
2196 (lun != ctx->lun)) in getSensorDataRecord()
2281 * - sdrCount - sensor/SDR count
2282 * - lunsAndDynamicPopulation - static/Dynamic sensor population flag
2305 sdrCount = numSensors + ipmi::sensor::getOtherSensorsCount(ctx) - 1; in ipmiSensorGetDeviceSdrInfo()
2310 if ((ctx->lun == lun0) && (numSensors > 0)) in ipmiSensorGetDeviceSdrInfo()
2315 else if ((ctx->lun == lun1) && (numSensors > maxSensorsPerLUN)) in ipmiSensorGetDeviceSdrInfo()
2319 : (numSensors - maxSensorsPerLUN) & maxSensorsPerLUN; in ipmiSensorGetDeviceSdrInfo()
2321 else if (ctx->lun == lun3) in ipmiSensorGetDeviceSdrInfo()
2325 sdrCount = (numSensors - (2 * maxSensorsPerLUN)) & in ipmiSensorGetDeviceSdrInfo()
2394 * - allocUnits - Number of possible allocation units
2395 * - allocUnitSize - Allocation unit size in bytes.
2396 * - allocUnitFree - Number of free allocation units
2397 * - allocUnitLargestFree - Largest free block in allocation units
2398 * - maxRecordSize - Maximum record size in allocation units.
2422 * - sdrReservationID
2477 sizeof(get_sdr::SensorDataRecordHeader) + hdr->record_length; in ipmiStorageGetSDR()
2485 bytesToRead = sdrLength - offset; in ipmiStorageGetSDR()
2541 const auto& connection = sensor.second.begin()->first; in getSensorsByEntityId()
2558 * in the Entity-Manger. in getSensorsByEntityId()
2565 if (entityIdValue == match->first || entityIdValue == match->second) in getSensorsByEntityId()
2646 double scaleVal = 0.0; in readTemp()
2649 scaleVal = std::visit(ipmi::VariantToDoubleVisitor(), scaleIt->second); in readTemp()
2653 double tempVal = 0.0; in readTemp()
2659 const double maxTemp = 127; in readTemp()
2660 double absTempVal = 0.0; in readTemp()
2663 tempVal = std::visit(ipmi::VariantToDoubleVisitor(), tempValIt->second); in readTemp()