Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1 | /* |
| 2 | // Copyright (c) 2018 Intel Corporation |
| 3 | // |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // |
| 8 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | // |
| 10 | // Unless required by applicable law or agreed to in writing, software |
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | // See the License for the specific language governing permissions and |
| 14 | // limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include <errno.h> |
| 18 | #include <fcntl.h> |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 19 | #include <limits.h> |
| 20 | #include <sys/stat.h> |
| 21 | #include <sys/types.h> |
| 22 | #include <unistd.h> |
| 23 | |
| 24 | #include <commandutils.hpp> |
| 25 | #include <cstdint> |
| 26 | #include <fstream> |
jayaprakash Mutyala | 853d829 | 2019-05-31 18:17:42 +0000 | [diff] [blame] | 27 | #include <ipmid/api.hpp> |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 28 | #include <ipmid/utils.hpp> |
| 29 | #include <phosphor-logging/log.hpp> |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 30 | #include <sdbusplus/message/types.hpp> |
| 31 | #include <smbiosmdrv2handler.hpp> |
| 32 | #include <string> |
| 33 | #include <vector> |
| 34 | #include <xyz/openbmc_project/Common/error.hpp> |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 35 | |
| 36 | std::unique_ptr<MDRV2> mdrv2 = nullptr; |
jayaprakash Mutyala | 3104b3f | 2019-06-10 19:23:07 +0000 | [diff] [blame] | 37 | static constexpr const uint8_t ccOemInvalidChecksum = 0x85; |
jayaprakash Mutyala | 40fec61 | 2019-06-19 11:53:03 +0000 | [diff] [blame] | 38 | static constexpr size_t dataInfoSize = 16; |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 39 | |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 40 | static void register_netfn_smbiosmdrv2_functions() __attribute__((constructor)); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 41 | |
| 42 | int MDRV2::agentLookup(const uint16_t &agentId) |
| 43 | { |
| 44 | int agentIndex = -1; |
| 45 | |
| 46 | if (lastAgentId == agentId) |
| 47 | { |
| 48 | return lastAgentIndex; |
| 49 | } |
| 50 | |
| 51 | if (agentId == smbiosAgentId) |
| 52 | { |
| 53 | return firstAgentIndex; |
| 54 | } |
| 55 | |
| 56 | return agentIndex; |
| 57 | } |
| 58 | |
| 59 | int MDRV2::sdplusMdrv2GetProperty(const std::string &name, |
| 60 | sdbusplus::message::variant<uint8_t> &value, |
| 61 | const std::string &service) |
| 62 | { |
Vernon Mauery | 15419dd | 2019-05-24 09:40:30 -0700 | [diff] [blame] | 63 | std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus(); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 64 | sdbusplus::message::message method = |
Vernon Mauery | 15419dd | 2019-05-24 09:40:30 -0700 | [diff] [blame] | 65 | bus->new_method_call(service.c_str(), mdrv2Path, dbusProperties, "Get"); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 66 | method.append(mdrv2Interface, name); |
| 67 | |
Vernon Mauery | 15419dd | 2019-05-24 09:40:30 -0700 | [diff] [blame] | 68 | sdbusplus::message::message reply = bus->call(method); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 69 | |
| 70 | try |
| 71 | { |
Vernon Mauery | 15419dd | 2019-05-24 09:40:30 -0700 | [diff] [blame] | 72 | sdbusplus::message::message reply = bus->call(method); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 73 | reply.read(value); |
| 74 | } |
Vernon Mauery | c7d517e | 2019-06-18 14:27:00 -0700 | [diff] [blame] | 75 | catch (sdbusplus::exception_t &e) |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 76 | { |
| 77 | phosphor::logging::log<phosphor::logging::level::ERR>( |
Vernon Mauery | c7d517e | 2019-06-18 14:27:00 -0700 | [diff] [blame] | 78 | "Error get property, sdbusplus call failed", |
| 79 | phosphor::logging::entry("ERROR=%s", e.what())); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 80 | return -1; |
| 81 | } |
| 82 | |
| 83 | return 0; |
| 84 | } |
| 85 | |
| 86 | int MDRV2::syncDirCommonData(uint8_t idIndex, uint32_t size, |
| 87 | const std::string &service) |
| 88 | { |
| 89 | std::vector<uint32_t> commonData; |
Vernon Mauery | 15419dd | 2019-05-24 09:40:30 -0700 | [diff] [blame] | 90 | std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus(); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 91 | sdbusplus::message::message method = |
Vernon Mauery | 15419dd | 2019-05-24 09:40:30 -0700 | [diff] [blame] | 92 | bus->new_method_call(service.c_str(), mdrv2Path, mdrv2Interface, |
| 93 | "SynchronizeDirectoryCommonData"); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 94 | method.append(idIndex, size); |
| 95 | |
| 96 | try |
| 97 | { |
Vernon Mauery | 15419dd | 2019-05-24 09:40:30 -0700 | [diff] [blame] | 98 | sdbusplus::message::message reply = bus->call(method); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 99 | reply.read(commonData); |
| 100 | } |
Vernon Mauery | c7d517e | 2019-06-18 14:27:00 -0700 | [diff] [blame] | 101 | catch (sdbusplus::exception_t &e) |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 102 | { |
| 103 | phosphor::logging::log<phosphor::logging::level::ERR>( |
Vernon Mauery | c7d517e | 2019-06-18 14:27:00 -0700 | [diff] [blame] | 104 | "Error sync dir common data with service", |
| 105 | phosphor::logging::entry("ERROR=%s", e.what())); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 106 | return -1; |
| 107 | } |
| 108 | |
| 109 | if (commonData.size() < syncDirCommonSize) |
| 110 | { |
| 111 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 112 | "Error sync dir common data - data length invalid"); |
| 113 | return -1; |
| 114 | } |
| 115 | smbiosDir.dir[idIndex].common.dataSetSize = commonData.at(0); |
| 116 | smbiosDir.dir[idIndex].common.dataVersion = commonData.at(1); |
| 117 | smbiosDir.dir[idIndex].common.timestamp = commonData.at(2); |
| 118 | |
| 119 | return 0; |
| 120 | } |
| 121 | |
| 122 | int MDRV2::findDataId(const uint8_t *dataInfo, const size_t &len, |
| 123 | const std::string &service) |
| 124 | { |
| 125 | int idIndex = -1; |
| 126 | |
| 127 | if (dataInfo == nullptr) |
| 128 | { |
| 129 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 130 | "Error dataInfo, input is null point"); |
| 131 | return -1; |
| 132 | } |
| 133 | |
Vernon Mauery | 15419dd | 2019-05-24 09:40:30 -0700 | [diff] [blame] | 134 | std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus(); |
| 135 | sdbusplus::message::message method = bus->new_method_call( |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 136 | service.c_str(), mdrv2Path, mdrv2Interface, "FindIdIndex"); |
| 137 | std::vector<uint8_t> info; |
| 138 | info.resize(len); |
| 139 | std::copy(dataInfo, dataInfo + len, info.data()); |
| 140 | method.append(info); |
| 141 | |
| 142 | try |
| 143 | { |
Vernon Mauery | 15419dd | 2019-05-24 09:40:30 -0700 | [diff] [blame] | 144 | sdbusplus::message::message reply = bus->call(method); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 145 | reply.read(idIndex); |
| 146 | } |
Vernon Mauery | c7d517e | 2019-06-18 14:27:00 -0700 | [diff] [blame] | 147 | catch (sdbusplus::exception_t &e) |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 148 | { |
| 149 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 150 | "Error find id index", |
Vernon Mauery | c7d517e | 2019-06-18 14:27:00 -0700 | [diff] [blame] | 151 | phosphor::logging::entry("ERROR=%s", e.what()), |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 152 | phosphor::logging::entry("SERVICE=%s", service.c_str()), |
| 153 | phosphor::logging::entry("PATH=%s", mdrv2Path)); |
| 154 | return -1; |
| 155 | } |
| 156 | |
| 157 | return idIndex; |
| 158 | } |
| 159 | |
| 160 | uint16_t MDRV2::getSessionHandle(Mdr2DirStruct *dir) |
| 161 | { |
| 162 | if (dir == NULL) |
| 163 | { |
| 164 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 165 | "Empty dir point"); |
| 166 | return 0; |
| 167 | } |
| 168 | dir->sessionHandle++; |
| 169 | if (dir->sessionHandle == 0) |
| 170 | { |
| 171 | dir->sessionHandle = 1; |
| 172 | } |
| 173 | |
| 174 | return dir->sessionHandle; |
| 175 | } |
| 176 | |
| 177 | int MDRV2::findLockHandle(const uint16_t &lockHandle) |
| 178 | { |
| 179 | int idIndex = -1; |
| 180 | |
| 181 | for (int index = 0; index < smbiosDir.dirEntries; index++) |
| 182 | { |
| 183 | if (lockHandle == smbiosDir.dir[index].lockHandle) |
| 184 | { |
| 185 | return index; |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | return idIndex; |
| 190 | } |
| 191 | |
| 192 | bool MDRV2::smbiosIsUpdating(uint8_t index) |
| 193 | { |
| 194 | if (index > maxDirEntries) |
| 195 | { |
| 196 | return false; |
| 197 | } |
| 198 | if (smbiosDir.dir[index].stage == MDR2SMBIOSStatusEnum::mdr2Updating) |
| 199 | { |
| 200 | return true; |
| 201 | } |
| 202 | |
| 203 | return false; |
| 204 | } |
| 205 | |
| 206 | uint32_t MDRV2::calcChecksum32(uint8_t *buf, uint32_t len) |
| 207 | { |
| 208 | uint32_t sum = 0; |
| 209 | |
| 210 | if (buf == nullptr) |
| 211 | { |
| 212 | return invalidChecksum; |
| 213 | } |
| 214 | |
| 215 | for (uint32_t index = 0; index < len; index++) |
| 216 | { |
| 217 | sum += buf[index]; |
| 218 | } |
| 219 | |
| 220 | return sum; |
| 221 | } |
| 222 | |
jayaprakash Mutyala | 853d829 | 2019-05-31 18:17:42 +0000 | [diff] [blame] | 223 | /** @brief implements mdr2 agent status command |
| 224 | * @param agentId |
| 225 | * @param dirVersion |
| 226 | * |
| 227 | * @returns IPMI completion code plus response data |
| 228 | * - mdrVersion |
| 229 | * - agentVersion |
| 230 | * - dirVersion |
| 231 | * - dirEntries |
| 232 | * - dataRequest |
| 233 | */ |
| 234 | ipmi::RspType<uint8_t, uint8_t, uint8_t, uint8_t, uint8_t> |
| 235 | mdr2AgentStatus(uint16_t agentId, uint8_t dirVersion) |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 236 | { |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 237 | if (mdrv2 == nullptr) |
| 238 | { |
| 239 | mdrv2 = std::make_unique<MDRV2>(); |
| 240 | } |
| 241 | |
jayaprakash Mutyala | 853d829 | 2019-05-31 18:17:42 +0000 | [diff] [blame] | 242 | int agentIndex = mdrv2->agentLookup(agentId); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 243 | if (agentIndex == -1) |
| 244 | { |
| 245 | phosphor::logging::log<phosphor::logging::level::ERR>( |
jayaprakash Mutyala | 853d829 | 2019-05-31 18:17:42 +0000 | [diff] [blame] | 246 | "Unknown agent id", phosphor::logging::entry("ID=%x", agentId)); |
| 247 | return ipmi::responseParmOutOfRange(); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 248 | } |
| 249 | |
jayaprakash Mutyala | 853d829 | 2019-05-31 18:17:42 +0000 | [diff] [blame] | 250 | constexpr uint8_t mdrVersion = mdr2Version; |
| 251 | constexpr uint8_t agentVersion = smbiosAgentVersion; |
| 252 | uint8_t dirVersionResp = mdrv2->smbiosDir.dirVersion; |
| 253 | uint8_t dirEntries = mdrv2->smbiosDir.dirEntries; |
| 254 | uint8_t dataRequest; |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 255 | |
jayaprakash Mutyala | 853d829 | 2019-05-31 18:17:42 +0000 | [diff] [blame] | 256 | if (mdrv2->smbiosDir.remoteDirVersion != dirVersion) |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 257 | { |
jayaprakash Mutyala | 853d829 | 2019-05-31 18:17:42 +0000 | [diff] [blame] | 258 | mdrv2->smbiosDir.remoteDirVersion = dirVersion; |
| 259 | dataRequest = |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 260 | static_cast<uint8_t>(DirDataRequestEnum::dirDataRequested); |
| 261 | } |
| 262 | else |
| 263 | { |
jayaprakash Mutyala | 853d829 | 2019-05-31 18:17:42 +0000 | [diff] [blame] | 264 | dataRequest = |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 265 | static_cast<uint8_t>(DirDataRequestEnum::dirDataNotRequested); |
| 266 | } |
| 267 | |
jayaprakash Mutyala | 853d829 | 2019-05-31 18:17:42 +0000 | [diff] [blame] | 268 | return ipmi::responseSuccess(mdrVersion, agentVersion, dirVersionResp, |
| 269 | dirEntries, dataRequest); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 270 | } |
| 271 | |
jayaprakash Mutyala | dad548b | 2019-06-12 15:29:39 +0000 | [diff] [blame] | 272 | /** @brief implements mdr2 get directory command |
| 273 | * @param agentId |
| 274 | * @param dirIndex |
| 275 | * @returns IPMI completion code plus response data |
| 276 | * - dataOut |
| 277 | */ |
| 278 | ipmi::RspType<std::vector<uint8_t>> mdr2GetDir(uint16_t agentId, |
| 279 | uint8_t dirIndex) |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 280 | { |
Vernon Mauery | 15419dd | 2019-05-24 09:40:30 -0700 | [diff] [blame] | 281 | std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus(); |
| 282 | std::string service = ipmi::getService(*bus, mdrv2Interface, mdrv2Path); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 283 | |
| 284 | if (mdrv2 == nullptr) |
| 285 | { |
| 286 | mdrv2 = std::make_unique<MDRV2>(); |
| 287 | } |
| 288 | |
jayaprakash Mutyala | dad548b | 2019-06-12 15:29:39 +0000 | [diff] [blame] | 289 | int agentIndex = mdrv2->agentLookup(agentId); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 290 | if (agentIndex == -1) |
| 291 | { |
| 292 | phosphor::logging::log<phosphor::logging::level::ERR>( |
jayaprakash Mutyala | dad548b | 2019-06-12 15:29:39 +0000 | [diff] [blame] | 293 | "Unknown agent id", phosphor::logging::entry("ID=%x", agentId)); |
| 294 | return ipmi::responseParmOutOfRange(); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 295 | } |
| 296 | |
jayaprakash Mutyala | dad548b | 2019-06-12 15:29:39 +0000 | [diff] [blame] | 297 | std::variant<uint8_t> value = 0; |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 298 | if (0 != mdrv2->sdplusMdrv2GetProperty("DirectoryEntries", value, service)) |
| 299 | { |
| 300 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 301 | "Error getting DirEnries"); |
jayaprakash Mutyala | dad548b | 2019-06-12 15:29:39 +0000 | [diff] [blame] | 302 | return ipmi::responseUnspecifiedError(); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 303 | } |
jayaprakash Mutyala | dad548b | 2019-06-12 15:29:39 +0000 | [diff] [blame] | 304 | if (dirIndex > std::get<uint8_t>(value)) |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 305 | { |
jayaprakash Mutyala | dad548b | 2019-06-12 15:29:39 +0000 | [diff] [blame] | 306 | return ipmi::responseParmOutOfRange(); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 307 | } |
| 308 | |
Vernon Mauery | 15419dd | 2019-05-24 09:40:30 -0700 | [diff] [blame] | 309 | sdbusplus::message::message method = bus->new_method_call( |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 310 | service.c_str(), mdrv2Path, mdrv2Interface, "GetDirectoryInformation"); |
| 311 | |
jayaprakash Mutyala | dad548b | 2019-06-12 15:29:39 +0000 | [diff] [blame] | 312 | method.append(dirIndex); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 313 | |
jayaprakash Mutyala | dad548b | 2019-06-12 15:29:39 +0000 | [diff] [blame] | 314 | std::vector<uint8_t> dataOut; |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 315 | try |
| 316 | { |
Vernon Mauery | 15419dd | 2019-05-24 09:40:30 -0700 | [diff] [blame] | 317 | sdbusplus::message::message reply = bus->call(method); |
jayaprakash Mutyala | dad548b | 2019-06-12 15:29:39 +0000 | [diff] [blame] | 318 | reply.read(dataOut); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 319 | } |
Vernon Mauery | c7d517e | 2019-06-18 14:27:00 -0700 | [diff] [blame] | 320 | catch (sdbusplus::exception_t &e) |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 321 | { |
| 322 | phosphor::logging::log<phosphor::logging::level::ERR>( |
Vernon Mauery | c7d517e | 2019-06-18 14:27:00 -0700 | [diff] [blame] | 323 | "Error get dir", phosphor::logging::entry("ERROR=%s", e.what()), |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 324 | phosphor::logging::entry("SERVICE=%s", service.c_str()), |
| 325 | phosphor::logging::entry("PATH=%s", mdrv2Path)); |
jayaprakash Mutyala | dad548b | 2019-06-12 15:29:39 +0000 | [diff] [blame] | 326 | return ipmi::responseResponseError(); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 327 | } |
| 328 | |
jayaprakash Mutyala | dad548b | 2019-06-12 15:29:39 +0000 | [diff] [blame] | 329 | constexpr size_t getDirRespSize = 6; |
| 330 | if (dataOut.size() < getDirRespSize) |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 331 | { |
| 332 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 333 | "Error get dir, response length invalid"); |
jayaprakash Mutyala | dad548b | 2019-06-12 15:29:39 +0000 | [diff] [blame] | 334 | return ipmi::responseUnspecifiedError(); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 335 | } |
| 336 | |
jayaprakash Mutyala | dad548b | 2019-06-12 15:29:39 +0000 | [diff] [blame] | 337 | if (dataOut.size() > MAX_IPMI_BUFFER) // length + completion code should no |
| 338 | // more than MAX_IPMI_BUFFER |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 339 | { |
| 340 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 341 | "Data length send from service is invalid"); |
jayaprakash Mutyala | dad548b | 2019-06-12 15:29:39 +0000 | [diff] [blame] | 342 | return ipmi::responseResponseError(); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 343 | } |
| 344 | |
jayaprakash Mutyala | dad548b | 2019-06-12 15:29:39 +0000 | [diff] [blame] | 345 | return ipmi::responseSuccess(dataOut); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 346 | } |
| 347 | |
| 348 | ipmi_ret_t cmd_mdr2_send_dir(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
| 349 | ipmi_request_t request, ipmi_response_t response, |
| 350 | ipmi_data_len_t data_len, ipmi_context_t context) |
| 351 | { |
| 352 | auto requestData = reinterpret_cast<const MDRiiSendDirRequest *>(request); |
| 353 | std::vector<uint8_t> idVector; |
| 354 | bool teminate = false; |
| 355 | |
| 356 | if (*data_len != sizeof(MDRiiSendDirRequest)) |
| 357 | { |
| 358 | *data_len = 0; |
| 359 | return IPMI_CC_REQ_DATA_LEN_INVALID; |
| 360 | } |
| 361 | |
| 362 | *data_len = 0; |
| 363 | |
Vernon Mauery | 15419dd | 2019-05-24 09:40:30 -0700 | [diff] [blame] | 364 | std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus(); |
| 365 | std::string service = ipmi::getService(*bus, mdrv2Interface, mdrv2Path); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 366 | |
| 367 | if (mdrv2 == nullptr) |
| 368 | { |
| 369 | mdrv2 = std::make_unique<MDRV2>(); |
| 370 | } |
| 371 | |
| 372 | int agentIndex = mdrv2->agentLookup(requestData->agentId); |
| 373 | if (agentIndex == -1) |
| 374 | { |
| 375 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 376 | "Unknown agent id", |
| 377 | phosphor::logging::entry("ID=%x", requestData->agentId)); |
| 378 | return IPMI_CC_PARM_OUT_OF_RANGE; |
| 379 | } |
| 380 | |
| 381 | if ((requestData->dirIndex + requestData->returnedEntries) > maxDirEntries) |
| 382 | { |
| 383 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 384 | "Too many directory entries"); |
| 385 | return IPMI_CC_STORGE_LEAK; |
| 386 | } |
| 387 | |
Vernon Mauery | 15419dd | 2019-05-24 09:40:30 -0700 | [diff] [blame] | 388 | sdbusplus::message::message method = bus->new_method_call( |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 389 | service.c_str(), mdrv2Path, mdrv2Interface, "SendDirectoryInformation"); |
| 390 | method.append(requestData->dirVersion, requestData->dirIndex, |
| 391 | requestData->returnedEntries, requestData->remainingEntries); |
| 392 | uint8_t *reqPoint; |
| 393 | for (int index = 0; index < requestData->returnedEntries; index++) |
| 394 | { |
| 395 | reqPoint = (uint8_t *)&(requestData->data[index]); |
| 396 | std::copy(reqPoint, sizeof(Mdr2DirEntry) + reqPoint, idVector.data()); |
| 397 | } |
| 398 | method.append(idVector); |
| 399 | |
| 400 | try |
| 401 | { |
Vernon Mauery | 15419dd | 2019-05-24 09:40:30 -0700 | [diff] [blame] | 402 | sdbusplus::message::message reply = bus->call(method); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 403 | reply.read(teminate); |
| 404 | } |
Vernon Mauery | c7d517e | 2019-06-18 14:27:00 -0700 | [diff] [blame] | 405 | catch (sdbusplus::exception_t &e) |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 406 | { |
| 407 | phosphor::logging::log<phosphor::logging::level::ERR>( |
Vernon Mauery | c7d517e | 2019-06-18 14:27:00 -0700 | [diff] [blame] | 408 | "Error send dir", phosphor::logging::entry("ERROR=%s", e.what()), |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 409 | phosphor::logging::entry("SERVICE=%s", service.c_str()), |
| 410 | phosphor::logging::entry("PATH=%s", mdrv2Path)); |
| 411 | return IPMI_CC_RESPONSE_ERROR; |
| 412 | } |
| 413 | |
| 414 | *data_len = 1; |
| 415 | if (teminate == false) |
| 416 | *(static_cast<uint8_t *>(response)) = 0; |
| 417 | else |
| 418 | *(static_cast<uint8_t *>(response)) = 1; |
| 419 | return IPMI_CC_OK; |
| 420 | } |
| 421 | |
| 422 | ipmi_ret_t cmd_mdr2_get_data_info(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
| 423 | ipmi_request_t request, |
| 424 | ipmi_response_t response, |
| 425 | ipmi_data_len_t data_len, |
| 426 | ipmi_context_t context) |
| 427 | { |
| 428 | auto requestData = |
| 429 | reinterpret_cast<const MDRiiGetDataInfoRequest *>(request); |
| 430 | auto dataOut = reinterpret_cast<uint8_t *>(response); |
| 431 | std::vector<uint8_t> res; |
| 432 | |
| 433 | if (*data_len < sizeof(MDRiiGetDataInfoRequest)) |
| 434 | { |
| 435 | *data_len = 0; |
| 436 | return IPMI_CC_REQ_DATA_LEN_INVALID; |
| 437 | } |
| 438 | |
| 439 | *data_len = 0; |
| 440 | |
Vernon Mauery | 15419dd | 2019-05-24 09:40:30 -0700 | [diff] [blame] | 441 | std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus(); |
| 442 | std::string service = ipmi::getService(*bus, mdrv2Interface, mdrv2Path); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 443 | |
| 444 | if (mdrv2 == nullptr) |
| 445 | { |
| 446 | mdrv2 = std::make_unique<MDRV2>(); |
| 447 | } |
| 448 | |
| 449 | int agentIndex = mdrv2->agentLookup(requestData->agentId); |
| 450 | if (agentIndex == -1) |
| 451 | { |
| 452 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 453 | "Unknown agent id", |
| 454 | phosphor::logging::entry("ID=%x", requestData->agentId)); |
| 455 | return IPMI_CC_PARM_OUT_OF_RANGE; |
| 456 | } |
| 457 | |
| 458 | int idIndex = |
| 459 | mdrv2->findDataId(requestData->dataSetInfo.dataInfo, |
| 460 | sizeof(requestData->dataSetInfo.dataInfo), service); |
| 461 | |
| 462 | if ((idIndex < 0) || (idIndex >= maxDirEntries)) |
| 463 | { |
| 464 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 465 | "Invalid Data ID", phosphor::logging::entry("IDINDEX=%x", idIndex)); |
| 466 | return IPMI_CC_PARM_OUT_OF_RANGE; |
| 467 | } |
| 468 | |
Vernon Mauery | 15419dd | 2019-05-24 09:40:30 -0700 | [diff] [blame] | 469 | sdbusplus::message::message method = bus->new_method_call( |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 470 | service.c_str(), mdrv2Path, mdrv2Interface, "GetDataInformation"); |
| 471 | |
| 472 | method.append(idIndex); |
| 473 | |
| 474 | try |
| 475 | { |
Vernon Mauery | 15419dd | 2019-05-24 09:40:30 -0700 | [diff] [blame] | 476 | sdbusplus::message::message reply = bus->call(method); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 477 | reply.read(res); |
| 478 | } |
Vernon Mauery | c7d517e | 2019-06-18 14:27:00 -0700 | [diff] [blame] | 479 | catch (sdbusplus::exception_t &e) |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 480 | { |
| 481 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 482 | "Error get data info", |
Vernon Mauery | c7d517e | 2019-06-18 14:27:00 -0700 | [diff] [blame] | 483 | phosphor::logging::entry("ERROR=%s", e.what()), |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 484 | phosphor::logging::entry("SERVICE=%s", service.c_str()), |
| 485 | phosphor::logging::entry("PATH=%s", mdrv2Path)); |
| 486 | return IPMI_CC_RESPONSE_ERROR; |
| 487 | } |
| 488 | |
| 489 | if (res.size() != sizeof(MDRiiGetDataInfoResponse)) |
| 490 | { |
| 491 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 492 | "Get data info response length not invalid"); |
| 493 | return IPMI_CC_UNSPECIFIED_ERROR; |
| 494 | } |
| 495 | *data_len = static_cast<size_t>(res.size()); |
| 496 | std::copy(&res[0], &res[*data_len], dataOut); |
| 497 | |
| 498 | return IPMI_CC_OK; |
| 499 | } |
| 500 | |
jayaprakash Mutyala | 853d829 | 2019-05-31 18:17:42 +0000 | [diff] [blame] | 501 | /** @brief implements mdr2 data info offer command |
| 502 | * @param agentId - Offer a agent ID to get the "Data Set ID" |
| 503 | * |
| 504 | * @returns IPMI completion code plus response data |
jayaprakash Mutyala | 3104b3f | 2019-06-10 19:23:07 +0000 | [diff] [blame] | 505 | * - dataOut - data Set Id |
jayaprakash Mutyala | 853d829 | 2019-05-31 18:17:42 +0000 | [diff] [blame] | 506 | */ |
| 507 | ipmi::RspType<std::vector<uint8_t>> mdr2DataInfoOffer(uint16_t agentId) |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 508 | { |
Vernon Mauery | 15419dd | 2019-05-24 09:40:30 -0700 | [diff] [blame] | 509 | std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus(); |
| 510 | std::string service = ipmi::getService(*bus, mdrv2Interface, mdrv2Path); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 511 | |
| 512 | if (mdrv2 == nullptr) |
| 513 | { |
| 514 | mdrv2 = std::make_unique<MDRV2>(); |
| 515 | } |
| 516 | |
jayaprakash Mutyala | 853d829 | 2019-05-31 18:17:42 +0000 | [diff] [blame] | 517 | int agentIndex = mdrv2->agentLookup(agentId); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 518 | if (agentIndex == -1) |
| 519 | { |
| 520 | phosphor::logging::log<phosphor::logging::level::ERR>( |
jayaprakash Mutyala | 853d829 | 2019-05-31 18:17:42 +0000 | [diff] [blame] | 521 | "Unknown agent id", phosphor::logging::entry("ID=%x", agentId)); |
| 522 | return ipmi::responseParmOutOfRange(); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 523 | } |
| 524 | |
Vernon Mauery | 15419dd | 2019-05-24 09:40:30 -0700 | [diff] [blame] | 525 | sdbusplus::message::message method = bus->new_method_call( |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 526 | service.c_str(), mdrv2Path, mdrv2Interface, "GetDataOffer"); |
| 527 | |
jayaprakash Mutyala | 3104b3f | 2019-06-10 19:23:07 +0000 | [diff] [blame] | 528 | std::vector<uint8_t> dataOut; |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 529 | try |
| 530 | { |
Vernon Mauery | 15419dd | 2019-05-24 09:40:30 -0700 | [diff] [blame] | 531 | sdbusplus::message::message reply = bus->call(method); |
jayaprakash Mutyala | 3104b3f | 2019-06-10 19:23:07 +0000 | [diff] [blame] | 532 | reply.read(dataOut); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 533 | } |
Vernon Mauery | c7d517e | 2019-06-18 14:27:00 -0700 | [diff] [blame] | 534 | catch (sdbusplus::exception_t &e) |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 535 | { |
| 536 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 537 | "Error send data info offer", |
Vernon Mauery | c7d517e | 2019-06-18 14:27:00 -0700 | [diff] [blame] | 538 | phosphor::logging::entry("ERROR=%s", e.what()), |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 539 | phosphor::logging::entry("SERVICE=%s", service.c_str()), |
| 540 | phosphor::logging::entry("PATH=%s", mdrv2Path)); |
jayaprakash Mutyala | 853d829 | 2019-05-31 18:17:42 +0000 | [diff] [blame] | 541 | return ipmi::responseResponseError(); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 542 | } |
| 543 | |
jayaprakash Mutyala | 3104b3f | 2019-06-10 19:23:07 +0000 | [diff] [blame] | 544 | constexpr size_t respInfoSize = 16; |
| 545 | if (dataOut.size() != respInfoSize) |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 546 | { |
| 547 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 548 | "Error send data info offer, return length invalid"); |
jayaprakash Mutyala | 853d829 | 2019-05-31 18:17:42 +0000 | [diff] [blame] | 549 | return ipmi::responseUnspecifiedError(); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 550 | } |
| 551 | |
jayaprakash Mutyala | 3104b3f | 2019-06-10 19:23:07 +0000 | [diff] [blame] | 552 | return ipmi::responseSuccess(dataOut); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 553 | } |
| 554 | |
| 555 | ipmi_ret_t cmd_mdr2_send_data_info(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
| 556 | ipmi_request_t request, |
| 557 | ipmi_response_t response, |
| 558 | ipmi_data_len_t data_len, |
| 559 | ipmi_context_t context) |
| 560 | { |
| 561 | auto requestData = |
| 562 | reinterpret_cast<const MDRiiSendDataInfoRequest *>(request); |
| 563 | bool entryChanged = true; |
| 564 | |
| 565 | if (*data_len != sizeof(MDRiiSendDataInfoRequest)) |
| 566 | { |
| 567 | *data_len = 0; |
| 568 | return IPMI_CC_REQ_DATA_LEN_INVALID; |
| 569 | } |
| 570 | |
| 571 | *data_len = 0; |
| 572 | |
| 573 | if (requestData->dataLength > smbiosTableStorageSize) |
| 574 | { |
| 575 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 576 | "Requested data length is out of SMBIOS Table storage size."); |
| 577 | return IPMI_CC_PARM_OUT_OF_RANGE; |
| 578 | } |
| 579 | |
Vernon Mauery | 15419dd | 2019-05-24 09:40:30 -0700 | [diff] [blame] | 580 | std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus(); |
| 581 | std::string service = ipmi::getService(*bus, mdrv2Interface, mdrv2Path); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 582 | |
| 583 | if (mdrv2 == nullptr) |
| 584 | { |
| 585 | mdrv2 = std::make_unique<MDRV2>(); |
| 586 | } |
| 587 | |
| 588 | int agentIndex = mdrv2->agentLookup(requestData->agentId); |
| 589 | if (agentIndex == -1) |
| 590 | { |
| 591 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 592 | "Unknown agent id", |
| 593 | phosphor::logging::entry("ID=%x", requestData->agentId)); |
| 594 | return IPMI_CC_PARM_OUT_OF_RANGE; |
| 595 | } |
| 596 | |
| 597 | int idIndex = |
| 598 | mdrv2->findDataId(requestData->dataSetInfo.dataInfo, |
| 599 | sizeof(requestData->dataSetInfo.dataInfo), service); |
| 600 | |
| 601 | if ((idIndex < 0) || (idIndex >= maxDirEntries)) |
| 602 | { |
| 603 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 604 | "Invalid Data ID", phosphor::logging::entry("IDINDEX=%x", idIndex)); |
| 605 | return IPMI_CC_PARM_OUT_OF_RANGE; |
| 606 | } |
| 607 | |
Vernon Mauery | 15419dd | 2019-05-24 09:40:30 -0700 | [diff] [blame] | 608 | sdbusplus::message::message method = bus->new_method_call( |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 609 | service.c_str(), mdrv2Path, mdrv2Interface, "SendDataInformation"); |
| 610 | |
| 611 | method.append((uint8_t)idIndex, requestData->validFlag, |
| 612 | requestData->dataLength, requestData->dataVersion, |
| 613 | requestData->timeStamp); |
| 614 | |
| 615 | try |
| 616 | { |
Vernon Mauery | 15419dd | 2019-05-24 09:40:30 -0700 | [diff] [blame] | 617 | sdbusplus::message::message reply = bus->call(method); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 618 | reply.read(entryChanged); |
| 619 | } |
Vernon Mauery | c7d517e | 2019-06-18 14:27:00 -0700 | [diff] [blame] | 620 | catch (sdbusplus::exception_t &e) |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 621 | { |
| 622 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 623 | "Error send data info", |
Vernon Mauery | c7d517e | 2019-06-18 14:27:00 -0700 | [diff] [blame] | 624 | phosphor::logging::entry("ERROR=%s", e.what()), |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 625 | phosphor::logging::entry("SERVICE=%s", service.c_str()), |
| 626 | phosphor::logging::entry("PATH=%s", mdrv2Path)); |
| 627 | return IPMI_CC_RESPONSE_ERROR; |
| 628 | } |
| 629 | |
| 630 | *data_len = 1; |
| 631 | |
| 632 | if (entryChanged) |
| 633 | { |
| 634 | *(static_cast<uint8_t *>(response)) = 1; |
| 635 | } |
| 636 | else |
| 637 | { |
| 638 | *(static_cast<uint8_t *>(response)) = 0; |
| 639 | } |
| 640 | |
| 641 | return IPMI_CC_OK; |
| 642 | } |
| 643 | |
| 644 | ipmi_ret_t cmd_mdr2_get_data_block(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
| 645 | ipmi_request_t request, |
| 646 | ipmi_response_t response, |
| 647 | ipmi_data_len_t data_len, |
| 648 | ipmi_context_t context) |
| 649 | { |
| 650 | auto requestData = |
| 651 | reinterpret_cast<const MDRiiGetDataBlockRequest *>(request); |
| 652 | auto responseData = reinterpret_cast<MDRiiGetDataBlockResponse *>(response); |
| 653 | std::tuple<uint8_t, uint32_t, uint32_t, std::vector<uint8_t>> res; |
| 654 | std::vector<uint8_t> resData; |
| 655 | uint8_t status = 1; |
| 656 | |
| 657 | if (*data_len != sizeof(MDRiiGetDataBlockRequest)) |
| 658 | { |
| 659 | *data_len = 0; |
| 660 | return IPMI_CC_REQ_DATA_LEN_INVALID; |
| 661 | } |
| 662 | |
| 663 | *data_len = 0; |
| 664 | |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 665 | if (mdrv2 == nullptr) |
| 666 | { |
| 667 | mdrv2 = std::make_unique<MDRV2>(); |
| 668 | } |
| 669 | |
| 670 | int agentIndex = mdrv2->agentLookup(requestData->agentId); |
| 671 | if (agentIndex == -1) |
| 672 | { |
| 673 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 674 | "Unknown agent id", |
| 675 | phosphor::logging::entry("ID=%x", requestData->agentId)); |
| 676 | return IPMI_CC_PARM_OUT_OF_RANGE; |
| 677 | } |
| 678 | |
| 679 | int idIndex = mdrv2->findLockHandle(requestData->lockHandle); |
| 680 | |
| 681 | if ((idIndex < 0) || (idIndex >= maxDirEntries)) |
| 682 | { |
| 683 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 684 | "Invalid Data ID", phosphor::logging::entry("IDINDEX=%x", idIndex)); |
| 685 | return IPMI_CC_PARM_OUT_OF_RANGE; |
| 686 | } |
| 687 | |
| 688 | if (requestData->xferOffset >= mdrv2->smbiosDir.dir[idIndex].common.size) |
| 689 | { |
| 690 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 691 | "Offset is outside of range."); |
| 692 | return IPMI_CC_PARM_OUT_OF_RANGE; |
| 693 | } |
| 694 | |
| 695 | size_t outSize = |
| 696 | (requestData->xferLength > mdrv2->smbiosDir.dir[idIndex].xferSize) |
| 697 | ? mdrv2->smbiosDir.dir[idIndex].xferSize |
| 698 | : requestData->xferLength; |
| 699 | if (outSize > UINT_MAX - requestData->xferOffset) |
| 700 | { |
| 701 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 702 | "Out size and offset are out of range"); |
| 703 | return IPMI_CC_PARM_OUT_OF_RANGE; |
| 704 | } |
| 705 | if ((requestData->xferOffset + outSize) > |
| 706 | mdrv2->smbiosDir.dir[idIndex].common.size) |
| 707 | { |
| 708 | outSize = |
| 709 | mdrv2->smbiosDir.dir[idIndex].common.size - requestData->xferOffset; |
| 710 | } |
| 711 | |
| 712 | responseData->xferLength = outSize; |
| 713 | if (responseData->xferLength > requestData->xferLength) |
| 714 | { |
| 715 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 716 | "Get data block unexpected error."); |
| 717 | return IPMI_CC_UNSPECIFIED_ERROR; |
| 718 | } |
| 719 | |
| 720 | if ((requestData->xferOffset + outSize) > |
| 721 | UINT_MAX - |
| 722 | reinterpret_cast<size_t>(mdrv2->smbiosDir.dir[idIndex].dataStorage)) |
| 723 | { |
| 724 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 725 | "Input data to calculate checksum is out of range"); |
| 726 | return IPMI_CC_PARM_OUT_OF_RANGE; |
| 727 | } |
| 728 | |
| 729 | uint32_t u32Checksum = mdrv2->calcChecksum32( |
| 730 | mdrv2->smbiosDir.dir[idIndex].dataStorage + requestData->xferOffset, |
| 731 | outSize); |
| 732 | if (u32Checksum == invalidChecksum) |
| 733 | { |
| 734 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 735 | "Get data block failed - invalid checksum"); |
| 736 | return IPMI_CC_OEM_INVALID_CHECKSUM; |
| 737 | } |
| 738 | responseData->checksum = u32Checksum; |
| 739 | |
| 740 | *data_len = sizeof(responseData->xferLength) + |
| 741 | sizeof(responseData->checksum) + outSize; |
| 742 | |
| 743 | if (*data_len > MAX_IPMI_BUFFER) // length + completion code should no more |
| 744 | // than MAX_IPMI_BUFFER |
| 745 | { |
| 746 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 747 | "Data length send from service is invalid"); |
| 748 | *data_len = 0; |
| 749 | return IPMI_CC_RESPONSE_ERROR; |
| 750 | } |
| 751 | |
| 752 | std::copy( |
| 753 | &mdrv2->smbiosDir.dir[idIndex].dataStorage[requestData->xferOffset], |
| 754 | &mdrv2->smbiosDir.dir[idIndex] |
| 755 | .dataStorage[requestData->xferOffset + outSize], |
| 756 | responseData->data); |
| 757 | |
| 758 | return IPMI_CC_OK; |
| 759 | } |
| 760 | |
jayaprakash Mutyala | 3104b3f | 2019-06-10 19:23:07 +0000 | [diff] [blame] | 761 | /** @brief implements mdr2 send data block command |
| 762 | * @param agentId |
| 763 | * @param lockHandle |
| 764 | * @param xferOffset |
| 765 | * @param xferLength |
| 766 | * @param checksum |
| 767 | * |
| 768 | * @returns IPMI completion code |
| 769 | */ |
| 770 | ipmi::RspType<> mdr2SendDataBlock(uint16_t agentId, uint16_t lockHandle, |
| 771 | uint32_t xferOffset, uint32_t xferLength, |
| 772 | uint32_t checksum) |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 773 | { |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 774 | if (mdrv2 == nullptr) |
| 775 | { |
| 776 | mdrv2 = std::make_unique<MDRV2>(); |
| 777 | } |
| 778 | |
jayaprakash Mutyala | 3104b3f | 2019-06-10 19:23:07 +0000 | [diff] [blame] | 779 | int agentIndex = mdrv2->agentLookup(agentId); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 780 | if (agentIndex == -1) |
| 781 | { |
| 782 | phosphor::logging::log<phosphor::logging::level::ERR>( |
jayaprakash Mutyala | 3104b3f | 2019-06-10 19:23:07 +0000 | [diff] [blame] | 783 | "Unknown agent id", phosphor::logging::entry("ID=%x", agentId)); |
| 784 | return ipmi::responseParmOutOfRange(); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 785 | } |
| 786 | |
jayaprakash Mutyala | 3104b3f | 2019-06-10 19:23:07 +0000 | [diff] [blame] | 787 | int idIndex = mdrv2->findLockHandle(lockHandle); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 788 | |
| 789 | if ((idIndex < 0) || (idIndex >= maxDirEntries)) |
| 790 | { |
| 791 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 792 | "Invalid Data ID", phosphor::logging::entry("IDINDEX=%x", idIndex)); |
jayaprakash Mutyala | 3104b3f | 2019-06-10 19:23:07 +0000 | [diff] [blame] | 793 | return ipmi::responseParmOutOfRange(); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 794 | } |
| 795 | |
| 796 | if (mdrv2->smbiosIsUpdating(idIndex)) |
| 797 | { |
jayaprakash Mutyala | 3104b3f | 2019-06-10 19:23:07 +0000 | [diff] [blame] | 798 | if (xferOffset > UINT_MAX - xferLength) |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 799 | { |
| 800 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 801 | "Offset and length are out of range"); |
jayaprakash Mutyala | 3104b3f | 2019-06-10 19:23:07 +0000 | [diff] [blame] | 802 | return ipmi::responseParmOutOfRange(); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 803 | } |
jayaprakash Mutyala | 3104b3f | 2019-06-10 19:23:07 +0000 | [diff] [blame] | 804 | if (((xferOffset + xferLength) > |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 805 | mdrv2->smbiosDir.dir[idIndex].maxDataSize) || |
jayaprakash Mutyala | 3104b3f | 2019-06-10 19:23:07 +0000 | [diff] [blame] | 806 | ((xferOffset + xferLength) > |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 807 | mdrv2->smbiosDir.dir[idIndex].common.dataSetSize)) |
| 808 | { |
| 809 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 810 | "Send data block Invalid offset/length"); |
jayaprakash Mutyala | 3104b3f | 2019-06-10 19:23:07 +0000 | [diff] [blame] | 811 | return ipmi::responseReqDataLenExceeded(); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 812 | } |
| 813 | if (reinterpret_cast<size_t>( |
| 814 | mdrv2->smbiosDir.dir[idIndex].dataStorage) > |
jayaprakash Mutyala | 3104b3f | 2019-06-10 19:23:07 +0000 | [diff] [blame] | 815 | UINT_MAX - xferOffset) |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 816 | { |
| 817 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 818 | "Offset is out of range"); |
jayaprakash Mutyala | 3104b3f | 2019-06-10 19:23:07 +0000 | [diff] [blame] | 819 | return ipmi::responseParmOutOfRange(); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 820 | } |
| 821 | uint8_t *destAddr = |
jayaprakash Mutyala | 3104b3f | 2019-06-10 19:23:07 +0000 | [diff] [blame] | 822 | mdrv2->smbiosDir.dir[idIndex].dataStorage + xferOffset; |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 823 | uint8_t *sourceAddr = reinterpret_cast<uint8_t *>(mdrv2->area->vPtr); |
jayaprakash Mutyala | 3104b3f | 2019-06-10 19:23:07 +0000 | [diff] [blame] | 824 | uint32_t calcChecksum = mdrv2->calcChecksum32(sourceAddr, xferLength); |
| 825 | if (calcChecksum != checksum) |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 826 | { |
| 827 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 828 | "Send data block Invalid checksum"); |
jayaprakash Mutyala | 3104b3f | 2019-06-10 19:23:07 +0000 | [diff] [blame] | 829 | return ipmi::response(ccOemInvalidChecksum); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 830 | } |
| 831 | else |
| 832 | { |
jayaprakash Mutyala | 3104b3f | 2019-06-10 19:23:07 +0000 | [diff] [blame] | 833 | if (reinterpret_cast<size_t>(sourceAddr) > UINT_MAX - xferLength) |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 834 | { |
| 835 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 836 | "Length is out of range"); |
jayaprakash Mutyala | 3104b3f | 2019-06-10 19:23:07 +0000 | [diff] [blame] | 837 | return ipmi::responseParmOutOfRange(); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 838 | } |
jayaprakash Mutyala | 3104b3f | 2019-06-10 19:23:07 +0000 | [diff] [blame] | 839 | std::copy(sourceAddr, sourceAddr + xferLength, destAddr); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 840 | } |
| 841 | } |
| 842 | else |
| 843 | { |
| 844 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 845 | "Send data block failed, other data is updating"); |
jayaprakash Mutyala | 3104b3f | 2019-06-10 19:23:07 +0000 | [diff] [blame] | 846 | return ipmi::responseDestinationUnavailable(); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 847 | } |
| 848 | |
jayaprakash Mutyala | 3104b3f | 2019-06-10 19:23:07 +0000 | [diff] [blame] | 849 | return ipmi::responseSuccess(); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 850 | } |
| 851 | |
| 852 | bool MDRV2::storeDatatoFlash(MDRSMBIOSHeader *mdrHdr, uint8_t *data) |
| 853 | { |
| 854 | std::ofstream smbiosFile(mdrType2File, |
| 855 | std::ios_base::binary | std::ios_base::trunc); |
| 856 | if (!smbiosFile.good()) |
| 857 | { |
| 858 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 859 | "Write data from flash error - Open MDRV2 table file failure"); |
| 860 | return false; |
| 861 | } |
| 862 | |
| 863 | try |
| 864 | { |
| 865 | smbiosFile.write(reinterpret_cast<char *>(mdrHdr), |
| 866 | sizeof(MDRSMBIOSHeader)); |
| 867 | smbiosFile.write(reinterpret_cast<char *>(data), mdrHdr->dataSize); |
| 868 | } |
| 869 | catch (std::ofstream::failure &e) |
| 870 | { |
| 871 | phosphor::logging::log<phosphor::logging::level::ERR>( |
Vernon Mauery | c7d517e | 2019-06-18 14:27:00 -0700 | [diff] [blame] | 872 | "Write data from flash error - write data error", |
| 873 | phosphor::logging::entry("ERROR=%s", e.what())); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 874 | return false; |
| 875 | } |
| 876 | |
| 877 | return true; |
| 878 | } |
| 879 | |
| 880 | void SharedMemoryArea::Initialize(uint32_t addr, uint32_t areaSize) |
| 881 | { |
| 882 | int memDriver = 0; |
| 883 | |
| 884 | // open mem driver for the system memory access |
| 885 | memDriver = open("/dev/vgasharedmem", O_RDONLY); |
| 886 | if (memDriver < 0) |
| 887 | { |
| 888 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 889 | "Cannot access mem driver"); |
| 890 | throw std::system_error(EIO, std::generic_category()); |
| 891 | } |
| 892 | |
| 893 | // map the system memory |
| 894 | vPtr = mmap(NULL, // where to map to: don't mind |
| 895 | areaSize, // how many bytes ? |
| 896 | PROT_READ, // want to read and write |
| 897 | MAP_SHARED, // no copy on write |
| 898 | memDriver, // handle to /dev/mem |
| 899 | (physicalAddr & pageMask)); // hopefully the Text-buffer :-) |
| 900 | |
| 901 | close(memDriver); |
| 902 | if (vPtr == MAP_FAILED) |
| 903 | { |
| 904 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 905 | "Failed to map share memory"); |
| 906 | throw std::system_error(EIO, std::generic_category()); |
| 907 | } |
| 908 | size = areaSize; |
| 909 | physicalAddr = addr; |
| 910 | } |
| 911 | |
| 912 | bool MDRV2::smbiosUnlock(uint8_t index) |
| 913 | { |
| 914 | bool ret; |
| 915 | switch (smbiosDir.dir[index].stage) |
| 916 | { |
| 917 | case MDR2SMBIOSStatusEnum::mdr2Updating: |
| 918 | smbiosDir.dir[index].stage = MDR2SMBIOSStatusEnum::mdr2Updated; |
| 919 | smbiosDir.dir[index].lock = MDR2DirLockEnum::mdr2DirUnlock; |
| 920 | |
| 921 | timer->stop(); |
| 922 | smbiosDir.dir[index].lockHandle = 0; |
| 923 | ret = true; |
| 924 | break; |
| 925 | |
| 926 | case MDR2SMBIOSStatusEnum::mdr2Updated: |
| 927 | case MDR2SMBIOSStatusEnum::mdr2Loaded: |
| 928 | smbiosDir.dir[index].lock = MDR2DirLockEnum::mdr2DirUnlock; |
| 929 | |
| 930 | timer->stop(); |
| 931 | |
| 932 | smbiosDir.dir[index].lockHandle = 0; |
| 933 | ret = true; |
| 934 | break; |
| 935 | |
| 936 | default: |
| 937 | break; |
| 938 | } |
| 939 | |
| 940 | return ret; |
| 941 | } |
| 942 | |
| 943 | bool MDRV2::smbiosTryLock(uint8_t flag, uint8_t index, uint16_t *session, |
| 944 | uint16_t timeout) |
| 945 | { |
| 946 | bool ret = false; |
| 947 | uint32_t u32Status = 0; |
| 948 | |
| 949 | if (timeout == 0) |
| 950 | { |
| 951 | timeout = defaultTimeout; |
| 952 | } |
| 953 | std::chrono::microseconds usec(timeout * sysClock); |
| 954 | |
| 955 | switch (smbiosDir.dir[index].stage) |
| 956 | { |
| 957 | case MDR2SMBIOSStatusEnum::mdr2Updating: |
| 958 | if (smbiosDir.dir[index].lock != MDR2DirLockEnum::mdr2DirLock) |
| 959 | { |
| 960 | smbiosDir.dir[index].lock = MDR2DirLockEnum::mdr2DirLock; |
| 961 | timer->start(usec); |
| 962 | lockIndex = index; |
| 963 | |
| 964 | *session = getSessionHandle(&smbiosDir); |
| 965 | smbiosDir.dir[index].lockHandle = *session; |
| 966 | ret = true; |
| 967 | } |
| 968 | break; |
| 969 | case MDR2SMBIOSStatusEnum::mdr2Init: |
| 970 | if (flag) |
| 971 | { |
| 972 | smbiosDir.dir[index].stage = MDR2SMBIOSStatusEnum::mdr2Updating; |
| 973 | smbiosDir.dir[index].lock = MDR2DirLockEnum::mdr2DirUnlock; |
| 974 | timer->start(usec); |
| 975 | lockIndex = index; |
| 976 | |
| 977 | *session = getSessionHandle(&smbiosDir); |
| 978 | smbiosDir.dir[index].lockHandle = *session; |
| 979 | ret = true; |
| 980 | } |
| 981 | break; |
| 982 | |
| 983 | case MDR2SMBIOSStatusEnum::mdr2Updated: |
| 984 | case MDR2SMBIOSStatusEnum::mdr2Loaded: |
| 985 | if (smbiosDir.dir[index].lock != MDR2DirLockEnum::mdr2DirLock) |
| 986 | { |
| 987 | if (flag) |
| 988 | { |
| 989 | smbiosDir.dir[index].stage = |
| 990 | MDR2SMBIOSStatusEnum::mdr2Updating; |
| 991 | smbiosDir.dir[index].lock = MDR2DirLockEnum::mdr2DirUnlock; |
| 992 | } |
| 993 | else |
| 994 | { |
| 995 | smbiosDir.dir[index].lock = MDR2DirLockEnum::mdr2DirLock; |
| 996 | } |
| 997 | |
| 998 | timer->start(usec); |
| 999 | lockIndex = index; |
| 1000 | |
| 1001 | *session = getSessionHandle(&smbiosDir); |
| 1002 | smbiosDir.dir[index].lockHandle = *session; |
| 1003 | ret = true; |
| 1004 | } |
| 1005 | break; |
| 1006 | |
| 1007 | default: |
| 1008 | break; |
| 1009 | } |
| 1010 | return ret; |
| 1011 | } |
| 1012 | |
| 1013 | void MDRV2::timeoutHandler() |
| 1014 | { |
| 1015 | smbiosUnlock(lockIndex); |
| 1016 | mdrv2->area.reset(nullptr); |
| 1017 | } |
| 1018 | |
jayaprakash Mutyala | 40fec61 | 2019-06-19 11:53:03 +0000 | [diff] [blame] | 1019 | /** @brief implements mdr2 lock data command |
| 1020 | * @param agentId |
| 1021 | * @param dataInfo |
| 1022 | * @param timeout |
| 1023 | * |
| 1024 | * @returns IPMI completion code plus response data |
| 1025 | * - mdr2Version |
| 1026 | * - session |
| 1027 | * - dataLength |
| 1028 | * - xferAddress |
| 1029 | * - xferLength |
| 1030 | */ |
| 1031 | ipmi::RspType<uint8_t, // mdr2Version |
| 1032 | uint16_t, // session |
| 1033 | uint32_t, // dataLength |
| 1034 | uint32_t, // xferAddress |
| 1035 | uint32_t // xferLength |
| 1036 | > |
| 1037 | mdr2LockData(uint16_t agentId, std::array<uint8_t, dataInfoSize> dataInfo, |
| 1038 | uint16_t timeout) |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1039 | { |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1040 | if (mdrv2 == nullptr) |
| 1041 | { |
| 1042 | mdrv2 = std::make_unique<MDRV2>(); |
| 1043 | } |
| 1044 | |
jayaprakash Mutyala | 40fec61 | 2019-06-19 11:53:03 +0000 | [diff] [blame] | 1045 | int agentIndex = mdrv2->agentLookup(agentId); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1046 | if (agentIndex == -1) |
| 1047 | { |
| 1048 | phosphor::logging::log<phosphor::logging::level::ERR>( |
jayaprakash Mutyala | 40fec61 | 2019-06-19 11:53:03 +0000 | [diff] [blame] | 1049 | "Unknown agent id", phosphor::logging::entry("ID=%x", agentId)); |
| 1050 | return ipmi::responseParmOutOfRange(); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1051 | } |
| 1052 | |
Vernon Mauery | 15419dd | 2019-05-24 09:40:30 -0700 | [diff] [blame] | 1053 | std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus(); |
| 1054 | std::string service = ipmi::getService(*bus, mdrv2Interface, mdrv2Path); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1055 | |
jayaprakash Mutyala | 40fec61 | 2019-06-19 11:53:03 +0000 | [diff] [blame] | 1056 | int idIndex = mdrv2->findDataId(dataInfo.data(), sizeof(dataInfo), service); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1057 | |
| 1058 | if ((idIndex < 0) || (idIndex >= maxDirEntries)) |
| 1059 | { |
| 1060 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 1061 | "Invalid Data ID", phosphor::logging::entry("IDINDEX=%x", idIndex)); |
jayaprakash Mutyala | 40fec61 | 2019-06-19 11:53:03 +0000 | [diff] [blame] | 1062 | return ipmi::responseParmOutOfRange(); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1063 | } |
| 1064 | |
jayaprakash Mutyala | 40fec61 | 2019-06-19 11:53:03 +0000 | [diff] [blame] | 1065 | uint16_t session = 0; |
| 1066 | if (!mdrv2->smbiosTryLock(0, idIndex, &session, timeout)) |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1067 | { |
| 1068 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 1069 | "Lock Data failed - cannot lock idIndex"); |
jayaprakash Mutyala | 40fec61 | 2019-06-19 11:53:03 +0000 | [diff] [blame] | 1070 | return ipmi::responseCommandNotAvailable(); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1071 | } |
| 1072 | |
jayaprakash Mutyala | 40fec61 | 2019-06-19 11:53:03 +0000 | [diff] [blame] | 1073 | uint32_t dataLength = mdrv2->smbiosDir.dir[idIndex].common.size; |
| 1074 | uint32_t xferAddress = mdrv2->smbiosDir.dir[idIndex].xferBuff; |
| 1075 | uint32_t xferLength = mdrv2->smbiosDir.dir[idIndex].xferSize; |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1076 | |
jayaprakash Mutyala | 40fec61 | 2019-06-19 11:53:03 +0000 | [diff] [blame] | 1077 | return ipmi::responseSuccess(mdr2Version, session, dataLength, xferAddress, |
| 1078 | xferLength); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1079 | } |
| 1080 | |
jayaprakash Mutyala | dad548b | 2019-06-12 15:29:39 +0000 | [diff] [blame] | 1081 | /** @brief implements mdr2 unlock data command |
| 1082 | * @param agentId |
| 1083 | * @param lockHandle |
| 1084 | * |
| 1085 | * @returns IPMI completion code |
| 1086 | */ |
| 1087 | ipmi::RspType<> mdr2UnlockData(uint16_t agentId, uint16_t lockHandle) |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1088 | { |
| 1089 | phosphor::logging::log<phosphor::logging::level::ERR>("unlock data"); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1090 | |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1091 | if (mdrv2 == nullptr) |
| 1092 | { |
| 1093 | mdrv2 = std::make_unique<MDRV2>(); |
| 1094 | } |
| 1095 | |
jayaprakash Mutyala | dad548b | 2019-06-12 15:29:39 +0000 | [diff] [blame] | 1096 | int agentIndex = mdrv2->agentLookup(agentId); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1097 | if (agentIndex == -1) |
| 1098 | { |
| 1099 | phosphor::logging::log<phosphor::logging::level::ERR>( |
jayaprakash Mutyala | dad548b | 2019-06-12 15:29:39 +0000 | [diff] [blame] | 1100 | "Unknown agent id", phosphor::logging::entry("ID=%x", agentId)); |
| 1101 | return ipmi::responseParmOutOfRange(); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1102 | } |
| 1103 | |
jayaprakash Mutyala | dad548b | 2019-06-12 15:29:39 +0000 | [diff] [blame] | 1104 | int idIndex = mdrv2->findLockHandle(lockHandle); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1105 | |
| 1106 | if ((idIndex < 0) || (idIndex >= maxDirEntries)) |
| 1107 | { |
| 1108 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 1109 | "Invalid Data ID", phosphor::logging::entry("IDINDEX=%x", idIndex)); |
jayaprakash Mutyala | dad548b | 2019-06-12 15:29:39 +0000 | [diff] [blame] | 1110 | return ipmi::responseParmOutOfRange(); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1111 | } |
| 1112 | |
| 1113 | if (!mdrv2->smbiosUnlock(idIndex)) |
| 1114 | { |
| 1115 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 1116 | "Unlock Data failed - cannot unlock idIndex"); |
jayaprakash Mutyala | dad548b | 2019-06-12 15:29:39 +0000 | [diff] [blame] | 1117 | return ipmi::responseCommandNotAvailable(); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1118 | } |
| 1119 | |
jayaprakash Mutyala | dad548b | 2019-06-12 15:29:39 +0000 | [diff] [blame] | 1120 | return ipmi::responseSuccess(); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1121 | } |
| 1122 | |
Deepak Kumar Sahu | 529d415 | 2019-05-31 18:23:14 +0000 | [diff] [blame] | 1123 | /** |
| 1124 | @brief This command is executed after POST BIOS to get the session info. |
| 1125 | |
| 1126 | @param - agentId, dataInfo, dataLength, xferAddress, xferLength, timeout. |
| 1127 | |
| 1128 | @return xferStartAck and session on success. |
| 1129 | **/ |
| 1130 | ipmi::RspType<uint8_t, uint16_t> |
| 1131 | cmd_mdr2_data_start(uint16_t agentId, std::array<uint8_t, 16> dataInfo, |
| 1132 | uint32_t dataLength, uint32_t xferAddress, |
| 1133 | uint32_t xferLength, uint16_t timeout) |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1134 | { |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1135 | uint16_t session = 0; |
| 1136 | |
Deepak Kumar Sahu | 529d415 | 2019-05-31 18:23:14 +0000 | [diff] [blame] | 1137 | if (dataLength > smbiosTableStorageSize) |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1138 | { |
| 1139 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 1140 | "Requested data length is out of SMBIOS Table storage size."); |
Deepak Kumar Sahu | 529d415 | 2019-05-31 18:23:14 +0000 | [diff] [blame] | 1141 | return ipmi::responseParmOutOfRange(); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1142 | } |
Deepak Kumar Sahu | 529d415 | 2019-05-31 18:23:14 +0000 | [diff] [blame] | 1143 | if ((xferLength + xferAddress) > mdriiSMSize) |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1144 | { |
| 1145 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 1146 | "Invalid data address and size"); |
Deepak Kumar Sahu | 529d415 | 2019-05-31 18:23:14 +0000 | [diff] [blame] | 1147 | return ipmi::responseParmOutOfRange(); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1148 | } |
| 1149 | |
Vernon Mauery | 15419dd | 2019-05-24 09:40:30 -0700 | [diff] [blame] | 1150 | std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus(); |
| 1151 | std::string service = ipmi::getService(*bus, mdrv2Interface, mdrv2Path); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1152 | |
| 1153 | if (mdrv2 == nullptr) |
| 1154 | { |
| 1155 | mdrv2 = std::make_unique<MDRV2>(); |
| 1156 | } |
| 1157 | |
Deepak Kumar Sahu | 529d415 | 2019-05-31 18:23:14 +0000 | [diff] [blame] | 1158 | int agentIndex = mdrv2->agentLookup(agentId); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1159 | if (agentIndex == -1) |
| 1160 | { |
| 1161 | phosphor::logging::log<phosphor::logging::level::ERR>( |
Deepak Kumar Sahu | 529d415 | 2019-05-31 18:23:14 +0000 | [diff] [blame] | 1162 | "Unknown agent id", phosphor::logging::entry("ID=%x", agentId)); |
| 1163 | return ipmi::responseParmOutOfRange(); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1164 | } |
| 1165 | |
Deepak Kumar Sahu | 529d415 | 2019-05-31 18:23:14 +0000 | [diff] [blame] | 1166 | int idIndex = mdrv2->findDataId(dataInfo.data(), sizeof(dataInfo), service); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1167 | |
| 1168 | if ((idIndex < 0) || (idIndex >= maxDirEntries)) |
| 1169 | { |
| 1170 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 1171 | "Invalid Data ID", phosphor::logging::entry("IDINDEX=%x", idIndex)); |
Deepak Kumar Sahu | 529d415 | 2019-05-31 18:23:14 +0000 | [diff] [blame] | 1172 | return ipmi::responseParmOutOfRange(); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1173 | } |
| 1174 | |
Deepak Kumar Sahu | 529d415 | 2019-05-31 18:23:14 +0000 | [diff] [blame] | 1175 | if (mdrv2->smbiosTryLock(1, idIndex, &session, timeout)) |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1176 | { |
| 1177 | try |
| 1178 | { |
Deepak Kumar Sahu | 529d415 | 2019-05-31 18:23:14 +0000 | [diff] [blame] | 1179 | mdrv2->area = |
| 1180 | std::make_unique<SharedMemoryArea>(xferAddress, xferLength); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1181 | } |
| 1182 | catch (const std::system_error &e) |
| 1183 | { |
| 1184 | mdrv2->smbiosUnlock(idIndex); |
| 1185 | phosphor::logging::log<phosphor::logging::level::ERR>( |
Vernon Mauery | c7d517e | 2019-06-18 14:27:00 -0700 | [diff] [blame] | 1186 | "Unable to access share memory", |
| 1187 | phosphor::logging::entry("ERROR=%s", e.what())); |
Deepak Kumar Sahu | 529d415 | 2019-05-31 18:23:14 +0000 | [diff] [blame] | 1188 | return ipmi::responseUnspecifiedError(); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1189 | } |
Deepak Kumar Sahu | 529d415 | 2019-05-31 18:23:14 +0000 | [diff] [blame] | 1190 | mdrv2->smbiosDir.dir[idIndex].common.size = dataLength; |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1191 | mdrv2->smbiosDir.dir[idIndex].lockHandle = session; |
| 1192 | if (-1 == |
| 1193 | mdrv2->syncDirCommonData( |
| 1194 | idIndex, mdrv2->smbiosDir.dir[idIndex].common.size, service)) |
| 1195 | { |
| 1196 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 1197 | "Unable to sync data to service"); |
Deepak Kumar Sahu | 529d415 | 2019-05-31 18:23:14 +0000 | [diff] [blame] | 1198 | return ipmi::responseResponseError(); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1199 | } |
| 1200 | } |
| 1201 | else |
| 1202 | { |
| 1203 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 1204 | "Canot lock smbios"); |
Deepak Kumar Sahu | 529d415 | 2019-05-31 18:23:14 +0000 | [diff] [blame] | 1205 | return ipmi::responseUnspecifiedError(); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1206 | } |
| 1207 | |
Deepak Kumar Sahu | 529d415 | 2019-05-31 18:23:14 +0000 | [diff] [blame] | 1208 | static constexpr uint8_t xferStartAck = 1; |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1209 | |
Deepak Kumar Sahu | 529d415 | 2019-05-31 18:23:14 +0000 | [diff] [blame] | 1210 | return ipmi::responseSuccess(xferStartAck, session); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1211 | } |
| 1212 | |
Deepak Kumar Sahu | 529d415 | 2019-05-31 18:23:14 +0000 | [diff] [blame] | 1213 | /** |
| 1214 | @brief This command is executed to close the session. |
| 1215 | |
| 1216 | @param - agentId, lockHandle. |
| 1217 | |
| 1218 | @return completion code on success. |
| 1219 | **/ |
| 1220 | ipmi::RspType<> cmd_mdr2_data_done(uint16_t agentId, uint16_t lockHandle) |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1221 | { |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1222 | |
| 1223 | if (mdrv2 == nullptr) |
| 1224 | { |
| 1225 | mdrv2 = std::make_unique<MDRV2>(); |
| 1226 | } |
| 1227 | |
Deepak Kumar Sahu | 529d415 | 2019-05-31 18:23:14 +0000 | [diff] [blame] | 1228 | int agentIndex = mdrv2->agentLookup(agentId); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1229 | if (agentIndex == -1) |
| 1230 | { |
| 1231 | phosphor::logging::log<phosphor::logging::level::ERR>( |
Deepak Kumar Sahu | 529d415 | 2019-05-31 18:23:14 +0000 | [diff] [blame] | 1232 | "Unknown agent id", phosphor::logging::entry("ID=%x", agentId)); |
| 1233 | return ipmi::responseParmOutOfRange(); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1234 | } |
| 1235 | |
Deepak Kumar Sahu | 529d415 | 2019-05-31 18:23:14 +0000 | [diff] [blame] | 1236 | int idIndex = mdrv2->findLockHandle(lockHandle); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1237 | |
| 1238 | if ((idIndex < 0) || (idIndex >= maxDirEntries)) |
| 1239 | { |
| 1240 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 1241 | "Invalid Data ID", phosphor::logging::entry("IDINDEX=%x", idIndex)); |
Deepak Kumar Sahu | 529d415 | 2019-05-31 18:23:14 +0000 | [diff] [blame] | 1242 | return ipmi::responseParmOutOfRange(); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1243 | } |
| 1244 | |
| 1245 | if (!mdrv2->smbiosUnlock(idIndex)) |
| 1246 | { |
| 1247 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 1248 | "Send data done failed - cannot unlock idIndex"); |
Deepak Kumar Sahu | 529d415 | 2019-05-31 18:23:14 +0000 | [diff] [blame] | 1249 | return ipmi::responseDestinationUnavailable(); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1250 | } |
| 1251 | |
| 1252 | mdrv2->area.reset(nullptr); |
| 1253 | MDRSMBIOSHeader mdr2Smbios; |
| 1254 | mdr2Smbios.mdrType = mdrTypeII; |
| 1255 | mdr2Smbios.dirVer = mdrv2->smbiosDir.dir[0].common.dataVersion; |
| 1256 | mdr2Smbios.timestamp = mdrv2->smbiosDir.dir[0].common.timestamp; |
| 1257 | mdr2Smbios.dataSize = mdrv2->smbiosDir.dir[0].common.size; |
| 1258 | |
| 1259 | if (access(smbiosPath, 0) == -1) |
| 1260 | { |
| 1261 | int flag = mkdir(smbiosPath, S_IRWXU); |
| 1262 | if (flag != 0) |
| 1263 | { |
| 1264 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 1265 | "create folder failed for writting smbios file"); |
| 1266 | } |
| 1267 | } |
| 1268 | if (!mdrv2->storeDatatoFlash( |
| 1269 | &mdr2Smbios, mdrv2->smbiosDir.dir[smbiosDirIndex].dataStorage)) |
| 1270 | { |
| 1271 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 1272 | "MDR2 Store data to flash failed"); |
Deepak Kumar Sahu | 529d415 | 2019-05-31 18:23:14 +0000 | [diff] [blame] | 1273 | return ipmi::responseDestinationUnavailable(); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1274 | } |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1275 | bool status = false; |
Vernon Mauery | 15419dd | 2019-05-24 09:40:30 -0700 | [diff] [blame] | 1276 | std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus(); |
| 1277 | std::string service = ipmi::getService(*bus, mdrv2Interface, mdrv2Path); |
| 1278 | sdbusplus::message::message method = bus->new_method_call( |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1279 | service.c_str(), mdrv2Path, mdrv2Interface, "AgentSynchronizeData"); |
| 1280 | |
| 1281 | try |
| 1282 | { |
Vernon Mauery | 15419dd | 2019-05-24 09:40:30 -0700 | [diff] [blame] | 1283 | sdbusplus::message::message reply = bus->call(method); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1284 | reply.read(status); |
| 1285 | } |
Vernon Mauery | c7d517e | 2019-06-18 14:27:00 -0700 | [diff] [blame] | 1286 | catch (sdbusplus::exception_t &e) |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1287 | { |
| 1288 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 1289 | "Error Sync data with service", |
Vernon Mauery | c7d517e | 2019-06-18 14:27:00 -0700 | [diff] [blame] | 1290 | phosphor::logging::entry("ERROR=%s", e.what()), |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1291 | phosphor::logging::entry("SERVICE=%s", service.c_str()), |
| 1292 | phosphor::logging::entry("PATH=%s", mdrv2Path)); |
Deepak Kumar Sahu | 529d415 | 2019-05-31 18:23:14 +0000 | [diff] [blame] | 1293 | return ipmi::responseResponseError(); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1294 | } |
| 1295 | |
| 1296 | if (!status) |
| 1297 | { |
| 1298 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 1299 | "Sync data with service failure"); |
Deepak Kumar Sahu | 529d415 | 2019-05-31 18:23:14 +0000 | [diff] [blame] | 1300 | return ipmi::responseUnspecifiedError(); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1301 | } |
| 1302 | |
Deepak Kumar Sahu | 529d415 | 2019-05-31 18:23:14 +0000 | [diff] [blame] | 1303 | return ipmi::responseSuccess(); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1304 | } |
| 1305 | |
| 1306 | static void register_netfn_smbiosmdrv2_functions(void) |
| 1307 | { |
| 1308 | // MDR V2 Command |
| 1309 | // <Get MDRII Status Command> |
jayaprakash Mutyala | 853d829 | 2019-05-31 18:17:42 +0000 | [diff] [blame] | 1310 | ipmi::registerHandler(ipmi::prioOemBase, NETFUN_INTEL_APP_OEM, |
| 1311 | IPMI_NETFN_INTEL_OEM_APP_CMD::MDRII_AGENT_STATUS, |
| 1312 | ipmi::Privilege::Operator, mdr2AgentStatus); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1313 | |
| 1314 | // <Get MDRII Directory Command> |
jayaprakash Mutyala | dad548b | 2019-06-12 15:29:39 +0000 | [diff] [blame] | 1315 | ipmi::registerHandler(ipmi::prioOemBase, NETFUN_INTEL_APP_OEM, |
| 1316 | IPMI_NETFN_INTEL_OEM_APP_CMD::MDRII_GET_DIR, |
| 1317 | ipmi::Privilege::Operator, mdr2GetDir); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1318 | |
| 1319 | // <Send MDRII Directory Command> |
| 1320 | ipmi_register_callback(NETFUN_INTEL_APP_OEM, |
| 1321 | IPMI_NETFN_INTEL_OEM_APP_CMD::MDRII_SEND_DIR, NULL, |
| 1322 | cmd_mdr2_send_dir, PRIVILEGE_OPERATOR); |
| 1323 | |
| 1324 | // <Get MDRII Data Info Command> |
| 1325 | ipmi_register_callback(NETFUN_INTEL_APP_OEM, |
| 1326 | IPMI_NETFN_INTEL_OEM_APP_CMD::MDRII_GET_DATA_INFO, |
| 1327 | NULL, cmd_mdr2_get_data_info, PRIVILEGE_OPERATOR); |
| 1328 | |
| 1329 | // <Send MDRII Info Offer> |
jayaprakash Mutyala | 853d829 | 2019-05-31 18:17:42 +0000 | [diff] [blame] | 1330 | ipmi::registerHandler( |
| 1331 | ipmi::prioOemBase, NETFUN_INTEL_APP_OEM, |
| 1332 | IPMI_NETFN_INTEL_OEM_APP_CMD::MDRII_SEND_DATA_INFO_OFFER, |
| 1333 | ipmi::Privilege::Operator, mdr2DataInfoOffer); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1334 | |
| 1335 | // <Send MDRII Data Info> |
| 1336 | ipmi_register_callback(NETFUN_INTEL_APP_OEM, |
| 1337 | IPMI_NETFN_INTEL_OEM_APP_CMD::MDRII_SEND_DATA_INFO, |
| 1338 | NULL, cmd_mdr2_send_data_info, PRIVILEGE_OPERATOR); |
| 1339 | |
| 1340 | // <Get MDRII Data Block Command> |
| 1341 | ipmi_register_callback(NETFUN_INTEL_APP_OEM, |
| 1342 | IPMI_NETFN_INTEL_OEM_APP_CMD::MDRII_GET_DATA_BLOCK, |
| 1343 | NULL, cmd_mdr2_get_data_block, PRIVILEGE_OPERATOR); |
| 1344 | |
| 1345 | // <Send MDRII Data Block> |
jayaprakash Mutyala | 3104b3f | 2019-06-10 19:23:07 +0000 | [diff] [blame] | 1346 | ipmi::registerHandler(ipmi::prioOemBase, NETFUN_INTEL_APP_OEM, |
| 1347 | IPMI_NETFN_INTEL_OEM_APP_CMD::MDRII_SEND_DATA_BLOCK, |
| 1348 | ipmi::Privilege::Operator, mdr2SendDataBlock); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1349 | |
| 1350 | // <Lock MDRII Data Command> |
jayaprakash Mutyala | 40fec61 | 2019-06-19 11:53:03 +0000 | [diff] [blame] | 1351 | ipmi::registerHandler(ipmi::prioOemBase, NETFUN_INTEL_APP_OEM, |
| 1352 | IPMI_NETFN_INTEL_OEM_APP_CMD::MDRII_LOCK_DATA, |
| 1353 | ipmi::Privilege::Operator, mdr2LockData); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1354 | |
| 1355 | // <Unlock MDRII Data Command> |
jayaprakash Mutyala | dad548b | 2019-06-12 15:29:39 +0000 | [diff] [blame] | 1356 | ipmi::registerHandler(ipmi::prioOemBase, NETFUN_INTEL_APP_OEM, |
| 1357 | IPMI_NETFN_INTEL_OEM_APP_CMD::MDRII_UNLOCK_DATA, |
| 1358 | ipmi::Privilege::Operator, mdr2UnlockData); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1359 | |
| 1360 | // <Send MDRII Data Start> |
Deepak Kumar Sahu | 529d415 | 2019-05-31 18:23:14 +0000 | [diff] [blame] | 1361 | ipmi::registerHandler(ipmi::prioOemBase, NETFUN_INTEL_APP_OEM, |
| 1362 | IPMI_NETFN_INTEL_OEM_APP_CMD::MDRII_DATA_START, |
| 1363 | ipmi::Privilege::Operator, cmd_mdr2_data_start); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1364 | |
| 1365 | // <Send MDRII Data Done> |
Deepak Kumar Sahu | 529d415 | 2019-05-31 18:23:14 +0000 | [diff] [blame] | 1366 | ipmi::registerHandler(ipmi::prioOemBase, NETFUN_INTEL_APP_OEM, |
| 1367 | IPMI_NETFN_INTEL_OEM_APP_CMD::MDRII_DATA_DONE, |
| 1368 | ipmi::Privilege::Operator, cmd_mdr2_data_done); |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1369 | } |