1367144cfSMatt Spinler #pragma once 26b427cc8SMatt Spinler #include "additional_data.hpp" 36b427cc8SMatt Spinler 4367144cfSMatt Spinler #include <nlohmann/json.hpp> 52544b419SPatrick Williams 62544b419SPatrick Williams #include <filesystem> 7367144cfSMatt Spinler #include <optional> 8367144cfSMatt Spinler #include <string> 9711f1129SMatt Spinler #include <variant> 10367144cfSMatt Spinler #include <vector> 11367144cfSMatt Spinler 12367144cfSMatt Spinler namespace openpower 13367144cfSMatt Spinler { 14367144cfSMatt Spinler namespace pels 15367144cfSMatt Spinler { 16367144cfSMatt Spinler namespace message 17367144cfSMatt Spinler { 18367144cfSMatt Spinler 19367144cfSMatt Spinler constexpr auto registryFileName = "message_registry.json"; 200f717e10SHarisuddin Mohamed Isa enum class LookupType 210f717e10SHarisuddin Mohamed Isa { 220f717e10SHarisuddin Mohamed Isa name = 0, 230f717e10SHarisuddin Mohamed Isa reasonCode = 1 240f717e10SHarisuddin Mohamed Isa }; 250f717e10SHarisuddin Mohamed Isa 260f717e10SHarisuddin Mohamed Isa /** 27aadccc85SMatt Spinler * @brief A possible severity/system type combination 28aadccc85SMatt Spinler * 29aadccc85SMatt Spinler * If there is no system type defined for this entry, 30aadccc85SMatt Spinler * then the system field will be empty. 31aadccc85SMatt Spinler */ 32aadccc85SMatt Spinler struct RegistrySeverity 33aadccc85SMatt Spinler { 34aadccc85SMatt Spinler std::string system; 35aadccc85SMatt Spinler uint8_t severity; 36aadccc85SMatt Spinler }; 37aadccc85SMatt Spinler 38aadccc85SMatt Spinler /** 390f717e10SHarisuddin Mohamed Isa * @brief Represents the Documentation related fields in the message registry. 400f717e10SHarisuddin Mohamed Isa * It is part of the 'Entry' structure that will be filled in when 410f717e10SHarisuddin Mohamed Isa * an error is looked up in the registry. 420f717e10SHarisuddin Mohamed Isa * 430f717e10SHarisuddin Mohamed Isa * If a field is wrapped by std::optional, it means the field is 440f717e10SHarisuddin Mohamed Isa * optional in the JSON and higher level code knows how to handle it. 450f717e10SHarisuddin Mohamed Isa */ 460f717e10SHarisuddin Mohamed Isa struct DOC 470f717e10SHarisuddin Mohamed Isa { 480f717e10SHarisuddin Mohamed Isa /** 490f717e10SHarisuddin Mohamed Isa * @brief Description of error 500f717e10SHarisuddin Mohamed Isa */ 510f717e10SHarisuddin Mohamed Isa std::string description; 520f717e10SHarisuddin Mohamed Isa 530f717e10SHarisuddin Mohamed Isa /** 540f717e10SHarisuddin Mohamed Isa * @brief Error message field 550f717e10SHarisuddin Mohamed Isa */ 560f717e10SHarisuddin Mohamed Isa std::string message; 570f717e10SHarisuddin Mohamed Isa 580f717e10SHarisuddin Mohamed Isa /** 590f717e10SHarisuddin Mohamed Isa * @brief An optional vector of SRC word 6-9 to use as the source of the 600f717e10SHarisuddin Mohamed Isa * numeric arguments that will be substituted into any placeholder 610f717e10SHarisuddin Mohamed Isa * in the Message field. 620f717e10SHarisuddin Mohamed Isa */ 630f717e10SHarisuddin Mohamed Isa std::optional<std::vector<std::string>> messageArgSources; 640f717e10SHarisuddin Mohamed Isa }; 65367144cfSMatt Spinler 66367144cfSMatt Spinler /** 6793e2932fSMatt Spinler * @brief Represents the SRC related fields in the message registry. 6893e2932fSMatt Spinler * It is part of the 'Entry' structure that will be filled in when 6993e2932fSMatt Spinler * an error is looked up in the registry. 7093e2932fSMatt Spinler * 7193e2932fSMatt Spinler * If a field is wrapped by std::optional, it means the field is 7293e2932fSMatt Spinler * optional in the JSON and higher level code knows how to handle it. 7393e2932fSMatt Spinler */ 7493e2932fSMatt Spinler struct SRC 7593e2932fSMatt Spinler { 7693e2932fSMatt Spinler /** 7793e2932fSMatt Spinler * @brief SRC type - The first byte of the ASCII string 7893e2932fSMatt Spinler */ 7993e2932fSMatt Spinler uint8_t type; 8093e2932fSMatt Spinler 8193e2932fSMatt Spinler /** 8293e2932fSMatt Spinler * @brief The SRC reason code (2nd half of 4B 'ASCII string' word) 8393e2932fSMatt Spinler */ 8493e2932fSMatt Spinler uint16_t reasonCode; 8593e2932fSMatt Spinler 8693e2932fSMatt Spinler /** 8793e2932fSMatt Spinler * @brief An optional vector of SRC hexword numbers that should be used 8893e2932fSMatt Spinler * along with the SRC ASCII string to build the Symptom ID, which 8993e2932fSMatt Spinler * is a field in the Extended Header section. 9093e2932fSMatt Spinler */ 9193e2932fSMatt Spinler using WordNum = size_t; 9293e2932fSMatt Spinler std::optional<std::vector<WordNum>> symptomID; 9393e2932fSMatt Spinler 9493e2932fSMatt Spinler /** 9593e2932fSMatt Spinler * @brief Which AdditionalData fields to use to fill in the user defined 9693e2932fSMatt Spinler * SRC hexwords. 9793e2932fSMatt Spinler * 9893e2932fSMatt Spinler * For example, if the AdditionalData event log property contained 991a1b0dfbSHarisuddin Mohamed Isa * "CHIPNUM=42" and this map contained {6, {"CHIPNUM", "DESC"}}, then the 1001a1b0dfbSHarisuddin Mohamed Isa * code would put 42 into SRC hexword 6. 1011a1b0dfbSHarisuddin Mohamed Isa * 1021a1b0dfbSHarisuddin Mohamed Isa * AdditionalDataField specifies two fields from the SRC entry in the 1031a1b0dfbSHarisuddin Mohamed Isa * message registry: "AdditionalDataPropSource" and "Description" 10493e2932fSMatt Spinler */ 1051a1b0dfbSHarisuddin Mohamed Isa using AdditionalDataField = std::tuple<std::string, std::string>; 10693e2932fSMatt Spinler std::optional<std::map<WordNum, AdditionalDataField>> hexwordADFields; 10793e2932fSMatt Spinler 1083fe93e96SMatt Spinler /** 1093fe93e96SMatt Spinler * @brief If the Deconfigured flag should be set in hex word 5 1103fe93e96SMatt Spinler */ 1113fe93e96SMatt Spinler bool deconfigFlag; 1123fe93e96SMatt Spinler 113da5b76b2SMatt Spinler /** 114da5b76b2SMatt Spinler * @brief If the checkstop flag should be set in hex word 5 115da5b76b2SMatt Spinler */ 116da5b76b2SMatt Spinler bool checkstopFlag; 117da5b76b2SMatt Spinler SRCopenpower::pels::message::SRC118da5b76b2SMatt Spinler SRC() : type(0), reasonCode(0), deconfigFlag(false), checkstopFlag(false) {} 11993e2932fSMatt Spinler }; 12093e2932fSMatt Spinler 121711f1129SMatt Spinler struct AppCapture 122711f1129SMatt Spinler { 123711f1129SMatt Spinler std::string syslogID; 124711f1129SMatt Spinler size_t numLines; 125711f1129SMatt Spinler }; 126711f1129SMatt Spinler 127711f1129SMatt Spinler // Can specify either the syslog IDs to capture along with how many 128711f1129SMatt Spinler // entries of each, or just how many entries to get the full journal. 129711f1129SMatt Spinler using AppCaptureList = std::vector<AppCapture>; 130711f1129SMatt Spinler using JournalCapture = std::variant<size_t, AppCaptureList>; 131711f1129SMatt Spinler 13293e2932fSMatt Spinler /** 133367144cfSMatt Spinler * @brief Represents a message registry entry, which is used for creating a 134367144cfSMatt Spinler * PEL from an OpenBMC event log. 135367144cfSMatt Spinler */ 136367144cfSMatt Spinler struct Entry 137367144cfSMatt Spinler { 138367144cfSMatt Spinler /** 139367144cfSMatt Spinler * @brief The error name, like "xyz.openbmc_project.Error.Foo". 140367144cfSMatt Spinler */ 141367144cfSMatt Spinler std::string name; 142367144cfSMatt Spinler 143367144cfSMatt Spinler /** 14493e2932fSMatt Spinler * @brief The component ID of the PEL creator. 14593e2932fSMatt Spinler */ 14693e2932fSMatt Spinler uint16_t componentID; 14793e2932fSMatt Spinler 14893e2932fSMatt Spinler /** 149367144cfSMatt Spinler * @brief The PEL subsystem field. 150367144cfSMatt Spinler */ 15123970b0dSMatt Spinler std::optional<uint8_t> subsystem; 152367144cfSMatt Spinler 153367144cfSMatt Spinler /** 154367144cfSMatt Spinler * @brief The optional PEL severity field. If not specified, the PEL 155367144cfSMatt Spinler * will use the severity of the OpenBMC event log. 156aadccc85SMatt Spinler * 157aadccc85SMatt Spinler * If the system type is specified in any of the entries in the vector, 158aadccc85SMatt Spinler * then the system type will be needed to find the actual severity. 159367144cfSMatt Spinler */ 160aadccc85SMatt Spinler std::optional<std::vector<RegistrySeverity>> severity; 161367144cfSMatt Spinler 162367144cfSMatt Spinler /** 163367144cfSMatt Spinler * @brief The optional severity field to use when in manufacturing tolerance 164aadccc85SMatt Spinler * mode. It behaves like the severity field above. 165367144cfSMatt Spinler */ 166aadccc85SMatt Spinler std::optional<std::vector<RegistrySeverity>> mfgSeverity; 167367144cfSMatt Spinler 168367144cfSMatt Spinler /** 169367144cfSMatt Spinler * @brief The PEL action flags field. 170367144cfSMatt Spinler */ 171e07f915bSMatt Spinler std::optional<uint16_t> actionFlags; 172367144cfSMatt Spinler 173367144cfSMatt Spinler /** 174367144cfSMatt Spinler * @brief The optional action flags to use instead when in manufacturing 175367144cfSMatt Spinler * tolerance mode. 176367144cfSMatt Spinler */ 177367144cfSMatt Spinler std::optional<uint16_t> mfgActionFlags; 178367144cfSMatt Spinler 179367144cfSMatt Spinler /** 180367144cfSMatt Spinler * @brief The PEL event type field. If not specified, higher level code 181367144cfSMatt Spinler * will decide the value. 182367144cfSMatt Spinler */ 183367144cfSMatt Spinler std::optional<uint8_t> eventType; 184367144cfSMatt Spinler 185367144cfSMatt Spinler /** 186367144cfSMatt Spinler * @brief The PEL event scope field. If not specified, higher level code 187367144cfSMatt Spinler * will decide the value. 188367144cfSMatt Spinler */ 189367144cfSMatt Spinler std::optional<uint8_t> eventScope; 190367144cfSMatt Spinler 19193e2932fSMatt Spinler /** 19293e2932fSMatt Spinler * The SRC related fields. 19393e2932fSMatt Spinler */ 19493e2932fSMatt Spinler SRC src; 1950f717e10SHarisuddin Mohamed Isa 1960f717e10SHarisuddin Mohamed Isa /** 1970f717e10SHarisuddin Mohamed Isa * The Documentation related fields. 1980f717e10SHarisuddin Mohamed Isa */ 1990f717e10SHarisuddin Mohamed Isa DOC doc; 200d8e29000SMatt Spinler 201d8e29000SMatt Spinler /** 202d8e29000SMatt Spinler * @brief The callout JSON, if the entry has callouts. 203d8e29000SMatt Spinler */ 204d8e29000SMatt Spinler std::optional<nlohmann::json> callouts; 205711f1129SMatt Spinler 206711f1129SMatt Spinler /** 207711f1129SMatt Spinler * @brief The journal capture instructions, if present. 208711f1129SMatt Spinler */ 209711f1129SMatt Spinler std::optional<JournalCapture> journalCapture; 210367144cfSMatt Spinler }; 211367144cfSMatt Spinler 212367144cfSMatt Spinler /** 2136b427cc8SMatt Spinler * @brief Holds callout information pulled out of the JSON. 2146b427cc8SMatt Spinler */ 2156b427cc8SMatt Spinler struct RegistryCallout 2166b427cc8SMatt Spinler { 2176b427cc8SMatt Spinler std::string priority; 2186b427cc8SMatt Spinler std::string locCode; 2196b427cc8SMatt Spinler std::string procedure; 2206b427cc8SMatt Spinler std::string symbolicFRU; 2216b427cc8SMatt Spinler std::string symbolicFRUTrusted; 222f00f9d0fSMatt Spinler bool useInventoryLocCode; 2236b427cc8SMatt Spinler }; 2246b427cc8SMatt Spinler 2256b427cc8SMatt Spinler /** 226367144cfSMatt Spinler * @class Registry 227367144cfSMatt Spinler * 228367144cfSMatt Spinler * This class wraps the message registry JSON data and allows one to find 229367144cfSMatt Spinler * the message registry entry pertaining to the error name. 230367144cfSMatt Spinler * 231367144cfSMatt Spinler * So that new registry files can easily be tested, the code will look for 232367144cfSMatt Spinler * /etc/phosphor-logging/message_registry.json before looking for the real 233367144cfSMatt Spinler * path. 234367144cfSMatt Spinler */ 235367144cfSMatt Spinler class Registry 236367144cfSMatt Spinler { 237367144cfSMatt Spinler public: 238367144cfSMatt Spinler Registry() = delete; 239367144cfSMatt Spinler ~Registry() = default; 240367144cfSMatt Spinler Registry(const Registry&) = default; 241367144cfSMatt Spinler Registry& operator=(const Registry&) = default; 242367144cfSMatt Spinler Registry(Registry&&) = default; 243367144cfSMatt Spinler Registry& operator=(Registry&&) = default; 244367144cfSMatt Spinler 245367144cfSMatt Spinler /** 246367144cfSMatt Spinler * @brief Constructor 247d8e29000SMatt Spinler * 248d8e29000SMatt Spinler * Will load the callout JSON. 249d8e29000SMatt Spinler * 250367144cfSMatt Spinler * @param[in] registryFile - The path to the file. 251367144cfSMatt Spinler */ Registry(const std::filesystem::path & registryFile)252367144cfSMatt Spinler explicit Registry(const std::filesystem::path& registryFile) : 253d8e29000SMatt Spinler Registry(registryFile, true) 2542544b419SPatrick Williams {} 255d8e29000SMatt Spinler 256d8e29000SMatt Spinler /** 257d8e29000SMatt Spinler * @brief Constructor 258d8e29000SMatt Spinler * 259d8e29000SMatt Spinler * This version contains a parameter that allows the callout JSON 260d8e29000SMatt Spinler * to be saved in the Entry struct or not, as it isn't needed at 261d8e29000SMatt Spinler * all in some cases. 262d8e29000SMatt Spinler * 263d8e29000SMatt Spinler * @param[in] registryFile - The path to the file. 264d8e29000SMatt Spinler * @param[in] loadCallouts - If the callout JSON should be saved. 265d8e29000SMatt Spinler */ Registry(const std::filesystem::path & registryFile,bool loadCallouts)266d8e29000SMatt Spinler explicit Registry(const std::filesystem::path& registryFile, 267d8e29000SMatt Spinler bool loadCallouts) : 268075c7923SPatrick Williams _registryFile(registryFile), _loadCallouts(loadCallouts) 2692544b419SPatrick Williams {} 270367144cfSMatt Spinler 271367144cfSMatt Spinler /** 2720f717e10SHarisuddin Mohamed Isa * @brief Find a registry entry based on its error name or reason code. 273367144cfSMatt Spinler * 274367144cfSMatt Spinler * This function does do some basic sanity checking on the JSON contents, 275367144cfSMatt Spinler * but there is also an external program that enforces a schema on the 276367144cfSMatt Spinler * registry JSON that should catch all of these problems ahead of time. 277367144cfSMatt Spinler * 278367144cfSMatt Spinler * @param[in] name - The error name, like xyz.openbmc_project.Error.Foo 2790f717e10SHarisuddin Mohamed Isa * - OR 2800f717e10SHarisuddin Mohamed Isa * - The reason code, like 0x1001 2810f717e10SHarisuddin Mohamed Isa * @param[in] type - LookupType enum value 2820f717e10SHarisuddin Mohamed Isa * @param[in] toCache - boolean to cache registry in memory 283367144cfSMatt Spinler * @return optional<Entry> A filled in message registry structure if 284367144cfSMatt Spinler * found, otherwise an empty optional object. 285367144cfSMatt Spinler */ 2860f717e10SHarisuddin Mohamed Isa std::optional<Entry> lookup(const std::string& name, LookupType type, 2870f717e10SHarisuddin Mohamed Isa bool toCache = false); 288367144cfSMatt Spinler 2896b427cc8SMatt Spinler /** 2906b427cc8SMatt Spinler * @brief Find the callouts to put into the PEL based on the calloutJSON 2916b427cc8SMatt Spinler * data. 2926b427cc8SMatt Spinler * 2936b427cc8SMatt Spinler * The system type and AdditionalData are used to index into the correct 2946b427cc8SMatt Spinler * callout table. 2956b427cc8SMatt Spinler * 2966b427cc8SMatt Spinler * Throws exceptions on failures. 2976b427cc8SMatt Spinler * 2986b427cc8SMatt Spinler * @param[in] calloutJSON - Where to look up the callouts 2996ea4d5f7SMatt Spinler * @param[in] systemNames - List of compatible system type names 3006b427cc8SMatt Spinler * @param[in] additionalData - The AdditionalData property 3016b427cc8SMatt Spinler * 3026b427cc8SMatt Spinler * @return std::vector<RegistryCallout> - The callouts to use 3036b427cc8SMatt Spinler */ 304*25291157SPatrick Williams static std::vector<RegistryCallout> getCallouts( 305*25291157SPatrick Williams const nlohmann::json& calloutJSON, 3066ea4d5f7SMatt Spinler const std::vector<std::string>& systemNames, 3076b427cc8SMatt Spinler const AdditionalData& additionalData); 3086b427cc8SMatt Spinler 309367144cfSMatt Spinler private: 310367144cfSMatt Spinler /** 3110f717e10SHarisuddin Mohamed Isa * @brief Parse message registry file using nlohmann::json 3120f717e10SHarisuddin Mohamed Isa * @param[in] registryFile - The message registry JSON file 3130f717e10SHarisuddin Mohamed Isa * @return optional<nlohmann::json> The full message registry object or an 3140f717e10SHarisuddin Mohamed Isa * empty optional object upon failure. 3150f717e10SHarisuddin Mohamed Isa */ 316*25291157SPatrick Williams std::optional<nlohmann::json> readRegistry( 317*25291157SPatrick Williams const std::filesystem::path& registryFile); 3180f717e10SHarisuddin Mohamed Isa 3190f717e10SHarisuddin Mohamed Isa /** 320367144cfSMatt Spinler * @brief The path to the registry JSON file. 321367144cfSMatt Spinler */ 322367144cfSMatt Spinler std::filesystem::path _registryFile; 3230f717e10SHarisuddin Mohamed Isa 3240f717e10SHarisuddin Mohamed Isa /** 3250f717e10SHarisuddin Mohamed Isa * @brief The full message registry object. 3260f717e10SHarisuddin Mohamed Isa */ 3270f717e10SHarisuddin Mohamed Isa std::optional<nlohmann::json> _registry; 328d8e29000SMatt Spinler 329d8e29000SMatt Spinler /** 330d8e29000SMatt Spinler * @brief If the callout JSON should be saved in the Entry on lookup. 331d8e29000SMatt Spinler */ 332d8e29000SMatt Spinler bool _loadCallouts; 333367144cfSMatt Spinler }; 334367144cfSMatt Spinler 335367144cfSMatt Spinler namespace helper 336367144cfSMatt Spinler { 337367144cfSMatt Spinler 338367144cfSMatt Spinler /** 339367144cfSMatt Spinler * @brief A helper function to get the PEL subsystem value based on 340367144cfSMatt Spinler * the registry subsystem name. 341367144cfSMatt Spinler * 342367144cfSMatt Spinler * @param[in] subsystemName - The registry name for the subsystem 343367144cfSMatt Spinler * 344367144cfSMatt Spinler * @return uint8_t The PEL subsystem value 345367144cfSMatt Spinler */ 346367144cfSMatt Spinler uint8_t getSubsystem(const std::string& subsystemName); 347367144cfSMatt Spinler 348367144cfSMatt Spinler /** 349367144cfSMatt Spinler * @brief A helper function to get the PEL severity value based on 350367144cfSMatt Spinler * the registry severity name. 351367144cfSMatt Spinler * 352367144cfSMatt Spinler * @param[in] severityName - The registry name for the severity 353367144cfSMatt Spinler * 354367144cfSMatt Spinler * @return uint8_t The PEL severity value 355367144cfSMatt Spinler */ 356367144cfSMatt Spinler uint8_t getSeverity(const std::string& severityName); 357367144cfSMatt Spinler 358367144cfSMatt Spinler /** 359aadccc85SMatt Spinler * @brief Returns all of the system type/severity values found 360aadccc85SMatt Spinler * in the severity JSON passed in. 361aadccc85SMatt Spinler * 362aadccc85SMatt Spinler * The JSON is either a simple string, like: 363aadccc85SMatt Spinler * "unrecoverable" 364aadccc85SMatt Spinler * or an array of system type/severity pairs, like: 365aadccc85SMatt Spinler * [ 366aadccc85SMatt Spinler * { 367aadccc85SMatt Spinler * "System": "1", 368aadccc85SMatt Spinler * "SevValue": "predictive" 369aadccc85SMatt Spinler * }, 370aadccc85SMatt Spinler * { 371aadccc85SMatt Spinler * "System": "2", 372aadccc85SMatt Spinler * "SevValue": "recovered" 373aadccc85SMatt Spinler * } 374aadccc85SMatt Spinler * ] 375aadccc85SMatt Spinler * 376aadccc85SMatt Spinler * @param[in] severity - The severity JSON 377aadccc85SMatt Spinler * @return The list of severity/system combinations. If the System key 378aadccc85SMatt Spinler * wasn't used, then that field will be empty in the structure. 379aadccc85SMatt Spinler */ 380aadccc85SMatt Spinler std::vector<RegistrySeverity> getSeverities(const nlohmann::json& severity); 381aadccc85SMatt Spinler 382aadccc85SMatt Spinler /** 383367144cfSMatt Spinler * @brief A helper function to get the action flags value based on 384367144cfSMatt Spinler * the action flag names used in the registry. 385367144cfSMatt Spinler * 386367144cfSMatt Spinler * @param[in] flags - The list of flag names from the registry. 387367144cfSMatt Spinler * 388367144cfSMatt Spinler * @return uint16_t - The bitfield of flags used in the PEL. 389367144cfSMatt Spinler */ 390367144cfSMatt Spinler uint16_t getActionFlags(const std::vector<std::string>& flags); 391367144cfSMatt Spinler 392367144cfSMatt Spinler /** 393367144cfSMatt Spinler * @brief A helper function to get the PEL event type value based on 394367144cfSMatt Spinler * the registry event type name. 395367144cfSMatt Spinler * 396367144cfSMatt Spinler * @param[in] eventTypeName - The registry name for the event type 397367144cfSMatt Spinler * 398367144cfSMatt Spinler * @return uint8_t The PEL event type value 399367144cfSMatt Spinler */ 400367144cfSMatt Spinler uint8_t getEventType(const std::string& eventTypeName); 401367144cfSMatt Spinler 402367144cfSMatt Spinler /** 403367144cfSMatt Spinler * @brief A helper function to get the PEL event scope value based on 404367144cfSMatt Spinler * the registry event scope name. 405367144cfSMatt Spinler * 406367144cfSMatt Spinler * @param[in] eventScopeName - The registry name for the event scope 407367144cfSMatt Spinler * 408367144cfSMatt Spinler * @return uint8_t The PEL event scope value 409367144cfSMatt Spinler */ 410367144cfSMatt Spinler uint8_t getEventScope(const std::string& eventScopeName); 411367144cfSMatt Spinler 41293e2932fSMatt Spinler /** 41393e2932fSMatt Spinler * @brief Reads the "ReasonCode" field out of JSON and converts the string value 41493e2932fSMatt Spinler * such as "0x5555" to a uint16 like 0x5555. 41593e2932fSMatt Spinler * 41693e2932fSMatt Spinler * @param[in] src - The message registry SRC dictionary to read from 41793e2932fSMatt Spinler * @param[in] name - The error name, to use in a trace if things go awry. 41893e2932fSMatt Spinler * 41993e2932fSMatt Spinler * @return uint16_t - The reason code 42093e2932fSMatt Spinler */ 42193e2932fSMatt Spinler uint16_t getSRCReasonCode(const nlohmann::json& src, const std::string& name); 42293e2932fSMatt Spinler 42393e2932fSMatt Spinler /** 42493e2932fSMatt Spinler * @brief Reads the "Type" field out of JSON and converts it to the SRC::Type 42593e2932fSMatt Spinler * value. 42693e2932fSMatt Spinler * 42793e2932fSMatt Spinler * @param[in] src - The message registry SRC dictionary to read from 42893e2932fSMatt Spinler * @param[in] name - The error name, to use in a trace if things go awry. 42993e2932fSMatt Spinler * 43093e2932fSMatt Spinler * @return uint8_t - The SRC type value, like 0x11 43193e2932fSMatt Spinler */ 43293e2932fSMatt Spinler uint8_t getSRCType(const nlohmann::json& src, const std::string& name); 43393e2932fSMatt Spinler 43493e2932fSMatt Spinler /** 43593e2932fSMatt Spinler * @brief Reads the "Words6To9" field out of JSON and converts it to a map 43693e2932fSMatt Spinler * of the SRC word number to the AdditionalData property field used 43793e2932fSMatt Spinler * to fill it in with. 43893e2932fSMatt Spinler * 43993e2932fSMatt Spinler * @param[in] src - The message registry SRC dictionary to read from 44093e2932fSMatt Spinler * @param[in] name - The error name, to use in a trace if things go awry. 44193e2932fSMatt Spinler * 44293e2932fSMatt Spinler * @return std::optional<std::map<SRC::WordNum, SRC::AdditionalDataField>> 44393e2932fSMatt Spinler */ 44493e2932fSMatt Spinler std::optional<std::map<SRC::WordNum, SRC::AdditionalDataField>> 44593e2932fSMatt Spinler getSRCHexwordFields(const nlohmann::json& src, const std::string& name); 44693e2932fSMatt Spinler 44793e2932fSMatt Spinler /** 44893e2932fSMatt Spinler * @brief Reads the "SymptomIDFields" field out of JSON and converts it to 44993e2932fSMatt Spinler * a vector of SRC word numbers. 45093e2932fSMatt Spinler * 45193e2932fSMatt Spinler * @param[in] src - The message registry SRC dictionary to read from 45293e2932fSMatt Spinler * @param[in] name - The error name, to use in a trace if things go awry. 45393e2932fSMatt Spinler * 45493e2932fSMatt Spinler * @return std::optional<std::vector<SRC::WordNum>> 45593e2932fSMatt Spinler */ 456*25291157SPatrick Williams std::optional<std::vector<SRC::WordNum>> getSRCSymptomIDFields( 457*25291157SPatrick Williams const nlohmann::json& src, const std::string& name); 45893e2932fSMatt Spinler 45993e2932fSMatt Spinler /** 4603fe93e96SMatt Spinler * @brief Returns the value of the 'DeconfigFlag' field. 4613fe93e96SMatt Spinler * 4623fe93e96SMatt Spinler * @param[in] src - The message registry SRC dictionary to read from 4633fe93e96SMatt Spinler * 4643fe93e96SMatt Spinler * @return bool - The field value 4653fe93e96SMatt Spinler */ 4663fe93e96SMatt Spinler bool getSRCDeconfigFlag(const nlohmann::json& src); 4673fe93e96SMatt Spinler 4683fe93e96SMatt Spinler /** 46993e2932fSMatt Spinler * @brief Reads the "ComponentID" field out of JSON and converts it to a 47093e2932fSMatt Spinler * uint16_t like 0xFF00. 47193e2932fSMatt Spinler * 47293e2932fSMatt Spinler * The ComponentID JSON field is only required if the SRC type isn't a BD 47393e2932fSMatt Spinler * BMC SRC, because for those SRCs it can be inferred from the upper byte 47493e2932fSMatt Spinler * of the SRC reasoncode. 47593e2932fSMatt Spinler * 47693e2932fSMatt Spinler * @param[in] srcType - The SRC type 47793e2932fSMatt Spinler * @param[in] reasonCode - The SRC reason code 47893e2932fSMatt Spinler * @param[in] pelEntry - The PEL entry JSON 47993e2932fSMatt Spinler * @param[in] name - The error name, to use in a trace if things go awry. 48093e2932fSMatt Spinler * 48193e2932fSMatt Spinler * @return uin16_t - The component ID, like 0xFF00 48293e2932fSMatt Spinler */ 48393e2932fSMatt Spinler uint16_t getComponentID(uint8_t srcType, uint16_t reasonCode, 48493e2932fSMatt Spinler const nlohmann::json& pelEntry, 48593e2932fSMatt Spinler const std::string& name); 48693e2932fSMatt Spinler 487367144cfSMatt Spinler } // namespace helper 488367144cfSMatt Spinler 489367144cfSMatt Spinler } // namespace message 490367144cfSMatt Spinler 491367144cfSMatt Spinler } // namespace pels 492367144cfSMatt Spinler } // namespace openpower 493