| Tom Joseph | 6b7a143 | 2017-05-19 10:43:36 +0530 | [diff] [blame] | 1 | #pragma once | 
|  | 2 |  | 
| Yong Li | 021f2d1 | 2018-09-26 16:09:22 +0800 | [diff] [blame] | 3 | #include <chrono> | 
| Tom Joseph | 6b7a143 | 2017-05-19 10:43:36 +0530 | [diff] [blame] | 4 | #include <cstdint> | 
| Vernon Mauery | 3325024 | 2019-03-12 16:49:26 -0700 | [diff] [blame] | 5 | #include <ipmid/types.hpp> | 
| Tom Joseph | 6b7a143 | 2017-05-19 10:43:36 +0530 | [diff] [blame] | 6 | #include <sdbusplus/server.hpp> | 
| Tom Joseph | 6b7a143 | 2017-05-19 10:43:36 +0530 | [diff] [blame] | 7 |  | 
|  | 8 | namespace ipmi | 
|  | 9 | { | 
|  | 10 |  | 
|  | 11 | namespace sel | 
|  | 12 | { | 
|  | 13 |  | 
|  | 14 | static constexpr auto mapperBusName = "xyz.openbmc_project.ObjectMapper"; | 
|  | 15 | static constexpr auto mapperObjPath = "/xyz/openbmc_project/object_mapper"; | 
|  | 16 | static constexpr auto mapperIntf = "xyz.openbmc_project.ObjectMapper"; | 
|  | 17 |  | 
|  | 18 | static constexpr auto logBasePath = "/xyz/openbmc_project/logging/entry"; | 
|  | 19 | static constexpr auto logEntryIntf = "xyz.openbmc_project.Logging.Entry"; | 
|  | 20 | static constexpr auto logDeleteIntf = "xyz.openbmc_project.Object.Delete"; | 
|  | 21 |  | 
|  | 22 | static constexpr auto propIntf = "org.freedesktop.DBus.Properties"; | 
|  | 23 |  | 
| Tom Joseph | 232f529 | 2017-07-07 20:14:02 +0530 | [diff] [blame] | 24 | using ObjectPaths = std::vector<std::string>; | 
| Tom Joseph | 306878b | 2017-07-10 19:30:54 +0530 | [diff] [blame] | 25 | using PropertyName = std::string; | 
|  | 26 | using Resolved = bool; | 
|  | 27 | using Id = uint32_t; | 
|  | 28 | using Timestamp = uint64_t; | 
|  | 29 | using Message = std::string; | 
|  | 30 | using AdditionalData = std::vector<std::string>; | 
| Vernon Mauery | 16b8693 | 2019-05-01 08:36:11 -0700 | [diff] [blame] | 31 | using PropertyType = | 
|  | 32 | std::variant<Resolved, Id, Timestamp, Message, AdditionalData>; | 
| Tom Joseph | 6b7a143 | 2017-05-19 10:43:36 +0530 | [diff] [blame] | 33 |  | 
| Tom Joseph | 6f7deaa | 2017-06-30 19:03:54 +0530 | [diff] [blame] | 34 | static constexpr auto selVersion = 0x51; | 
|  | 35 | static constexpr auto invalidTimeStamp = 0xFFFFFFFF; | 
| Tom Joseph | 6f7deaa | 2017-06-30 19:03:54 +0530 | [diff] [blame] | 36 |  | 
| Tom Joseph | a495339 | 2017-06-30 19:09:47 +0530 | [diff] [blame] | 37 | static constexpr auto firstEntry = 0x0000; | 
|  | 38 | static constexpr auto lastEntry = 0xFFFF; | 
|  | 39 | static constexpr auto entireRecord = 0xFF; | 
|  | 40 | static constexpr auto selRecordSize = 16; | 
|  | 41 |  | 
| jayaprakash Mutyala | b755772 | 2019-05-02 21:13:30 +0000 | [diff] [blame] | 42 | namespace operationSupport | 
|  | 43 | { | 
|  | 44 | static constexpr bool overflow = false; | 
|  | 45 | static constexpr bool deleteSel = true; | 
|  | 46 | static constexpr bool partialAddSelEntry = false; | 
|  | 47 | static constexpr bool reserveSel = true; | 
|  | 48 | static constexpr bool getSelAllocationInfo = false; | 
|  | 49 | } // namespace operationSupport | 
|  | 50 |  | 
| Tom Joseph | a495339 | 2017-06-30 19:09:47 +0530 | [diff] [blame] | 51 | /** @struct GetSELEntryRequest | 
|  | 52 | * | 
|  | 53 | *  IPMI payload for Get SEL Entry command request. | 
|  | 54 | */ | 
|  | 55 | struct GetSELEntryRequest | 
|  | 56 | { | 
| Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 57 | uint16_t reservationID; //!< Reservation ID. | 
|  | 58 | uint16_t selRecordID;   //!< SEL Record ID. | 
|  | 59 | uint8_t offset;         //!< Offset into record. | 
|  | 60 | uint8_t readLength;     //!< Bytes to read. | 
| Tom Joseph | a495339 | 2017-06-30 19:09:47 +0530 | [diff] [blame] | 61 | } __attribute__((packed)); | 
|  | 62 |  | 
| Tom Joseph | 6b7a143 | 2017-05-19 10:43:36 +0530 | [diff] [blame] | 63 | /** @struct GetSELEntryResponse | 
|  | 64 | * | 
|  | 65 | *  IPMI payload for Get SEL Entry command response. | 
|  | 66 | */ | 
|  | 67 | struct GetSELEntryResponse | 
|  | 68 | { | 
| Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 69 | uint16_t nextRecordID;    //!< Next RecordID. | 
|  | 70 | uint16_t recordID;        //!< Record ID. | 
|  | 71 | uint8_t recordType;       //!< Record Type. | 
|  | 72 | uint32_t timeStamp;       //!< Timestamp. | 
|  | 73 | uint16_t generatorID;     //!< Generator ID. | 
|  | 74 | uint8_t eventMsgRevision; //!< Event Message Revision. | 
|  | 75 | uint8_t sensorType;       //!< Sensor Type. | 
|  | 76 | uint8_t sensorNum;        //!< Sensor Number. | 
|  | 77 | uint8_t eventType;        //!< Event Dir | Event Type. | 
|  | 78 | uint8_t eventData1;       //!< Event Data 1. | 
|  | 79 | uint8_t eventData2;       //!< Event Data 2. | 
|  | 80 | uint8_t eventData3;       //!< Event Data 3. | 
| Tom Joseph | 6b7a143 | 2017-05-19 10:43:36 +0530 | [diff] [blame] | 81 | } __attribute__((packed)); | 
|  | 82 |  | 
| Tom Joseph | 2f05bb5 | 2017-06-30 19:14:49 +0530 | [diff] [blame] | 83 | static constexpr auto initiateErase = 0xAA; | 
|  | 84 | static constexpr auto getEraseStatus = 0x00; | 
|  | 85 | static constexpr auto eraseComplete = 0x01; | 
|  | 86 |  | 
| Tom Joseph | 6edc8a0 | 2017-06-30 18:52:56 +0530 | [diff] [blame] | 87 | /** @brief Convert logging entry to SEL | 
|  | 88 | * | 
|  | 89 | *  @param[in] objPath - DBUS object path of the logging entry. | 
|  | 90 | * | 
|  | 91 | *  @return On success return the response of Get SEL entry command. | 
|  | 92 | */ | 
|  | 93 | GetSELEntryResponse convertLogEntrytoSEL(const std::string& objPath); | 
|  | 94 |  | 
| Tom Joseph | 399fd92 | 2017-06-30 18:40:30 +0530 | [diff] [blame] | 95 | /** @brief Get the timestamp of the log entry | 
|  | 96 | * | 
|  | 97 | *  @param[in] objPath - DBUS object path of the logging entry. | 
|  | 98 | * | 
|  | 99 | *  @return On success return the timestamp of the log entry as number of | 
|  | 100 | *          seconds from epoch. | 
|  | 101 | */ | 
|  | 102 | std::chrono::seconds getEntryTimeStamp(const std::string& objPath); | 
| Tom Joseph | 6edc8a0 | 2017-06-30 18:52:56 +0530 | [diff] [blame] | 103 |  | 
| Tom Joseph | 232f529 | 2017-07-07 20:14:02 +0530 | [diff] [blame] | 104 | /** @brief Read the logging entry object paths | 
|  | 105 | * | 
|  | 106 | *  This API would read the logging dbus logging entry object paths and sorting | 
|  | 107 | *  the filename in the numeric order. The paths is cleared before populating | 
|  | 108 | *  the object paths. | 
|  | 109 | * | 
|  | 110 | *  @param[in,out] paths - sorted list of logging entry object paths. | 
|  | 111 | * | 
|  | 112 | *  @note This function is invoked when the Get SEL Info command or the Delete | 
|  | 113 | *        SEL entry command is invoked. The Get SEL Entry command is preceded | 
|  | 114 | *        typically by Get SEL Info command, so readLoggingObjectPaths is not | 
|  | 115 | *        invoked before each Get SEL entry command. | 
|  | 116 | */ | 
|  | 117 | void readLoggingObjectPaths(ObjectPaths& paths); | 
|  | 118 |  | 
| Tom Joseph | 6b7a143 | 2017-05-19 10:43:36 +0530 | [diff] [blame] | 119 | namespace internal | 
|  | 120 | { | 
|  | 121 |  | 
|  | 122 | /** @brief Convert logging entry to SEL event record | 
|  | 123 | * | 
|  | 124 | *  @param[in] objPath - DBUS object path of the logging entry. | 
|  | 125 | *  @param[in] iter - Iterator to the sensor data corresponding to the logging | 
|  | 126 | *                    entry | 
|  | 127 | * | 
|  | 128 | *  @return On success return the SEL event record, throw an exception in case | 
|  | 129 | *          of failure. | 
|  | 130 | */ | 
| Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 131 | GetSELEntryResponse | 
|  | 132 | prepareSELEntry(const std::string& objPath, | 
|  | 133 | ipmi::sensor::InvObjectIDMap::const_iterator iter); | 
| Tom Joseph | 6b7a143 | 2017-05-19 10:43:36 +0530 | [diff] [blame] | 134 |  | 
| Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 135 | } // namespace internal | 
| Tom Joseph | 6b7a143 | 2017-05-19 10:43:36 +0530 | [diff] [blame] | 136 |  | 
|  | 137 | } // namespace sel | 
|  | 138 |  | 
|  | 139 | } // namespace ipmi |