Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 1 | #include "pldm.hpp" |
| 2 | |
| 3 | #include "file.hpp" |
| 4 | |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 5 | #include <libpldm/entity.h> |
Andrew Jeffery | 97476a1 | 2024-06-19 21:07:29 +0930 | [diff] [blame] | 6 | #include <libpldm/oem/ibm/state_set.h> |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 7 | #include <libpldm/platform.h> |
| 8 | #include <libpldm/state_set.h> |
| 9 | |
| 10 | #include <phosphor-logging/log.hpp> |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 11 | #include <sdbusplus/bus.hpp> |
| 12 | #include <sdeventplus/clock.hpp> |
| 13 | #include <sdeventplus/exception.hpp> |
| 14 | #include <sdeventplus/source/io.hpp> |
| 15 | #include <sdeventplus/source/time.hpp> |
| 16 | |
| 17 | #include <algorithm> |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 18 | #include <format> |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 19 | |
| 20 | namespace pldm |
| 21 | { |
| 22 | |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 23 | using namespace phosphor::logging; |
| 24 | |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 25 | using namespace sdeventplus; |
| 26 | using namespace sdeventplus::source; |
| 27 | constexpr auto clockId = sdeventplus::ClockId::RealTime; |
| 28 | using Clock = sdeventplus::Clock<clockId>; |
| 29 | using Timer = Time<clockId>; |
Chris Cain | 755af10 | 2024-02-27 16:09:51 -0600 | [diff] [blame] | 30 | bool Interface::throttleTraces = false; |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 31 | |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 32 | void Interface::fetchSensorInfo(uint16_t stateSetId, |
| 33 | SensorToInstance& sensorInstanceMap, |
| 34 | SensorOffset& sensorOffset) |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 35 | { |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 36 | PdrList pdrs{}; |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 37 | static bool tracedError = false; |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 38 | |
| 39 | auto& bus = open_power::occ::utils::getBus(); |
| 40 | try |
| 41 | { |
| 42 | auto method = bus.new_method_call( |
| 43 | "xyz.openbmc_project.PLDM", "/xyz/openbmc_project/pldm", |
| 44 | "xyz.openbmc_project.PLDM.PDR", "FindStateSensorPDR"); |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 45 | method.append(tid, static_cast<uint16_t>(PLDM_ENTITY_PROC), stateSetId); |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 46 | |
| 47 | auto responseMsg = bus.call(method); |
| 48 | responseMsg.read(pdrs); |
| 49 | } |
Patrick Williams | af40808 | 2022-07-22 19:26:54 -0500 | [diff] [blame] | 50 | catch (const sdbusplus::exception_t& e) |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 51 | { |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 52 | if (!tracedError) |
| 53 | { |
| 54 | log<level::ERR>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 55 | std::format( |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 56 | "fetchSensorInfo: Failed to find stateSetID:{} PDR: {}", |
| 57 | stateSetId, e.what()) |
| 58 | .c_str()); |
| 59 | tracedError = true; |
| 60 | } |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | if (pdrs.empty()) |
| 64 | { |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 65 | if (!tracedError) |
| 66 | { |
| 67 | log<level::ERR>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 68 | std::format( |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 69 | "fetchSensorInfo: state sensor PDRs ({}) not present", |
| 70 | stateSetId) |
| 71 | .c_str()); |
| 72 | tracedError = true; |
| 73 | } |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 74 | return; |
| 75 | } |
| 76 | |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 77 | // Found PDR |
| 78 | if (tracedError) |
| 79 | { |
| 80 | log<level::INFO>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 81 | std::format("fetchSensorInfo: found {} PDRs", pdrs.size()).c_str()); |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 82 | tracedError = false; |
| 83 | } |
| 84 | |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 85 | bool offsetFound = false; |
George Liu | f3a4a69 | 2021-12-28 13:59:51 +0800 | [diff] [blame] | 86 | auto stateSensorPDR = |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 87 | reinterpret_cast<const pldm_state_sensor_pdr*>(pdrs.front().data()); |
George Liu | f3a4a69 | 2021-12-28 13:59:51 +0800 | [diff] [blame] | 88 | auto possibleStatesPtr = stateSensorPDR->possible_states; |
| 89 | for (auto offset = 0; offset < stateSensorPDR->composite_sensor_count; |
| 90 | offset++) |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 91 | { |
| 92 | auto possibleStates = |
| 93 | reinterpret_cast<const state_sensor_possible_states*>( |
| 94 | possibleStatesPtr); |
| 95 | |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 96 | if (possibleStates->state_set_id == stateSetId) |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 97 | { |
| 98 | sensorOffset = offset; |
| 99 | offsetFound = true; |
| 100 | break; |
| 101 | } |
| 102 | possibleStatesPtr += sizeof(possibleStates->state_set_id) + |
| 103 | sizeof(possibleStates->possible_states_size) + |
| 104 | possibleStates->possible_states_size; |
| 105 | } |
| 106 | |
| 107 | if (!offsetFound) |
| 108 | { |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 109 | log<level::ERR>("pldm: state sensor PDR not found"); |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 110 | return; |
| 111 | } |
| 112 | |
| 113 | // To order SensorID based on the EntityInstance. |
| 114 | // Note that when a proc is on a DCM, the PDRs for these sensors |
| 115 | // could have the same instance IDs but different container IDs. |
| 116 | std::map<uint32_t, SensorID> entityInstMap{}; |
| 117 | for (auto& pdr : pdrs) |
| 118 | { |
| 119 | auto pdrPtr = |
| 120 | reinterpret_cast<const pldm_state_sensor_pdr*>(pdr.data()); |
Chris Cain | 72d01aa | 2022-06-14 16:28:03 -0500 | [diff] [blame] | 121 | uint32_t key = pdrPtr->sensor_id; |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 122 | entityInstMap.emplace(key, static_cast<SensorID>(pdrPtr->sensor_id)); |
| 123 | } |
| 124 | |
| 125 | open_power::occ::instanceID count = start; |
Patrick Williams | a49c987 | 2023-05-10 07:50:35 -0500 | [diff] [blame] | 126 | for (const auto& pair : entityInstMap) |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 127 | { |
| 128 | sensorInstanceMap.emplace(pair.second, count); |
| 129 | count++; |
| 130 | } |
| 131 | } |
| 132 | |
Patrick Williams | af40808 | 2022-07-22 19:26:54 -0500 | [diff] [blame] | 133 | void Interface::sensorEvent(sdbusplus::message_t& msg) |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 134 | { |
| 135 | if (!isOCCSensorCacheValid()) |
| 136 | { |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 137 | fetchSensorInfo(PLDM_STATE_SET_OPERATIONAL_RUNNING_STATUS, |
| 138 | sensorToOCCInstance, OCCSensorOffset); |
| 139 | } |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 140 | |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 141 | if (sensorToSBEInstance.empty()) |
| 142 | { |
| 143 | fetchSensorInfo(PLDM_OEM_IBM_SBE_HRESET_STATE, sensorToSBEInstance, |
| 144 | SBESensorOffset); |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 145 | } |
| 146 | |
Chris Cain | 72d01aa | 2022-06-14 16:28:03 -0500 | [diff] [blame] | 147 | TerminusID sensorTid{}; |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 148 | SensorID sensorId{}; |
| 149 | SensorOffset msgSensorOffset{}; |
| 150 | EventState eventState{}; |
| 151 | EventState previousEventState{}; |
| 152 | |
Chris Cain | 72d01aa | 2022-06-14 16:28:03 -0500 | [diff] [blame] | 153 | msg.read(sensorTid, sensorId, msgSensorOffset, eventState, |
| 154 | previousEventState); |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 155 | |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 156 | if (msgSensorOffset == OCCSensorOffset) |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 157 | { |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 158 | auto sensorEntry = sensorToOCCInstance.find(sensorId); |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 159 | |
Eddie James | 432dc48 | 2021-11-19 15:29:31 -0600 | [diff] [blame] | 160 | if (sensorEntry != sensorToOCCInstance.end()) |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 161 | { |
Chris Cain | 8b508bf | 2022-05-26 14:01:31 -0500 | [diff] [blame] | 162 | const uint8_t instance = sensorEntry->second; |
Chris Cain | 755af10 | 2024-02-27 16:09:51 -0600 | [diff] [blame] | 163 | bool validEvent = true; |
Chris Cain | 7b00cde | 2023-03-14 15:47:12 -0500 | [diff] [blame] | 164 | bool isRunning = false; |
Eddie James | 432dc48 | 2021-11-19 15:29:31 -0600 | [diff] [blame] | 165 | if (eventState == |
| 166 | static_cast<EventState>( |
| 167 | PLDM_STATE_SET_OPERATIONAL_RUNNING_STATUS_IN_SERVICE)) |
| 168 | { |
| 169 | log<level::INFO>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 170 | std::format("PLDM: OCC{} is RUNNING", instance).c_str()); |
Chris Cain | 7b00cde | 2023-03-14 15:47:12 -0500 | [diff] [blame] | 171 | isRunning = true; |
Eddie James | 432dc48 | 2021-11-19 15:29:31 -0600 | [diff] [blame] | 172 | } |
| 173 | else if (eventState == |
| 174 | static_cast<EventState>( |
| 175 | PLDM_STATE_SET_OPERATIONAL_RUNNING_STATUS_STOPPED)) |
| 176 | { |
Chris Cain | 8b508bf | 2022-05-26 14:01:31 -0500 | [diff] [blame] | 177 | log<level::INFO>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 178 | std::format("PLDM: OCC{} has now STOPPED", instance) |
Chris Cain | 8b508bf | 2022-05-26 14:01:31 -0500 | [diff] [blame] | 179 | .c_str()); |
Eddie James | 432dc48 | 2021-11-19 15:29:31 -0600 | [diff] [blame] | 180 | } |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 181 | else if (eventState == |
| 182 | static_cast<EventState>( |
| 183 | PLDM_STATE_SET_OPERATIONAL_RUNNING_STATUS_DORMANT)) |
| 184 | { |
Chris Cain | 755af10 | 2024-02-27 16:09:51 -0600 | [diff] [blame] | 185 | log<level::ERR>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 186 | std::format( |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 187 | "PLDM: OCC{} has now STOPPED and system is in SAFE MODE", |
Chris Cain | 8b508bf | 2022-05-26 14:01:31 -0500 | [diff] [blame] | 188 | instance) |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 189 | .c_str()); |
Sheldon Bailey | 31a2f13 | 2022-05-20 11:31:52 -0500 | [diff] [blame] | 190 | |
| 191 | // Setting safe mode true |
| 192 | safeModeCallBack(true); |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 193 | } |
| 194 | else |
| 195 | { |
Chris Cain | 755af10 | 2024-02-27 16:09:51 -0600 | [diff] [blame] | 196 | log<level::WARNING>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 197 | std::format("PLDM: Unexpected PLDM state {} for OCC{}", |
Chris Cain | 8b508bf | 2022-05-26 14:01:31 -0500 | [diff] [blame] | 198 | eventState, instance) |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 199 | .c_str()); |
Chris Cain | 755af10 | 2024-02-27 16:09:51 -0600 | [diff] [blame] | 200 | validEvent = false; |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 201 | } |
Chris Cain | 755af10 | 2024-02-27 16:09:51 -0600 | [diff] [blame] | 202 | if (validEvent) |
| 203 | { |
| 204 | if ((pldmFd > 0) && (instance == pldmResponseOcc)) |
| 205 | { |
| 206 | // Waiting for a response for this OCC, can stop waiting |
| 207 | pldmClose(); |
| 208 | } |
| 209 | callBack(instance, isRunning); |
| 210 | } |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 211 | return; |
| 212 | } |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 213 | } |
Eddie James | 432dc48 | 2021-11-19 15:29:31 -0600 | [diff] [blame] | 214 | |
| 215 | if (msgSensorOffset == SBESensorOffset) |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 216 | { |
| 217 | auto sensorEntry = sensorToSBEInstance.find(sensorId); |
| 218 | |
Eddie James | 432dc48 | 2021-11-19 15:29:31 -0600 | [diff] [blame] | 219 | if (sensorEntry != sensorToSBEInstance.end()) |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 220 | { |
Chris Cain | 12d0b82 | 2022-04-22 17:29:18 -0500 | [diff] [blame] | 221 | const uint8_t instance = sensorEntry->second; |
| 222 | auto match = std::find(outstandingHResets.begin(), |
| 223 | outstandingHResets.end(), instance); |
| 224 | if (match != outstandingHResets.end()) |
Eddie James | 432dc48 | 2021-11-19 15:29:31 -0600 | [diff] [blame] | 225 | { |
Chris Cain | 12d0b82 | 2022-04-22 17:29:18 -0500 | [diff] [blame] | 226 | outstandingHResets.erase(match); |
| 227 | if (eventState == static_cast<EventState>(SBE_HRESET_NOT_READY)) |
| 228 | { |
| 229 | log<level::INFO>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 230 | std::format("pldm: HRESET is NOT READY (OCC{})", |
Chris Cain | 12d0b82 | 2022-04-22 17:29:18 -0500 | [diff] [blame] | 231 | instance) |
| 232 | .c_str()); |
| 233 | } |
| 234 | else if (eventState == |
| 235 | static_cast<EventState>(SBE_HRESET_READY)) |
| 236 | { |
| 237 | sbeCallBack(instance, true); |
| 238 | } |
| 239 | else if (eventState == |
| 240 | static_cast<EventState>(SBE_HRESET_FAILED)) |
| 241 | { |
| 242 | sbeCallBack(instance, false); |
| 243 | } |
Eddie James | 432dc48 | 2021-11-19 15:29:31 -0600 | [diff] [blame] | 244 | } |
Chris Cain | 12d0b82 | 2022-04-22 17:29:18 -0500 | [diff] [blame] | 245 | // else request was not from us |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 246 | } |
| 247 | } |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 248 | } |
| 249 | |
Patrick Williams | af40808 | 2022-07-22 19:26:54 -0500 | [diff] [blame] | 250 | void Interface::hostStateEvent(sdbusplus::message_t& msg) |
Chris Cain | 157467d | 2022-06-24 11:25:23 -0500 | [diff] [blame] | 251 | { |
| 252 | std::map<std::string, std::variant<std::string>> properties{}; |
| 253 | std::string interface; |
| 254 | msg.read(interface, properties); |
| 255 | const auto stateEntry = properties.find("CurrentHostState"); |
| 256 | if (stateEntry != properties.end()) |
| 257 | { |
| 258 | auto stateEntryValue = stateEntry->second; |
| 259 | auto propVal = std::get<std::string>(stateEntryValue); |
| 260 | if (propVal == "xyz.openbmc_project.State.Host.HostState.Off") |
| 261 | { |
| 262 | clearData(); |
| 263 | } |
| 264 | } |
| 265 | } |
| 266 | |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 267 | void Interface::clearData() |
| 268 | { |
Chris Cain | 72d01aa | 2022-06-14 16:28:03 -0500 | [diff] [blame] | 269 | if (!sensorToOCCInstance.empty()) |
| 270 | { |
| 271 | log<level::INFO>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 272 | std::format("clearData: Clearing sensorToOCCInstance ({} entries)", |
Chris Cain | 72d01aa | 2022-06-14 16:28:03 -0500 | [diff] [blame] | 273 | sensorToOCCInstance.size()) |
| 274 | .c_str()); |
| 275 | for (auto entry : sensorToOCCInstance) |
| 276 | { |
| 277 | log<level::INFO>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 278 | std::format("clearData: OCC{} / sensorID: 0x{:04X}", |
Chris Cain | 72d01aa | 2022-06-14 16:28:03 -0500 | [diff] [blame] | 279 | entry.second, entry.first) |
| 280 | .c_str()); |
Chris Cain | 082a6ca | 2023-03-21 10:27:26 -0500 | [diff] [blame] | 281 | callBack(entry.second, false); |
Chris Cain | 72d01aa | 2022-06-14 16:28:03 -0500 | [diff] [blame] | 282 | } |
| 283 | sensorToOCCInstance.clear(); |
| 284 | } |
| 285 | if (!occInstanceToEffecter.empty()) |
| 286 | { |
| 287 | log<level::DEBUG>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 288 | std::format( |
Chris Cain | 72d01aa | 2022-06-14 16:28:03 -0500 | [diff] [blame] | 289 | "clearData: Clearing occInstanceToEffecter ({} entries)", |
| 290 | occInstanceToEffecter.size()) |
| 291 | .c_str()); |
| 292 | occInstanceToEffecter.clear(); |
| 293 | } |
| 294 | if (!sensorToSBEInstance.empty()) |
| 295 | { |
| 296 | log<level::DEBUG>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 297 | std::format("clearData: Clearing sensorToSBEInstance ({} entries)", |
Chris Cain | 72d01aa | 2022-06-14 16:28:03 -0500 | [diff] [blame] | 298 | sensorToSBEInstance.size()) |
| 299 | .c_str()); |
| 300 | sensorToSBEInstance.clear(); |
| 301 | } |
| 302 | if (!sbeInstanceToEffecter.empty()) |
| 303 | { |
| 304 | log<level::DEBUG>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 305 | std::format( |
Chris Cain | 72d01aa | 2022-06-14 16:28:03 -0500 | [diff] [blame] | 306 | "clearData: Clearing sbeInstanceToEffecter ({} entries)", |
| 307 | sbeInstanceToEffecter.size()) |
| 308 | .c_str()); |
| 309 | sbeInstanceToEffecter.clear(); |
| 310 | } |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 311 | } |
| 312 | |
Eddie James | 432dc48 | 2021-11-19 15:29:31 -0600 | [diff] [blame] | 313 | void Interface::fetchEffecterInfo(uint16_t stateSetId, |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 314 | InstanceToEffecter& instanceToEffecterMap, |
| 315 | CompositeEffecterCount& effecterCount, |
| 316 | uint8_t& stateIdPos) |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 317 | { |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 318 | PdrList pdrs{}; |
| 319 | |
| 320 | auto& bus = open_power::occ::utils::getBus(); |
| 321 | try |
| 322 | { |
| 323 | auto method = bus.new_method_call( |
| 324 | "xyz.openbmc_project.PLDM", "/xyz/openbmc_project/pldm", |
| 325 | "xyz.openbmc_project.PLDM.PDR", "FindStateEffecterPDR"); |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 326 | method.append(tid, static_cast<uint16_t>(PLDM_ENTITY_PROC), stateSetId); |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 327 | |
| 328 | auto responseMsg = bus.call(method); |
| 329 | responseMsg.read(pdrs); |
| 330 | } |
Patrick Williams | af40808 | 2022-07-22 19:26:54 -0500 | [diff] [blame] | 331 | catch (const sdbusplus::exception_t& e) |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 332 | { |
| 333 | log<level::ERR>("pldm: Failed to fetch the state effecter PDRs", |
| 334 | entry("ERROR=%s", e.what())); |
| 335 | } |
| 336 | |
| 337 | if (!pdrs.size()) |
| 338 | { |
| 339 | log<level::ERR>("pldm: state effecter PDRs not present"); |
| 340 | return; |
| 341 | } |
| 342 | |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 343 | bool offsetFound = false; |
George Liu | f3a4a69 | 2021-12-28 13:59:51 +0800 | [diff] [blame] | 344 | auto stateEffecterPDR = |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 345 | reinterpret_cast<const pldm_state_effecter_pdr*>(pdrs.front().data()); |
George Liu | f3a4a69 | 2021-12-28 13:59:51 +0800 | [diff] [blame] | 346 | auto possibleStatesPtr = stateEffecterPDR->possible_states; |
| 347 | for (auto offset = 0; offset < stateEffecterPDR->composite_effecter_count; |
| 348 | offset++) |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 349 | { |
| 350 | auto possibleStates = |
| 351 | reinterpret_cast<const state_effecter_possible_states*>( |
| 352 | possibleStatesPtr); |
| 353 | |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 354 | if (possibleStates->state_set_id == stateSetId) |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 355 | { |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 356 | stateIdPos = offset; |
George Liu | f3a4a69 | 2021-12-28 13:59:51 +0800 | [diff] [blame] | 357 | effecterCount = stateEffecterPDR->composite_effecter_count; |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 358 | offsetFound = true; |
| 359 | break; |
| 360 | } |
| 361 | possibleStatesPtr += sizeof(possibleStates->state_set_id) + |
| 362 | sizeof(possibleStates->possible_states_size) + |
| 363 | possibleStates->possible_states_size; |
| 364 | } |
| 365 | |
| 366 | if (!offsetFound) |
| 367 | { |
| 368 | return; |
| 369 | } |
| 370 | |
Chris Cain | 0f51652 | 2022-02-07 14:48:28 -0600 | [diff] [blame] | 371 | std::map<uint32_t, EffecterID> entityInstMap{}; |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 372 | for (auto& pdr : pdrs) |
| 373 | { |
| 374 | auto pdrPtr = |
| 375 | reinterpret_cast<const pldm_state_effecter_pdr*>(pdr.data()); |
Chris Cain | 72d01aa | 2022-06-14 16:28:03 -0500 | [diff] [blame] | 376 | uint32_t key = pdrPtr->effecter_id; |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 377 | entityInstMap.emplace(key, static_cast<SensorID>(pdrPtr->effecter_id)); |
| 378 | } |
| 379 | |
| 380 | open_power::occ::instanceID position = start; |
Patrick Williams | a49c987 | 2023-05-10 07:50:35 -0500 | [diff] [blame] | 381 | for (const auto& pair : entityInstMap) |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 382 | { |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 383 | instanceToEffecterMap.emplace(position, pair.second); |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 384 | position++; |
| 385 | } |
| 386 | } |
| 387 | |
| 388 | std::vector<uint8_t> |
Chris Cain | 8b508bf | 2022-05-26 14:01:31 -0500 | [diff] [blame] | 389 | Interface::prepareSetEffecterReq(EffecterID effecterId, |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 390 | CompositeEffecterCount effecterCount, |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 391 | uint8_t stateIdPos, uint8_t stateSetValue) |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 392 | { |
Rashmica Gupta | aeba51c | 2023-02-17 12:30:46 +1100 | [diff] [blame^] | 393 | if (!getPldmInstanceId()) |
Chris Cain | 8b508bf | 2022-05-26 14:01:31 -0500 | [diff] [blame] | 394 | { |
| 395 | return std::vector<uint8_t>(); |
| 396 | } |
| 397 | |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 398 | std::vector<uint8_t> request( |
| 399 | sizeof(pldm_msg_hdr) + sizeof(effecterId) + sizeof(effecterCount) + |
| 400 | (effecterCount * sizeof(set_effecter_state_field))); |
| 401 | auto requestMsg = reinterpret_cast<pldm_msg*>(request.data()); |
| 402 | std::vector<set_effecter_state_field> stateField; |
| 403 | |
| 404 | for (uint8_t effecterPos = 0; effecterPos < effecterCount; effecterPos++) |
| 405 | { |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 406 | if (effecterPos == stateIdPos) |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 407 | { |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 408 | stateField.emplace_back( |
| 409 | set_effecter_state_field{PLDM_REQUEST_SET, stateSetValue}); |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 410 | } |
| 411 | else |
| 412 | { |
| 413 | stateField.emplace_back( |
| 414 | set_effecter_state_field{PLDM_NO_CHANGE, 0}); |
| 415 | } |
| 416 | } |
| 417 | auto rc = encode_set_state_effecter_states_req( |
Rashmica Gupta | aeba51c | 2023-02-17 12:30:46 +1100 | [diff] [blame^] | 418 | pldmInstanceID.value(), effecterId, effecterCount, stateField.data(), |
Chris Cain | 8b508bf | 2022-05-26 14:01:31 -0500 | [diff] [blame] | 419 | requestMsg); |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 420 | if (rc != PLDM_SUCCESS) |
| 421 | { |
| 422 | log<level::ERR>("encode set effecter states request returned error ", |
| 423 | entry("RC=%d", rc)); |
| 424 | request.clear(); |
| 425 | } |
| 426 | return request; |
| 427 | } |
| 428 | |
| 429 | void Interface::resetOCC(open_power::occ::instanceID occInstanceId) |
| 430 | { |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 431 | if (open_power::occ::utils::isHostRunning()) |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 432 | { |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 433 | if (!isPDREffecterCacheValid()) |
| 434 | { |
| 435 | fetchEffecterInfo(PLDM_STATE_SET_BOOT_RESTART_CAUSE, |
| 436 | occInstanceToEffecter, OCCEffecterCount, |
| 437 | bootRestartPosition); |
| 438 | } |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 439 | |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 440 | // Find the matching effecter for the OCC instance |
| 441 | auto effecterEntry = occInstanceToEffecter.find(occInstanceId); |
| 442 | if (effecterEntry == occInstanceToEffecter.end()) |
| 443 | { |
| 444 | log<level::ERR>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 445 | std::format( |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 446 | "pldm: Failed to find a matching effecter for OCC instance {}", |
| 447 | occInstanceId) |
| 448 | .c_str()); |
| 449 | |
| 450 | return; |
| 451 | } |
| 452 | |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 453 | // Prepare the SetStateEffecterStates request to reset the OCC |
| 454 | auto request = prepareSetEffecterReq( |
Chris Cain | 8b508bf | 2022-05-26 14:01:31 -0500 | [diff] [blame] | 455 | effecterEntry->second, OCCEffecterCount, bootRestartPosition, |
| 456 | PLDM_STATE_SET_BOOT_RESTART_CAUSE_WARM_RESET); |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 457 | |
| 458 | if (request.empty()) |
| 459 | { |
| 460 | log<level::ERR>( |
| 461 | "pldm: SetStateEffecterStates OCC reset request empty"); |
| 462 | return; |
| 463 | } |
| 464 | |
| 465 | // Send request to reset the OCCs/PM Complex (ignore response) |
| 466 | sendPldm(request, occInstanceId, false); |
| 467 | } |
| 468 | else |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 469 | { |
| 470 | log<level::ERR>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 471 | std::format("resetOCC: HOST is not running (OCC{})", occInstanceId) |
Chris Cain | 0f51652 | 2022-02-07 14:48:28 -0600 | [diff] [blame] | 472 | .c_str()); |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 473 | clearData(); |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 474 | } |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 475 | } |
| 476 | |
| 477 | void Interface::sendHRESET(open_power::occ::instanceID sbeInstanceId) |
| 478 | { |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 479 | if (open_power::occ::utils::isHostRunning()) |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 480 | { |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 481 | if (sbeInstanceToEffecter.empty()) |
| 482 | { |
| 483 | fetchEffecterInfo(PLDM_OEM_IBM_SBE_MAINTENANCE_STATE, |
| 484 | sbeInstanceToEffecter, SBEEffecterCount, |
| 485 | sbeMaintenanceStatePosition); |
| 486 | } |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 487 | |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 488 | auto effecterEntry = sbeInstanceToEffecter.find(sbeInstanceId); |
| 489 | if (effecterEntry == sbeInstanceToEffecter.end()) |
| 490 | { |
| 491 | log<level::ERR>( |
| 492 | "pldm: Failed to find a matching effecter for SBE instance", |
| 493 | entry("SBE=%d", sbeInstanceId)); |
| 494 | return; |
| 495 | } |
| 496 | |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 497 | // Prepare the SetStateEffecterStates request to HRESET the SBE |
| 498 | auto request = prepareSetEffecterReq( |
Chris Cain | 8b508bf | 2022-05-26 14:01:31 -0500 | [diff] [blame] | 499 | effecterEntry->second, SBEEffecterCount, |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 500 | sbeMaintenanceStatePosition, SBE_RETRY_REQUIRED); |
| 501 | |
| 502 | if (request.empty()) |
| 503 | { |
| 504 | log<level::ERR>( |
| 505 | "pldm: SetStateEffecterStates HRESET request empty"); |
| 506 | return; |
| 507 | } |
| 508 | |
| 509 | // Send request to issue HRESET of SBE (ignore response) |
| 510 | sendPldm(request, sbeInstanceId, false); |
Chris Cain | 12d0b82 | 2022-04-22 17:29:18 -0500 | [diff] [blame] | 511 | outstandingHResets.insert(sbeInstanceId); |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 512 | } |
| 513 | else |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 514 | { |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 515 | log<level::ERR>(std::format("sendHRESET: HOST is not running (OCC{})", |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 516 | sbeInstanceId) |
| 517 | .c_str()); |
| 518 | clearData(); |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 519 | } |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 520 | } |
| 521 | |
Rashmica Gupta | aeba51c | 2023-02-17 12:30:46 +1100 | [diff] [blame^] | 522 | bool Interface::getPldmInstanceId() |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 523 | { |
Rashmica Gupta | aeba51c | 2023-02-17 12:30:46 +1100 | [diff] [blame^] | 524 | if (!pldmInstanceID) |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 525 | { |
Chris Cain | 8b508bf | 2022-05-26 14:01:31 -0500 | [diff] [blame] | 526 | // Request new instance ID |
| 527 | auto& bus = open_power::occ::utils::getBus(); |
| 528 | try |
| 529 | { |
| 530 | auto method = bus.new_method_call( |
| 531 | "xyz.openbmc_project.PLDM", "/xyz/openbmc_project/pldm", |
| 532 | "xyz.openbmc_project.PLDM.Requester", "GetInstanceId"); |
| 533 | method.append(mctpEid); |
| 534 | auto reply = bus.call(method); |
| 535 | uint8_t newInstanceId; |
| 536 | reply.read(newInstanceId); |
Rashmica Gupta | aeba51c | 2023-02-17 12:30:46 +1100 | [diff] [blame^] | 537 | pldmInstanceID = newInstanceId; |
Chris Cain | 755af10 | 2024-02-27 16:09:51 -0600 | [diff] [blame] | 538 | if (!throttleTraces) |
| 539 | { |
| 540 | log<level::INFO>(std::format("pldm: got new InstanceId: {}", |
Rashmica Gupta | aeba51c | 2023-02-17 12:30:46 +1100 | [diff] [blame^] | 541 | pldmInstanceID.value()) |
Chris Cain | 755af10 | 2024-02-27 16:09:51 -0600 | [diff] [blame] | 542 | .c_str()); |
| 543 | } |
Chris Cain | 8b508bf | 2022-05-26 14:01:31 -0500 | [diff] [blame] | 544 | } |
Patrick Williams | af40808 | 2022-07-22 19:26:54 -0500 | [diff] [blame] | 545 | catch (const sdbusplus::exception_t& e) |
Chris Cain | 8b508bf | 2022-05-26 14:01:31 -0500 | [diff] [blame] | 546 | { |
| 547 | log<level::ERR>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 548 | std::format("pldm: GetInstanceId failed: {}", e.what()) |
Chris Cain | 8b508bf | 2022-05-26 14:01:31 -0500 | [diff] [blame] | 549 | .c_str()); |
| 550 | return false; |
| 551 | } |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 552 | } |
| 553 | |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 554 | return true; |
| 555 | } |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 556 | |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 557 | void Interface::sendPldm(const std::vector<uint8_t>& request, |
| 558 | const uint8_t instance, const bool rspExpected) |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 559 | { |
Rashmica Gupta | aeba51c | 2023-02-17 12:30:46 +1100 | [diff] [blame^] | 560 | if (!pldmInstanceID) |
Chris Cain | 8b508bf | 2022-05-26 14:01:31 -0500 | [diff] [blame] | 561 | { |
Rashmica Gupta | aeba51c | 2023-02-17 12:30:46 +1100 | [diff] [blame^] | 562 | log<level::ERR>("sendPldm: No PLDM Instance ID found!"); |
Chris Cain | 8b508bf | 2022-05-26 14:01:31 -0500 | [diff] [blame] | 563 | return; |
| 564 | } |
| 565 | |
Chris Cain | c9dc441 | 2023-03-06 15:56:34 -0600 | [diff] [blame] | 566 | // Connect to MCTP socket |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 567 | pldmFd = pldm_open(); |
| 568 | auto openErrno = errno; |
| 569 | if (pldmFd == PLDM_REQUESTER_OPEN_FAIL) |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 570 | { |
Chris Cain | d1b6826 | 2022-02-28 09:56:50 -0600 | [diff] [blame] | 571 | log<level::ERR>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 572 | std::format( |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 573 | "sendPldm: Failed to connect to MCTP socket, errno={}/{}", |
| 574 | openErrno, strerror(openErrno)) |
Chris Cain | d1b6826 | 2022-02-28 09:56:50 -0600 | [diff] [blame] | 575 | .c_str()); |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 576 | return; |
| 577 | } |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 578 | |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 579 | // Send the PLDM request message to HBRT |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 580 | if (rspExpected) |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 581 | { |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 582 | // Register callback when response is available |
| 583 | registerPldmRspCallback(); |
| 584 | |
| 585 | // Send PLDM request |
Chris Cain | 755af10 | 2024-02-27 16:09:51 -0600 | [diff] [blame] | 586 | if (!throttleTraces) |
| 587 | { |
| 588 | log<level::INFO>( |
| 589 | std::format( |
| 590 | "sendPldm: calling pldm_send(OCC{}, instance:{}, {} bytes)", |
Rashmica Gupta | aeba51c | 2023-02-17 12:30:46 +1100 | [diff] [blame^] | 591 | instance, pldmInstanceID.value(), request.size()) |
Chris Cain | 755af10 | 2024-02-27 16:09:51 -0600 | [diff] [blame] | 592 | .c_str()); |
| 593 | } |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 594 | pldmResponseReceived = false; |
| 595 | pldmResponseTimeout = false; |
| 596 | pldmResponseOcc = instance; |
Patrick Williams | a49c987 | 2023-05-10 07:50:35 -0500 | [diff] [blame] | 597 | auto pldmRc = pldm_send(mctpEid, pldmFd, request.data(), |
| 598 | request.size()); |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 599 | auto sendErrno = errno; |
| 600 | if (pldmRc != PLDM_REQUESTER_SUCCESS) |
| 601 | { |
| 602 | log<level::ERR>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 603 | std::format( |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 604 | "sendPldm: pldm_send failed with rc={} and errno={}/{}", |
Chris Cain | 5161a02 | 2023-08-15 10:07:12 -0500 | [diff] [blame] | 605 | static_cast< |
| 606 | std::underlying_type_t<pldm_requester_error_codes>>( |
| 607 | pldmRc), |
| 608 | sendErrno, strerror(sendErrno)) |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 609 | .c_str()); |
| 610 | pldmClose(); |
| 611 | return; |
| 612 | } |
| 613 | |
| 614 | // start timer waiting for the response |
| 615 | using namespace std::literals::chrono_literals; |
Chris Cain | bd551de | 2022-04-26 13:41:16 -0500 | [diff] [blame] | 616 | pldmRspTimer.restartOnce(8s); |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 617 | |
| 618 | // Wait for response/timeout |
| 619 | } |
| 620 | else // not expecting the response |
| 621 | { |
Chris Cain | 755af10 | 2024-02-27 16:09:51 -0600 | [diff] [blame] | 622 | if (!throttleTraces) |
| 623 | { |
| 624 | log<level::INFO>( |
| 625 | std::format( |
| 626 | "sendPldm: calling pldm_send(mctpID:{}, fd:{}, {} bytes) for OCC{}", |
| 627 | mctpEid, pldmFd, request.size(), instance) |
| 628 | .c_str()); |
| 629 | } |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 630 | auto rc = pldm_send(mctpEid, pldmFd, request.data(), request.size()); |
| 631 | auto sendErrno = errno; |
Chris Cain | d1b6826 | 2022-02-28 09:56:50 -0600 | [diff] [blame] | 632 | if (rc) |
| 633 | { |
| 634 | log<level::ERR>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 635 | std::format( |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 636 | "sendPldm: pldm_send(mctpID:{}, fd:{}, {} bytes) failed with rc={} and errno={}/{}", |
Chris Cain | 5161a02 | 2023-08-15 10:07:12 -0500 | [diff] [blame] | 637 | mctpEid, pldmFd, request.size(), |
| 638 | static_cast< |
| 639 | std::underlying_type_t<pldm_requester_error_codes>>(rc), |
| 640 | sendErrno, strerror(sendErrno)) |
Chris Cain | d1b6826 | 2022-02-28 09:56:50 -0600 | [diff] [blame] | 641 | .c_str()); |
| 642 | } |
Chris Cain | 8b508bf | 2022-05-26 14:01:31 -0500 | [diff] [blame] | 643 | else |
| 644 | { |
| 645 | // Not waiting for response, instance ID should be freed |
Rashmica Gupta | aeba51c | 2023-02-17 12:30:46 +1100 | [diff] [blame^] | 646 | pldmInstanceID = std::nullopt; |
Chris Cain | 8b508bf | 2022-05-26 14:01:31 -0500 | [diff] [blame] | 647 | } |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 648 | pldmClose(); |
| 649 | } |
| 650 | } |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 651 | |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 652 | // Attaches the FD to event loop and registers the callback handler |
| 653 | void Interface::registerPldmRspCallback() |
| 654 | { |
| 655 | decltype(eventSource.get()) sourcePtr = nullptr; |
| 656 | auto rc = sd_event_add_io(event.get(), &sourcePtr, pldmFd, EPOLLIN, |
| 657 | pldmRspCallback, this); |
| 658 | if (rc < 0) |
| 659 | { |
| 660 | log<level::ERR>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 661 | std::format( |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 662 | "registerPldmRspCallback: sd_event_add_io: Error({})={} : fd={}", |
| 663 | rc, strerror(-rc), pldmFd) |
| 664 | .c_str()); |
Chris Cain | d1b6826 | 2022-02-28 09:56:50 -0600 | [diff] [blame] | 665 | } |
| 666 | else |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 667 | { |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 668 | // puts sourcePtr in the event source. |
| 669 | eventSource.reset(sourcePtr); |
| 670 | } |
| 671 | } |
| 672 | |
| 673 | // Add a timer to the event loop, default 30s. |
| 674 | void Interface::pldmRspExpired() |
| 675 | { |
| 676 | if (!pldmResponseReceived) |
| 677 | { |
Chris Cain | 755af10 | 2024-02-27 16:09:51 -0600 | [diff] [blame] | 678 | if (!throttleTraces) |
| 679 | { |
| 680 | log<level::WARNING>( |
| 681 | std::format( |
| 682 | "pldmRspExpired: timerCallback - timeout waiting for pldm response for OCC{}", |
| 683 | pldmResponseOcc) |
| 684 | .c_str()); |
| 685 | } |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 686 | pldmResponseTimeout = true; |
| 687 | if (pldmFd) |
| 688 | { |
| 689 | pldmClose(); |
| 690 | } |
| 691 | } |
| 692 | return; |
| 693 | }; |
| 694 | |
| 695 | void Interface::pldmClose() |
| 696 | { |
| 697 | if (pldmRspTimer.isEnabled()) |
| 698 | { |
| 699 | // stop PLDM response timer |
| 700 | pldmRspTimer.setEnabled(false); |
| 701 | } |
Pavithra Barithaya | 159a227 | 2023-09-27 06:10:55 -0500 | [diff] [blame] | 702 | pldm_close(); |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 703 | pldmFd = -1; |
| 704 | eventSource.reset(); |
| 705 | } |
| 706 | |
| 707 | int Interface::pldmRspCallback(sd_event_source* /*es*/, int fd, |
| 708 | uint32_t revents, void* userData) |
| 709 | { |
| 710 | if (!(revents & EPOLLIN)) |
| 711 | { |
| 712 | log<level::INFO>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 713 | std::format("pldmRspCallback - revents={:08X}", revents).c_str()); |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 714 | return -1; |
| 715 | } |
| 716 | |
| 717 | auto pldmIface = static_cast<Interface*>(userData); |
| 718 | |
Rashmica Gupta | aeba51c | 2023-02-17 12:30:46 +1100 | [diff] [blame^] | 719 | if (!pldmIface->pldmInstanceID) |
Chris Cain | 8b508bf | 2022-05-26 14:01:31 -0500 | [diff] [blame] | 720 | { |
| 721 | log<level::ERR>( |
Rashmica Gupta | aeba51c | 2023-02-17 12:30:46 +1100 | [diff] [blame^] | 722 | "pldmRspCallback: No outstanding PLDM Instance ID found"); |
Chris Cain | 8b508bf | 2022-05-26 14:01:31 -0500 | [diff] [blame] | 723 | return -1; |
| 724 | } |
| 725 | |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 726 | uint8_t* responseMsg = nullptr; |
| 727 | size_t responseMsgSize{}; |
| 728 | |
Chris Cain | 755af10 | 2024-02-27 16:09:51 -0600 | [diff] [blame] | 729 | if (!throttleTraces) |
| 730 | { |
| 731 | log<level::INFO>( |
| 732 | std::format("pldmRspCallback: calling pldm_recv() instance:{}", |
Rashmica Gupta | aeba51c | 2023-02-17 12:30:46 +1100 | [diff] [blame^] | 733 | pldmIface->pldmInstanceID.value()) |
Chris Cain | 755af10 | 2024-02-27 16:09:51 -0600 | [diff] [blame] | 734 | .c_str()); |
| 735 | } |
Rashmica Gupta | aeba51c | 2023-02-17 12:30:46 +1100 | [diff] [blame^] | 736 | auto rc = pldm_recv(mctpEid, fd, pldmIface->pldmInstanceID.value(), |
Chris Cain | 8b508bf | 2022-05-26 14:01:31 -0500 | [diff] [blame] | 737 | &responseMsg, &responseMsgSize); |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 738 | int lastErrno = errno; |
| 739 | if (rc) |
| 740 | { |
Chris Cain | 755af10 | 2024-02-27 16:09:51 -0600 | [diff] [blame] | 741 | if (!throttleTraces) |
| 742 | { |
| 743 | log<level::ERR>( |
| 744 | std::format( |
| 745 | "pldmRspCallback: pldm_recv failed with rc={}, errno={}/{}", |
| 746 | static_cast< |
| 747 | std::underlying_type_t<pldm_requester_error_codes>>(rc), |
| 748 | lastErrno, strerror(lastErrno)) |
| 749 | .c_str()); |
| 750 | } |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 751 | return -1; |
| 752 | } |
Chris Cain | 8b508bf | 2022-05-26 14:01:31 -0500 | [diff] [blame] | 753 | |
| 754 | // We got the response for the PLDM request msg that was sent |
Chris Cain | 755af10 | 2024-02-27 16:09:51 -0600 | [diff] [blame] | 755 | if (!throttleTraces) |
| 756 | { |
| 757 | log<level::INFO>( |
| 758 | std::format("pldmRspCallback: pldm_recv() rsp was {} bytes", |
| 759 | responseMsgSize) |
| 760 | .c_str()); |
| 761 | } |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 762 | |
| 763 | if (pldmIface->pldmRspTimer.isEnabled()) |
| 764 | { |
| 765 | // stop PLDM response timer |
| 766 | pldmIface->pldmRspTimer.setEnabled(false); |
| 767 | } |
| 768 | |
Chris Cain | 8b508bf | 2022-05-26 14:01:31 -0500 | [diff] [blame] | 769 | // instance ID should be freed |
Rashmica Gupta | aeba51c | 2023-02-17 12:30:46 +1100 | [diff] [blame^] | 770 | pldmIface->pldmInstanceID = std::nullopt; |
Chris Cain | 8b508bf | 2022-05-26 14:01:31 -0500 | [diff] [blame] | 771 | |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 772 | // Set pointer to autodelete |
| 773 | std::unique_ptr<uint8_t, decltype(std::free)*> responseMsgPtr{responseMsg, |
| 774 | std::free}; |
| 775 | |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 776 | auto response = reinterpret_cast<pldm_msg*>(responseMsgPtr.get()); |
| 777 | if (response->payload[0] != PLDM_SUCCESS) |
| 778 | { |
| 779 | log<level::ERR>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 780 | std::format("pldmRspCallback: payload[0] was not success: {}", |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 781 | response->payload[0]) |
| 782 | .c_str()); |
| 783 | pldmIface->pldmClose(); |
| 784 | return -1; |
| 785 | } |
| 786 | |
| 787 | // Decode the response |
| 788 | uint8_t compCode = 0, sensorCount = 1; |
| 789 | get_sensor_state_field field[6]; |
| 790 | responseMsgSize -= sizeof(pldm_msg_hdr); |
| 791 | auto msgRc = decode_get_state_sensor_readings_resp( |
| 792 | response, responseMsgSize, &compCode, &sensorCount, field); |
| 793 | if ((msgRc != PLDM_SUCCESS) || (compCode != PLDM_SUCCESS)) |
| 794 | { |
| 795 | log<level::ERR>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 796 | std::format( |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 797 | "pldmRspCallback: decode_get_state_sensor_readings failed with rc={} and compCode={}", |
| 798 | msgRc, compCode) |
| 799 | .c_str()); |
| 800 | pldmIface->pldmClose(); |
| 801 | return -1; |
| 802 | } |
| 803 | |
| 804 | pldmIface->pldmClose(); |
| 805 | |
| 806 | const uint8_t instance = pldmIface->pldmResponseOcc; |
| 807 | const uint8_t occSensorState = field[0].present_state; |
| 808 | pldmIface->pldmResponseReceived = true; |
| 809 | |
| 810 | if (occSensorState == PLDM_STATE_SET_OPERATIONAL_RUNNING_STATUS_IN_SERVICE) |
| 811 | { |
| 812 | log<level::INFO>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 813 | std::format("pldmRspCallback: OCC{} is RUNNING", instance).c_str()); |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 814 | pldmIface->callBack(instance, true); |
| 815 | } |
Chris Cain | 733b201 | 2022-05-04 11:54:06 -0500 | [diff] [blame] | 816 | else if (occSensorState == |
| 817 | PLDM_STATE_SET_OPERATIONAL_RUNNING_STATUS_DORMANT) |
| 818 | { |
Chris Cain | 755af10 | 2024-02-27 16:09:51 -0600 | [diff] [blame] | 819 | log<level::ERR>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 820 | std::format( |
Chris Cain | 733b201 | 2022-05-04 11:54:06 -0500 | [diff] [blame] | 821 | "pldmRspCallback: OCC{} has now STOPPED and system is in SAFE MODE", |
| 822 | instance) |
| 823 | .c_str()); |
Sheldon Bailey | 31a2f13 | 2022-05-20 11:31:52 -0500 | [diff] [blame] | 824 | |
| 825 | // Setting safe mode true |
| 826 | pldmIface->safeModeCallBack(true); |
| 827 | |
Chris Cain | 733b201 | 2022-05-04 11:54:06 -0500 | [diff] [blame] | 828 | pldmIface->callBack(instance, false); |
| 829 | } |
Chris Cain | 755af10 | 2024-02-27 16:09:51 -0600 | [diff] [blame] | 830 | else if (occSensorState == |
| 831 | PLDM_STATE_SET_OPERATIONAL_RUNNING_STATUS_STOPPED) |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 832 | { |
| 833 | log<level::INFO>( |
Chris Cain | 755af10 | 2024-02-27 16:09:51 -0600 | [diff] [blame] | 834 | std::format("pldmRspCallback: OCC{} is not running", instance) |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 835 | .c_str()); |
Chris Cain | 755af10 | 2024-02-27 16:09:51 -0600 | [diff] [blame] | 836 | pldmIface->callBack(instance, false); |
| 837 | } |
| 838 | else |
| 839 | { |
| 840 | const size_t rspLength = responseMsgSize + sizeof(pldm_msg_hdr); |
| 841 | std::vector<std::uint8_t> pldmResponse(rspLength); |
| 842 | memcpy(&pldmResponse[0], reinterpret_cast<std::uint8_t*>(response), |
| 843 | rspLength); |
| 844 | if (!throttleTraces) |
Chris Cain | c9dc441 | 2023-03-06 15:56:34 -0600 | [diff] [blame] | 845 | { |
Chris Cain | 755af10 | 2024-02-27 16:09:51 -0600 | [diff] [blame] | 846 | log<level::WARNING>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 847 | std::format( |
Chris Cain | 755af10 | 2024-02-27 16:09:51 -0600 | [diff] [blame] | 848 | "pldmRspCallback: Unexpected State: {} - PLDM response ({} bytes) for OCC{}:", |
| 849 | occSensorState, rspLength, instance) |
Chris Cain | c9dc441 | 2023-03-06 15:56:34 -0600 | [diff] [blame] | 850 | .c_str()); |
| 851 | dump_hex(pldmResponse); |
| 852 | } |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 853 | } |
| 854 | |
| 855 | return 0; |
| 856 | }; |
| 857 | |
| 858 | std::vector<uint8_t> Interface::encodeGetStateSensorRequest(uint8_t instance, |
| 859 | uint16_t sensorId) |
| 860 | { |
Rashmica Gupta | aeba51c | 2023-02-17 12:30:46 +1100 | [diff] [blame^] | 861 | if (!getPldmInstanceId()) |
Chris Cain | 8b508bf | 2022-05-26 14:01:31 -0500 | [diff] [blame] | 862 | { |
| 863 | log<level::ERR>( |
Rashmica Gupta | aeba51c | 2023-02-17 12:30:46 +1100 | [diff] [blame^] | 864 | "encodeGetStateSensorRequest: failed to getPldmInstanceId"); |
Chris Cain | 8b508bf | 2022-05-26 14:01:31 -0500 | [diff] [blame] | 865 | return std::vector<uint8_t>(); |
| 866 | } |
| 867 | |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 868 | bitfield8_t sRearm = {0}; |
Patrick Williams | a49c987 | 2023-05-10 07:50:35 -0500 | [diff] [blame] | 869 | const size_t msgSize = sizeof(pldm_msg_hdr) + |
| 870 | PLDM_GET_STATE_SENSOR_READINGS_REQ_BYTES; |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 871 | std::vector<uint8_t> request(msgSize); |
Chris Cain | 8b508bf | 2022-05-26 14:01:31 -0500 | [diff] [blame] | 872 | |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 873 | auto msg = reinterpret_cast<pldm_msg*>(request.data()); |
Rashmica Gupta | aeba51c | 2023-02-17 12:30:46 +1100 | [diff] [blame^] | 874 | auto msgRc = encode_get_state_sensor_readings_req(pldmInstanceID.value(), |
Chris Cain | 8b508bf | 2022-05-26 14:01:31 -0500 | [diff] [blame] | 875 | sensorId, sRearm, 0, msg); |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 876 | if (msgRc != PLDM_SUCCESS) |
| 877 | { |
| 878 | log<level::ERR>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 879 | std::format( |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 880 | "encodeGetStateSensorRequest: Failed to encode sensorId:0x{:08X} for OCC{} (rc={})", |
| 881 | sensorId, instance, msgRc) |
| 882 | .c_str()); |
| 883 | } |
| 884 | return request; |
| 885 | } |
| 886 | |
| 887 | // Initiate query of the specified OCC Active Sensor |
| 888 | void Interface::checkActiveSensor(uint8_t instance) |
| 889 | { |
| 890 | static bool tracedOnce = false; |
| 891 | if (pldmFd > 0) |
| 892 | { |
Chris Cain | 755af10 | 2024-02-27 16:09:51 -0600 | [diff] [blame] | 893 | if (!throttleTraces && !tracedOnce) |
Chris Cain | d1b6826 | 2022-02-28 09:56:50 -0600 | [diff] [blame] | 894 | { |
Chris Cain | 755af10 | 2024-02-27 16:09:51 -0600 | [diff] [blame] | 895 | log<level::WARNING>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 896 | std::format( |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 897 | "checkActiveSensor: already waiting on OCC{} (fd={})", |
| 898 | pldmResponseOcc, pldmFd) |
Chris Cain | d1b6826 | 2022-02-28 09:56:50 -0600 | [diff] [blame] | 899 | .c_str()); |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 900 | tracedOnce = true; |
Chris Cain | d1b6826 | 2022-02-28 09:56:50 -0600 | [diff] [blame] | 901 | } |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 902 | return; |
| 903 | } |
| 904 | tracedOnce = false; |
| 905 | |
| 906 | if (!isOCCSensorCacheValid()) |
| 907 | { |
| 908 | fetchSensorInfo(PLDM_STATE_SET_OPERATIONAL_RUNNING_STATUS, |
| 909 | sensorToOCCInstance, OCCSensorOffset); |
| 910 | } |
| 911 | |
| 912 | // look up sensor id (key) based on instance |
| 913 | auto entry = std::find_if( |
| 914 | sensorToOCCInstance.begin(), sensorToOCCInstance.end(), |
| 915 | [instance](const auto& entry) { return instance == entry.second; }); |
| 916 | if (entry != sensorToOCCInstance.end()) |
| 917 | { |
| 918 | // Query the OCC Active Sensor state for this instance |
Chris Cain | 755af10 | 2024-02-27 16:09:51 -0600 | [diff] [blame] | 919 | if (!throttleTraces) |
| 920 | { |
| 921 | log<level::INFO>( |
| 922 | std::format("checkActiveSensor: OCC{} / sensorID: 0x{:04X}", |
| 923 | instance, entry->first) |
| 924 | .c_str()); |
| 925 | } |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 926 | |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 927 | // Encode GetStateSensorReadings PLDM message |
| 928 | auto request = encodeGetStateSensorRequest(instance, entry->first); |
| 929 | if (request.empty()) |
| 930 | { |
| 931 | return; |
| 932 | } |
| 933 | |
| 934 | // Send request to PLDM and setup callback for response |
| 935 | sendPldm(request, instance, true); |
| 936 | } |
| 937 | else |
| 938 | { |
Chris Cain | 755af10 | 2024-02-27 16:09:51 -0600 | [diff] [blame] | 939 | if (!throttleTraces) |
| 940 | { |
| 941 | log<level::ERR>( |
| 942 | std::format( |
| 943 | "checkActiveSensor: Unable to find PLDM sensor for OCC{}", |
| 944 | instance) |
| 945 | .c_str()); |
| 946 | log<level::INFO>( |
| 947 | "checkActiveSensor: fetching STATE_SET_OPERATIONAL_RUNNING_STATUS"); |
| 948 | } |
Chris Cain | 8cf7496 | 2022-06-29 08:45:16 -0500 | [diff] [blame] | 949 | fetchSensorInfo(PLDM_STATE_SET_OPERATIONAL_RUNNING_STATUS, |
| 950 | sensorToOCCInstance, OCCSensorOffset); |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 951 | } |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 952 | } |
| 953 | |
Chris Cain | 755af10 | 2024-02-27 16:09:51 -0600 | [diff] [blame] | 954 | void Interface::setTraceThrottle(const bool throttle) |
| 955 | { |
| 956 | if (throttle != throttleTraces) |
| 957 | { |
| 958 | if (throttle) |
| 959 | { |
| 960 | log<level::WARNING>("PLDM traces being throttled"); |
| 961 | } |
| 962 | else |
| 963 | { |
| 964 | log<level::INFO>("PLDM traces no longer being throttled"); |
| 965 | } |
| 966 | throttleTraces = throttle; |
| 967 | } |
| 968 | } |
| 969 | |
Patrick Williams | 05e9559 | 2021-09-02 09:28:14 -0500 | [diff] [blame] | 970 | } // namespace pldm |