Tom Joseph | 64b3dec | 2017-04-03 01:53:44 +0530 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Tom Joseph | 64b3dec | 2017-04-03 01:53:44 +0530 | [diff] [blame] | 3 | #include "message_handler.hpp" |
| 4 | |
Vernon Mauery | 9e801a2 | 2018-10-12 13:20:49 -0700 | [diff] [blame] | 5 | #include <vector> |
| 6 | |
Tom Joseph | 64b3dec | 2017-04-03 01:53:44 +0530 | [diff] [blame] | 7 | namespace sol |
| 8 | { |
| 9 | |
| 10 | namespace command |
| 11 | { |
| 12 | |
| 13 | /** @brief SOL Payload Handler |
| 14 | * |
| 15 | * This command is used for activating and deactivating a payload type under a |
| 16 | * given IPMI session. The UDP Port number for SOL is the same as the port that |
| 17 | * was used to establish the IPMI session. |
| 18 | * |
| 19 | * @param[in] inPayload - Request data for the command. |
| 20 | * @param[in] handler - Reference to the message handler. |
| 21 | * |
| 22 | * @return Response data for the command. |
| 23 | */ |
Tom Joseph | 18a45e9 | 2017-04-11 11:30:44 +0530 | [diff] [blame] | 24 | std::vector<uint8_t> payloadHandler(const std::vector<uint8_t>& inPayload, |
Tom Joseph | 64b3dec | 2017-04-03 01:53:44 +0530 | [diff] [blame] | 25 | const message::Handler& handler); |
Tom Joseph | e14ac96 | 2017-04-03 01:56:04 +0530 | [diff] [blame] | 26 | |
| 27 | constexpr uint8_t netfnTransport = 0x0C; |
| 28 | constexpr uint8_t solActivatingCmd = 0x20; |
| 29 | |
| 30 | /** @struct ActivatingRequest |
| 31 | * |
| 32 | * IPMI payload for SOL Activating command. |
| 33 | */ |
| 34 | struct ActivatingRequest |
| 35 | { |
| 36 | #if BYTE_ORDER == LITTLE_ENDIAN |
Vernon Mauery | 9e801a2 | 2018-10-12 13:20:49 -0700 | [diff] [blame] | 37 | uint8_t sessionState : 4; //!< SOL session state. |
| 38 | uint8_t reserved : 4; //!< Reserved. |
Tom Joseph | e14ac96 | 2017-04-03 01:56:04 +0530 | [diff] [blame] | 39 | #endif |
| 40 | |
| 41 | #if BYTE_ORDER == BIG_ENDIAN |
Vernon Mauery | 9e801a2 | 2018-10-12 13:20:49 -0700 | [diff] [blame] | 42 | uint8_t reserved : 4; //!< Reserved. |
| 43 | uint8_t sessionState : 4; //!< SOL session state. |
Tom Joseph | e14ac96 | 2017-04-03 01:56:04 +0530 | [diff] [blame] | 44 | #endif |
| 45 | |
Vernon Mauery | 9e801a2 | 2018-10-12 13:20:49 -0700 | [diff] [blame] | 46 | uint8_t payloadInstance; //!< Payload instance. |
| 47 | uint8_t majorVersion; //!< SOL format major version |
| 48 | uint8_t minorVersion; //!< SOL format minor version |
Tom Joseph | e14ac96 | 2017-04-03 01:56:04 +0530 | [diff] [blame] | 49 | } __attribute__((packed)); |
| 50 | |
| 51 | /** @brief SOL Activating Command. |
| 52 | * |
| 53 | * This command provides a mechanism for the BMC to notify a remote application |
| 54 | * that a SOL payload is activating on another channel.The request message is a |
| 55 | * message that is asynchronously generated by the BMC. The BMC will not wait |
| 56 | * for a response from the remote console before dropping the serial connection |
| 57 | * to proceed with SOL, therefore the remote console does not need to respond |
| 58 | * to this command. |
| 59 | * |
| 60 | * @param[in] payloadInstance - SOL payload instance. |
| 61 | * @param[in] sessionID - IPMI session ID. |
| 62 | */ |
| 63 | void activating(uint8_t payloadInstance, uint32_t sessionID); |
| 64 | |
Tom Joseph | 48b9951 | 2017-04-28 01:31:08 +0530 | [diff] [blame] | 65 | /** @enum Parameter |
| 66 | * |
| 67 | * SOL parameters are volatile, they are initialized by the SOL manager. |
| 68 | * They can be read using Get SOL configuration parameters command and updated |
| 69 | * using Set SOL configuration parameters command. |
| 70 | */ |
| 71 | enum class Parameter |
| 72 | { |
| 73 | PROGRESS, //!< Set In Progress. |
| 74 | ENABLE, //!< SOL Enable. |
| 75 | AUTHENTICATION, //!< SOL Authentication. |
| 76 | ACCUMULATE, //!< Character Accumulate Interval & Send Threshold. |
| 77 | RETRY, //!< SOL Retry. |
| 78 | NVBITRATE, //!< SOL non-volatile bit rate. |
| 79 | VBITRATE, //!< SOL volatile bit rate. |
| 80 | CHANNEL, //!< SOL payload channel. |
| 81 | PORT, //!< SOL payload port. |
| 82 | }; |
| 83 | |
| 84 | constexpr uint8_t progressMask = 0x03; |
| 85 | constexpr uint8_t enableMask = 0x01; |
| 86 | |
| 87 | /** @struct Auth |
| 88 | * |
| 89 | * SOL authentication parameter. |
| 90 | */ |
| 91 | struct Auth |
| 92 | { |
| 93 | #if BYTE_ORDER == LITTLE_ENDIAN |
Vernon Mauery | 9e801a2 | 2018-10-12 13:20:49 -0700 | [diff] [blame] | 94 | uint8_t privilege : 4; //!< SOL privilege level. |
| 95 | uint8_t reserved : 2; //!< Reserved. |
| 96 | uint8_t auth : 1; //!< Force SOL payload Authentication. |
| 97 | uint8_t encrypt : 1; //!< Force SOL payload encryption. |
Tom Joseph | 48b9951 | 2017-04-28 01:31:08 +0530 | [diff] [blame] | 98 | #endif |
| 99 | |
| 100 | #if BYTE_ORDER == BIG_ENDIAN |
Vernon Mauery | 9e801a2 | 2018-10-12 13:20:49 -0700 | [diff] [blame] | 101 | uint8_t encrypt : 1; //!< Force SOL payload encryption. |
| 102 | uint8_t auth : 1; //!< Force SOL payload Authentication. |
| 103 | uint8_t reserved : 2; //!< Reserved. |
| 104 | uint8_t privilege : 4; //!< SOL privilege level. |
Tom Joseph | 48b9951 | 2017-04-28 01:31:08 +0530 | [diff] [blame] | 105 | #endif |
| 106 | } __attribute__((packed)); |
| 107 | |
| 108 | /** @struct Accumulate |
| 109 | * |
| 110 | * Character accumulate interval & Character send threshold. |
| 111 | */ |
| 112 | struct Accumulate |
| 113 | { |
Vernon Mauery | 9e801a2 | 2018-10-12 13:20:49 -0700 | [diff] [blame] | 114 | uint8_t interval; //!< Character accumulate interval. |
| 115 | uint8_t threshold; //!< Character send threshold. |
Tom Joseph | 48b9951 | 2017-04-28 01:31:08 +0530 | [diff] [blame] | 116 | } __attribute__((packed)); |
| 117 | |
| 118 | constexpr uint8_t retryCountMask = 0x07; |
| 119 | |
| 120 | /** @struct Retry |
| 121 | * |
| 122 | * SOL retry count and interval. |
| 123 | */ |
| 124 | struct Retry |
| 125 | { |
| 126 | #if BYTE_ORDER == LITTLE_ENDIAN |
Vernon Mauery | 9e801a2 | 2018-10-12 13:20:49 -0700 | [diff] [blame] | 127 | uint8_t count : 3; //!< SOL retry count. |
| 128 | uint8_t reserved : 5; //!< Reserved. |
Tom Joseph | 48b9951 | 2017-04-28 01:31:08 +0530 | [diff] [blame] | 129 | #endif |
| 130 | |
| 131 | #if BYTE_ORDER == BIG_ENDIAN |
Vernon Mauery | 9e801a2 | 2018-10-12 13:20:49 -0700 | [diff] [blame] | 132 | uint8_t reserved : 5; //!< Reserved. |
| 133 | uint8_t count : 3; //!< SOL retry count. |
Tom Joseph | 48b9951 | 2017-04-28 01:31:08 +0530 | [diff] [blame] | 134 | #endif |
| 135 | |
Vernon Mauery | 9e801a2 | 2018-10-12 13:20:49 -0700 | [diff] [blame] | 136 | uint8_t interval; //!< SOL retry interval. |
Tom Joseph | 48b9951 | 2017-04-28 01:31:08 +0530 | [diff] [blame] | 137 | } __attribute__((packed)); |
| 138 | |
| 139 | constexpr uint8_t ipmiCCParamNotSupported = 0x80; |
| 140 | constexpr uint8_t ipmiCCInvalidSetInProgress = 0x81; |
| 141 | constexpr uint8_t ipmiCCWriteReadParameter = 0x82; |
| 142 | constexpr uint8_t ipmiCCReadWriteParameter = 0x83; |
| 143 | constexpr uint8_t parameterRevision = 0x11; |
| 144 | |
| 145 | /** @struct SetConfParamsRequest |
| 146 | * |
| 147 | * IPMI payload for Set SOL configuration parameters command request. |
| 148 | */ |
| 149 | struct SetConfParamsRequest |
| 150 | { |
| 151 | #if BYTE_ORDER == LITTLE_ENDIAN |
Vernon Mauery | 9e801a2 | 2018-10-12 13:20:49 -0700 | [diff] [blame] | 152 | uint8_t channelNumber : 4; //!< Channel number. |
| 153 | uint8_t reserved : 4; //!< Reserved. |
Tom Joseph | 48b9951 | 2017-04-28 01:31:08 +0530 | [diff] [blame] | 154 | #endif |
| 155 | |
| 156 | #if BYTE_ORDER == BIG_ENDIAN |
Vernon Mauery | 9e801a2 | 2018-10-12 13:20:49 -0700 | [diff] [blame] | 157 | uint8_t reserved : 4; //!< Reserved. |
| 158 | uint8_t channelNumber : 4; //!< Channel number. |
Tom Joseph | 48b9951 | 2017-04-28 01:31:08 +0530 | [diff] [blame] | 159 | #endif |
| 160 | |
Vernon Mauery | 9e801a2 | 2018-10-12 13:20:49 -0700 | [diff] [blame] | 161 | uint8_t paramSelector; //!< Parameter selector. |
Tom Joseph | 48b9951 | 2017-04-28 01:31:08 +0530 | [diff] [blame] | 162 | union |
| 163 | { |
Vernon Mauery | 9e801a2 | 2018-10-12 13:20:49 -0700 | [diff] [blame] | 164 | uint8_t value; //!< Represents one byte SOL parameters. |
| 165 | struct Accumulate acc; //!< Character accumulate values. |
| 166 | struct Retry retry; //!< Retry values. |
| 167 | struct Auth auth; //!< Authentication parameters. |
Tom Joseph | 48b9951 | 2017-04-28 01:31:08 +0530 | [diff] [blame] | 168 | }; |
| 169 | } __attribute__((packed)); |
| 170 | |
| 171 | /** @struct SetConfParamsResponse |
| 172 | * |
| 173 | * IPMI payload for Set SOL configuration parameters command response. |
| 174 | */ |
| 175 | struct SetConfParamsResponse |
| 176 | { |
Vernon Mauery | 9e801a2 | 2018-10-12 13:20:49 -0700 | [diff] [blame] | 177 | uint8_t completionCode; //!< Completion code. |
Tom Joseph | 48b9951 | 2017-04-28 01:31:08 +0530 | [diff] [blame] | 178 | } __attribute__((packed)); |
| 179 | |
| 180 | /** @brief Set SOL configuration parameters command. |
| 181 | * |
| 182 | * @param[in] inPayload - Request data for the command. |
| 183 | * @param[in] handler - Reference to the message handler. |
| 184 | * |
| 185 | * @return Response data for the command. |
| 186 | */ |
| 187 | std::vector<uint8_t> setConfParams(const std::vector<uint8_t>& inPayload, |
| 188 | const message::Handler& handler); |
| 189 | |
Tom Joseph | 20aef33 | 2017-04-28 01:34:10 +0530 | [diff] [blame] | 190 | /** @struct GetConfParamsRequest |
| 191 | * |
| 192 | * IPMI payload for Get SOL configuration parameters command request. |
| 193 | */ |
| 194 | struct GetConfParamsRequest |
| 195 | { |
| 196 | #if BYTE_ORDER == LITTLE_ENDIAN |
Vernon Mauery | 9e801a2 | 2018-10-12 13:20:49 -0700 | [diff] [blame] | 197 | uint8_t channelNum : 4; //!< Channel number. |
| 198 | uint8_t reserved : 3; //!< Reserved. |
| 199 | uint8_t getParamRev : 1; //!< Get parameter or Get parameter revision |
Tom Joseph | 20aef33 | 2017-04-28 01:34:10 +0530 | [diff] [blame] | 200 | #endif |
| 201 | |
| 202 | #if BYTE_ORDER == BIG_ENDIAN |
Vernon Mauery | 9e801a2 | 2018-10-12 13:20:49 -0700 | [diff] [blame] | 203 | uint8_t getParamRev : 1; //!< Get parameter or Get parameter revision |
| 204 | uint8_t reserved : 3; //!< Reserved. |
| 205 | uint8_t channelNum : 4; //!< Channel number. |
Tom Joseph | 20aef33 | 2017-04-28 01:34:10 +0530 | [diff] [blame] | 206 | #endif |
| 207 | |
Vernon Mauery | 9e801a2 | 2018-10-12 13:20:49 -0700 | [diff] [blame] | 208 | uint8_t paramSelector; //!< Parameter selector. |
| 209 | uint8_t setSelector; //!< Set selector. |
| 210 | uint8_t blockSelector; //!< Block selector. |
Tom Joseph | 20aef33 | 2017-04-28 01:34:10 +0530 | [diff] [blame] | 211 | } __attribute__((packed)); |
| 212 | |
| 213 | /** @struct GetConfParamsResponse |
| 214 | * |
| 215 | * IPMI payload for Get SOL configuration parameters command response. |
| 216 | */ |
| 217 | struct GetConfParamsResponse |
| 218 | { |
Vernon Mauery | 9e801a2 | 2018-10-12 13:20:49 -0700 | [diff] [blame] | 219 | uint8_t completionCode; //!< Completion code. |
| 220 | uint8_t paramRev; //!< Parameter revision. |
Tom Joseph | 20aef33 | 2017-04-28 01:34:10 +0530 | [diff] [blame] | 221 | } __attribute__((packed)); |
| 222 | |
| 223 | /** @brief Get SOL configuration parameters command. |
| 224 | * |
| 225 | * @param[in] inPayload - Request data for the command. |
| 226 | * @param[in] handler - Reference to the message handler. |
| 227 | * |
| 228 | * @return Response data for the command. |
| 229 | */ |
| 230 | std::vector<uint8_t> getConfParams(const std::vector<uint8_t>& inPayload, |
| 231 | const message::Handler& handler); |
| 232 | |
Tom Joseph | 64b3dec | 2017-04-03 01:53:44 +0530 | [diff] [blame] | 233 | } // namespace command |
| 234 | |
| 235 | } // namespace sol |