blob: 4034cff5c33b44d4588a6693525bc97702b36d8a [file] [log] [blame]
Jason M. Bills3f7c5e42018-10-03 14:00:41 -07001/*
Jason M. Bills1a2fbdd2019-05-10 09:05:37 -07002// Copyright (c) 2017-2019 Intel Corporation
Jason M. Bills3f7c5e42018-10-03 14:00:41 -07003//
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
Patrick Ventureca99ef52019-10-20 14:00:50 -070017#include "storagecommands.hpp"
18
19#include "commandutils.hpp"
Peter Foley21a1b5f2023-10-31 17:42:04 -040020#include "fruutils.hpp"
Patrick Ventureca99ef52019-10-20 14:00:50 -070021#include "ipmi_to_redfish_hooks.hpp"
22#include "sdrutils.hpp"
Patrick Venturec2a07d42020-05-30 16:35:03 -070023#include "types.hpp"
Patrick Ventureca99ef52019-10-20 14:00:50 -070024
Jason M. Bills1d4d54d2019-04-23 11:26:11 -070025#include <boost/algorithm/string.hpp>
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070026#include <boost/container/flat_map.hpp>
Johnathan Manteyee27fe02024-06-26 07:54:42 -070027#include <boost/process.hpp>
James Feist2a265d52019-04-08 11:16:27 -070028#include <ipmid/api.hpp>
James Feist25690252019-12-23 12:25:49 -080029#include <ipmid/message.hpp>
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070030#include <phosphor-logging/log.hpp>
31#include <sdbusplus/message/types.hpp>
32#include <sdbusplus/timer.hpp>
James Feistfcd2d3a2020-05-28 10:38:15 -070033
34#include <filesystem>
Archana Kakanif23fd542021-09-16 05:05:10 +000035#include <fstream>
Johnathan Manteyee27fe02024-06-26 07:54:42 -070036#include <functional>
James Feistfcd2d3a2020-05-28 10:38:15 -070037#include <iostream>
Jason M. Billsc04e2e72018-11-28 15:15:56 -080038#include <stdexcept>
Johnathan Manteyee27fe02024-06-26 07:54:42 -070039#include <string_view>
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070040
Patrick Venture9ce789f2019-10-17 09:09:39 -070041static constexpr bool DEBUG = false;
42
Jason M. Bills1d4d54d2019-04-23 11:26:11 -070043namespace intel_oem::ipmi::sel
44{
45static const std::filesystem::path selLogDir = "/var/log";
46static const std::string selLogFilename = "ipmi_sel";
47
48static int getFileTimestamp(const std::filesystem::path& file)
49{
50 struct stat st;
51
52 if (stat(file.c_str(), &st) >= 0)
53 {
54 return st.st_mtime;
55 }
56 return ::ipmi::sel::invalidTimeStamp;
57}
58
59namespace erase_time
Jason M. Bills7944c302019-03-20 15:24:05 -070060{
61static constexpr const char* selEraseTimestamp = "/var/lib/ipmi/sel_erase_time";
62
63void save()
64{
65 // open the file, creating it if necessary
66 int fd = open(selEraseTimestamp, O_WRONLY | O_CREAT | O_CLOEXEC, 0644);
67 if (fd < 0)
68 {
69 std::cerr << "Failed to open file\n";
70 return;
71 }
72
73 // update the file timestamp to the current time
74 if (futimens(fd, NULL) < 0)
75 {
76 std::cerr << "Failed to update timestamp: "
77 << std::string(strerror(errno));
78 }
79 close(fd);
80}
81
82int get()
83{
Jason M. Bills1d4d54d2019-04-23 11:26:11 -070084 return getFileTimestamp(selEraseTimestamp);
Jason M. Bills7944c302019-03-20 15:24:05 -070085}
Jason M. Bills1d4d54d2019-04-23 11:26:11 -070086} // namespace erase_time
87} // namespace intel_oem::ipmi::sel
Jason M. Bills7944c302019-03-20 15:24:05 -070088
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070089namespace ipmi
90{
91
92namespace storage
93{
94
Jason M. Billse2d1aee2018-10-03 15:57:18 -070095constexpr static const size_t maxMessageSize = 64;
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070096constexpr static const size_t maxFruSdrNameSize = 16;
James Feiste4f710d2020-05-20 15:50:30 -070097using ObjectType = boost::container::flat_map<
98 std::string, boost::container::flat_map<std::string, DbusVariant>>;
99using ManagedObjectType =
100 boost::container::flat_map<sdbusplus::message::object_path, ObjectType>;
101using ManagedEntry = std::pair<sdbusplus::message::object_path, ObjectType>;
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700102
James Feist3bcba452018-12-20 12:31:03 -0800103constexpr static const char* fruDeviceServiceName =
104 "xyz.openbmc_project.FruDevice";
James Feist25690252019-12-23 12:25:49 -0800105constexpr static const size_t writeTimeoutSeconds = 10;
Anoop S358e7df2020-05-05 16:43:34 +0000106constexpr static const char* chassisTypeRackMount = "23";
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700107
Jason M. Bills4ed6f2c2019-04-02 12:21:25 -0700108// event direction is bit[7] of eventType where 1b = Deassertion event
109constexpr static const uint8_t deassertionEvent = 0x80;
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800110
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700111static std::vector<uint8_t> fruCache;
Johnathan Mantey07574002022-12-13 14:52:54 -0800112static uint16_t cacheBus = 0xFFFF;
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700113static uint8_t cacheAddr = 0XFF;
James Feiste4f710d2020-05-20 15:50:30 -0700114static uint8_t lastDevId = 0xFF;
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700115
Johnathan Mantey07574002022-12-13 14:52:54 -0800116static uint16_t writeBus = 0xFFFF;
James Feist25690252019-12-23 12:25:49 -0800117static uint8_t writeAddr = 0XFF;
118
Patrick Williamsf0feb492023-12-05 12:45:02 -0600119std::unique_ptr<sdbusplus::Timer> writeTimer = nullptr;
Patrick Williamsf944d2e2022-07-22 19:26:52 -0500120static std::vector<sdbusplus::bus::match_t> fruMatches;
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700121
James Feist25690252019-12-23 12:25:49 -0800122ManagedObjectType frus;
123
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700124// we unfortunately have to build a map of hashes in case there is a
125// collision to verify our dev-id
Johnathan Mantey07574002022-12-13 14:52:54 -0800126boost::container::flat_map<uint8_t, std::pair<uint16_t, uint8_t>> deviceHashes;
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700127
Jason M. Billse2d1aee2018-10-03 15:57:18 -0700128void registerStorageFunctions() __attribute__((constructor));
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700129
130bool writeFru()
131{
Johnathan Mantey07574002022-12-13 14:52:54 -0800132 if (writeBus == 0xFFFF && writeAddr == 0xFF)
James Feist25690252019-12-23 12:25:49 -0800133 {
134 return true;
135 }
Vernon Mauery15419dd2019-05-24 09:40:30 -0700136 std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus();
Patrick Williamsf944d2e2022-07-22 19:26:52 -0500137 sdbusplus::message_t writeFru = dbus->new_method_call(
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700138 fruDeviceServiceName, "/xyz/openbmc_project/FruDevice",
139 "xyz.openbmc_project.FruDeviceManager", "WriteFru");
James Feist25690252019-12-23 12:25:49 -0800140 writeFru.append(writeBus, writeAddr, fruCache);
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700141 try
142 {
Patrick Williamsf944d2e2022-07-22 19:26:52 -0500143 sdbusplus::message_t writeFruResp = dbus->call(writeFru);
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700144 }
Patrick Williamsbd51e6a2021-10-06 13:09:44 -0500145 catch (const sdbusplus::exception_t&)
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700146 {
147 // todo: log sel?
148 phosphor::logging::log<phosphor::logging::level::ERR>(
149 "error writing fru");
150 return false;
151 }
Johnathan Mantey07574002022-12-13 14:52:54 -0800152 writeBus = 0xFFFF;
James Feist25690252019-12-23 12:25:49 -0800153 writeAddr = 0xFF;
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700154 return true;
155}
156
James Feist25690252019-12-23 12:25:49 -0800157void createTimers()
Jason M. Billse2d1aee2018-10-03 15:57:18 -0700158{
Patrick Williamsf0feb492023-12-05 12:45:02 -0600159 writeTimer = std::make_unique<sdbusplus::Timer>(writeFru);
Jason M. Billse2d1aee2018-10-03 15:57:18 -0700160}
161
James Feiste4f710d2020-05-20 15:50:30 -0700162void recalculateHashes()
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700163{
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700164 deviceHashes.clear();
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700165 // hash the object paths to create unique device id's. increment on
166 // collision
167 std::hash<std::string> hasher;
168 for (const auto& fru : frus)
169 {
170 auto fruIface = fru.second.find("xyz.openbmc_project.FruDevice");
171 if (fruIface == fru.second.end())
172 {
173 continue;
174 }
175
176 auto busFind = fruIface->second.find("BUS");
177 auto addrFind = fruIface->second.find("ADDRESS");
178 if (busFind == fruIface->second.end() ||
179 addrFind == fruIface->second.end())
180 {
181 phosphor::logging::log<phosphor::logging::level::INFO>(
182 "fru device missing Bus or Address",
183 phosphor::logging::entry("FRU=%s", fru.first.str.c_str()));
184 continue;
185 }
186
Johnathan Mantey07574002022-12-13 14:52:54 -0800187 uint16_t fruBus = std::get<uint32_t>(busFind->second);
Vernon Mauery8166c8d2019-05-23 11:22:30 -0700188 uint8_t fruAddr = std::get<uint32_t>(addrFind->second);
Anoop S358e7df2020-05-05 16:43:34 +0000189 auto chassisFind = fruIface->second.find("CHASSIS_TYPE");
190 std::string chassisType;
191 if (chassisFind != fruIface->second.end())
192 {
193 chassisType = std::get<std::string>(chassisFind->second);
194 }
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700195
196 uint8_t fruHash = 0;
Anoop S358e7df2020-05-05 16:43:34 +0000197 if (chassisType.compare(chassisTypeRackMount) != 0)
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700198 {
199 fruHash = hasher(fru.first.str);
200 // can't be 0xFF based on spec, and 0 is reserved for baseboard
201 if (fruHash == 0 || fruHash == 0xFF)
202 {
203 fruHash = 1;
204 }
205 }
Johnathan Mantey07574002022-12-13 14:52:54 -0800206 std::pair<uint16_t, uint8_t> newDev(fruBus, fruAddr);
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700207
208 bool emplacePassed = false;
209 while (!emplacePassed)
210 {
211 auto resp = deviceHashes.emplace(fruHash, newDev);
212 emplacePassed = resp.second;
213 if (!emplacePassed)
214 {
215 fruHash++;
216 // can't be 0xFF based on spec, and 0 is reserved for
217 // baseboard
218 if (fruHash == 0XFF)
219 {
220 fruHash = 0x1;
221 }
222 }
223 }
224 }
James Feiste4f710d2020-05-20 15:50:30 -0700225}
226
227void replaceCacheFru(const std::shared_ptr<sdbusplus::asio::connection>& bus,
Archana Kakanif23fd542021-09-16 05:05:10 +0000228 boost::asio::yield_context& yield)
James Feiste4f710d2020-05-20 15:50:30 -0700229{
230 boost::system::error_code ec;
231
Johnathan Manteyee27fe02024-06-26 07:54:42 -0700232 frus = bus->yield_method_call<ManagedObjectType>(
233 yield, ec, fruDeviceServiceName, "/",
234 "org.freedesktop.DBus.ObjectManager", "GetManagedObjects");
James Feiste4f710d2020-05-20 15:50:30 -0700235 if (ec)
236 {
237 phosphor::logging::log<phosphor::logging::level::ERR>(
Johnathan Manteyee27fe02024-06-26 07:54:42 -0700238 "GetMangagedObjects for getSensorMap failed",
James Feiste4f710d2020-05-20 15:50:30 -0700239 phosphor::logging::entry("ERROR=%s", ec.message().c_str()));
240
241 return;
242 }
243 recalculateHashes();
244}
245
Vernon Mauerydcff1502022-09-28 11:12:46 -0700246ipmi::Cc getFru(ipmi::Context::ptr& ctx, uint8_t devId)
James Feiste4f710d2020-05-20 15:50:30 -0700247{
248 if (lastDevId == devId && devId != 0xFF)
249 {
250 return ipmi::ccSuccess;
251 }
252
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700253 auto deviceFind = deviceHashes.find(devId);
Johnathan Manteyee27fe02024-06-26 07:54:42 -0700254 if (deviceFind == deviceHashes.end())
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700255 {
256 return IPMI_CC_SENSOR_INVALID;
257 }
258
PavanKumarIntel3432a0a2023-07-10 14:37:29 +0000259 if (writeTimer->isRunning())
260 {
261 phosphor::logging::log<phosphor::logging::level::ERR>(
262 "Couldn't get raw fru as fru is updating");
263 return ipmi::ccBusy;
264 }
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700265 fruCache.clear();
James Feist25690252019-12-23 12:25:49 -0800266
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700267 cacheBus = deviceFind->second.first;
268 cacheAddr = deviceFind->second.second;
James Feist25690252019-12-23 12:25:49 -0800269
James Feiste4f710d2020-05-20 15:50:30 -0700270 boost::system::error_code ec;
271
Johnathan Manteyee27fe02024-06-26 07:54:42 -0700272 fruCache = ctx->bus->yield_method_call<std::vector<uint8_t>>(
273 ctx->yield, ec, fruDeviceServiceName, "/xyz/openbmc_project/FruDevice",
274 "xyz.openbmc_project.FruDeviceManager", "GetRawFru", cacheBus,
275 cacheAddr);
James Feist25690252019-12-23 12:25:49 -0800276 if (ec)
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700277 {
James Feist25690252019-12-23 12:25:49 -0800278 phosphor::logging::log<phosphor::logging::level::ERR>(
279 "Couldn't get raw fru",
280 phosphor::logging::entry("ERROR=%s", ec.message().c_str()));
Johnathan Mantey07574002022-12-13 14:52:54 -0800281 cacheBus = 0xFFFF;
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700282 cacheAddr = 0xFF;
James Feist25690252019-12-23 12:25:49 -0800283 return ipmi::ccResponseError;
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700284 }
285
286 lastDevId = devId;
James Feist25690252019-12-23 12:25:49 -0800287 return ipmi::ccSuccess;
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700288}
289
James Feiste4f710d2020-05-20 15:50:30 -0700290void writeFruIfRunning()
291{
292 if (!writeTimer->isRunning())
293 {
294 return;
295 }
296 writeTimer->stop();
297 writeFru();
298}
299
300void startMatch(void)
301{
302 if (fruMatches.size())
303 {
304 return;
305 }
306
307 fruMatches.reserve(2);
308
309 auto bus = getSdBus();
Patrick Williams1bcced02024-08-16 15:20:24 -0400310 fruMatches.emplace_back(
311 *bus,
312 "type='signal',arg0path='/xyz/openbmc_project/"
313 "FruDevice/',member='InterfacesAdded'",
314 [](sdbusplus::message_t& message) {
315 sdbusplus::message::object_path path;
316 ObjectType object;
317 try
318 {
319 message.read(path, object);
320 }
321 catch (const sdbusplus::exception_t&)
322 {
323 return;
324 }
325 auto findType = object.find("xyz.openbmc_project.FruDevice");
326 if (findType == object.end())
327 {
328 return;
329 }
330 writeFruIfRunning();
331 frus[path] = object;
332 recalculateHashes();
333 lastDevId = 0xFF;
334 });
James Feiste4f710d2020-05-20 15:50:30 -0700335
Patrick Williams1bcced02024-08-16 15:20:24 -0400336 fruMatches.emplace_back(
337 *bus,
338 "type='signal',arg0path='/xyz/openbmc_project/"
339 "FruDevice/',member='InterfacesRemoved'",
340 [](sdbusplus::message_t& message) {
341 sdbusplus::message::object_path path;
342 std::set<std::string> interfaces;
343 try
344 {
345 message.read(path, interfaces);
346 }
347 catch (const sdbusplus::exception_t&)
348 {
349 return;
350 }
351 auto findType = interfaces.find("xyz.openbmc_project.FruDevice");
352 if (findType == interfaces.end())
353 {
354 return;
355 }
356 writeFruIfRunning();
357 frus.erase(path);
358 recalculateHashes();
359 lastDevId = 0xFF;
360 });
James Feiste4f710d2020-05-20 15:50:30 -0700361
362 // call once to populate
Jason M. Bills48437462025-01-13 14:26:02 -0800363 boost::asio::spawn(*getIoContext(),
364 [](boost::asio::yield_context yield) {
365 replaceCacheFru(getSdBus(), yield);
366 },
367 {});
James Feiste4f710d2020-05-20 15:50:30 -0700368}
369
jayaprakash Mutyala5f4194e2019-05-20 16:17:01 +0000370/** @brief implements the read FRU data command
371 * @param fruDeviceId - FRU Device ID
372 * @param fruInventoryOffset - FRU Inventory Offset to write
373 * @param countToRead - Count to read
374 *
375 * @returns ipmi completion code plus response data
376 * - countWritten - Count written
377 */
378ipmi::RspType<uint8_t, // Count
379 std::vector<uint8_t> // Requested data
380 >
Vernon Mauerydcff1502022-09-28 11:12:46 -0700381 ipmiStorageReadFruData(ipmi::Context::ptr& ctx, uint8_t fruDeviceId,
James Feist25690252019-12-23 12:25:49 -0800382 uint16_t fruInventoryOffset, uint8_t countToRead)
Jason M. Billse2d1aee2018-10-03 15:57:18 -0700383{
jayaprakash Mutyala5f4194e2019-05-20 16:17:01 +0000384 if (fruDeviceId == 0xFF)
Jason M. Billse2d1aee2018-10-03 15:57:18 -0700385 {
jayaprakash Mutyala5f4194e2019-05-20 16:17:01 +0000386 return ipmi::responseInvalidFieldRequest();
Jason M. Billse2d1aee2018-10-03 15:57:18 -0700387 }
388
James Feiste4f710d2020-05-20 15:50:30 -0700389 ipmi::Cc status = getFru(ctx, fruDeviceId);
Jason M. Billse2d1aee2018-10-03 15:57:18 -0700390
jayaprakash Mutyala5f4194e2019-05-20 16:17:01 +0000391 if (status != ipmi::ccSuccess)
392 {
393 return ipmi::response(status);
394 }
395
396 size_t fromFruByteLen = 0;
397 if (countToRead + fruInventoryOffset < fruCache.size())
398 {
399 fromFruByteLen = countToRead;
400 }
401 else if (fruCache.size() > fruInventoryOffset)
402 {
403 fromFruByteLen = fruCache.size() - fruInventoryOffset;
404 }
405 else
406 {
srikanta mondal92108382020-02-27 18:53:20 +0000407 return ipmi::responseReqDataLenExceeded();
jayaprakash Mutyala5f4194e2019-05-20 16:17:01 +0000408 }
409
410 std::vector<uint8_t> requestedData;
411
412 requestedData.insert(
413 requestedData.begin(), fruCache.begin() + fruInventoryOffset,
414 fruCache.begin() + fruInventoryOffset + fromFruByteLen);
415
Patrick Venture70b17f92019-10-28 20:01:53 -0700416 return ipmi::responseSuccess(static_cast<uint8_t>(requestedData.size()),
417 requestedData);
Jason M. Billse2d1aee2018-10-03 15:57:18 -0700418}
419
jayaprakash Mutyala5f4194e2019-05-20 16:17:01 +0000420/** @brief implements the write FRU data command
421 * @param fruDeviceId - FRU Device ID
422 * @param fruInventoryOffset - FRU Inventory Offset to write
423 * @param dataToWrite - Data to write
424 *
425 * @returns ipmi completion code plus response data
426 * - countWritten - Count written
427 */
Patrick Williams1bcced02024-08-16 15:20:24 -0400428ipmi::RspType<uint8_t> ipmiStorageWriteFruData(
429 ipmi::Context::ptr& ctx, uint8_t fruDeviceId, uint16_t fruInventoryOffset,
430 std::vector<uint8_t>& dataToWrite)
Jason M. Billse2d1aee2018-10-03 15:57:18 -0700431{
jayaprakash Mutyala5f4194e2019-05-20 16:17:01 +0000432 if (fruDeviceId == 0xFF)
Jason M. Billse2d1aee2018-10-03 15:57:18 -0700433 {
jayaprakash Mutyala5f4194e2019-05-20 16:17:01 +0000434 return ipmi::responseInvalidFieldRequest();
Jason M. Billse2d1aee2018-10-03 15:57:18 -0700435 }
436
jayaprakash Mutyala5f4194e2019-05-20 16:17:01 +0000437 size_t writeLen = dataToWrite.size();
Jason M. Billse2d1aee2018-10-03 15:57:18 -0700438
James Feiste4f710d2020-05-20 15:50:30 -0700439 ipmi::Cc status = getFru(ctx, fruDeviceId);
jayaprakash Mutyala5f4194e2019-05-20 16:17:01 +0000440 if (status != ipmi::ccSuccess)
Jason M. Billse2d1aee2018-10-03 15:57:18 -0700441 {
jayaprakash Mutyala5f4194e2019-05-20 16:17:01 +0000442 return ipmi::response(status);
Jason M. Billse2d1aee2018-10-03 15:57:18 -0700443 }
Vernon Mauerydcff1502022-09-28 11:12:46 -0700444 size_t lastWriteAddr = fruInventoryOffset + writeLen;
Jason M. Billse2d1aee2018-10-03 15:57:18 -0700445 if (fruCache.size() < lastWriteAddr)
446 {
jayaprakash Mutyala5f4194e2019-05-20 16:17:01 +0000447 fruCache.resize(fruInventoryOffset + writeLen);
Jason M. Billse2d1aee2018-10-03 15:57:18 -0700448 }
449
jayaprakash Mutyala5f4194e2019-05-20 16:17:01 +0000450 std::copy(dataToWrite.begin(), dataToWrite.begin() + writeLen,
451 fruCache.begin() + fruInventoryOffset);
Jason M. Billse2d1aee2018-10-03 15:57:18 -0700452
Peter Foley21a1b5f2023-10-31 17:42:04 -0400453 bool atEnd = validateBasicFruContent(fruCache, lastWriteAddr);
jayaprakash Mutyala5f4194e2019-05-20 16:17:01 +0000454 uint8_t countWritten = 0;
James Feist25690252019-12-23 12:25:49 -0800455
456 writeBus = cacheBus;
457 writeAddr = cacheAddr;
Jason M. Billse2d1aee2018-10-03 15:57:18 -0700458 if (atEnd)
459 {
460 // cancel timer, we're at the end so might as well send it
James Feist25690252019-12-23 12:25:49 -0800461 writeTimer->stop();
Jason M. Billse2d1aee2018-10-03 15:57:18 -0700462 if (!writeFru())
463 {
jayaprakash Mutyala5f4194e2019-05-20 16:17:01 +0000464 return ipmi::responseInvalidFieldRequest();
Jason M. Billse2d1aee2018-10-03 15:57:18 -0700465 }
jayaprakash Mutyala5f4194e2019-05-20 16:17:01 +0000466 countWritten = std::min(fruCache.size(), static_cast<size_t>(0xFF));
Jason M. Billse2d1aee2018-10-03 15:57:18 -0700467 }
468 else
469 {
James Feist25690252019-12-23 12:25:49 -0800470 // start a timer, if no further data is sent to check to see if it is
471 // valid
472 writeTimer->start(std::chrono::duration_cast<std::chrono::microseconds>(
473 std::chrono::seconds(writeTimeoutSeconds)));
jayaprakash Mutyala5f4194e2019-05-20 16:17:01 +0000474 countWritten = 0;
Jason M. Billse2d1aee2018-10-03 15:57:18 -0700475 }
476
jayaprakash Mutyala5f4194e2019-05-20 16:17:01 +0000477 return ipmi::responseSuccess(countWritten);
Jason M. Billse2d1aee2018-10-03 15:57:18 -0700478}
479
jayaprakash Mutyalad33acd62019-05-17 19:37:25 +0000480/** @brief implements the get FRU inventory area info command
481 * @param fruDeviceId - FRU Device ID
482 *
483 * @returns IPMI completion code plus response data
484 * - inventorySize - Number of possible allocation units
485 * - accessType - Allocation unit size in bytes.
486 */
487ipmi::RspType<uint16_t, // inventorySize
488 uint8_t> // accessType
Vernon Mauerydcff1502022-09-28 11:12:46 -0700489 ipmiStorageGetFruInvAreaInfo(ipmi::Context::ptr& ctx, uint8_t fruDeviceId)
Jason M. Billse2d1aee2018-10-03 15:57:18 -0700490{
jayaprakash Mutyalad33acd62019-05-17 19:37:25 +0000491 if (fruDeviceId == 0xFF)
Jason M. Billse2d1aee2018-10-03 15:57:18 -0700492 {
jayaprakash Mutyalad33acd62019-05-17 19:37:25 +0000493 return ipmi::responseInvalidFieldRequest();
Jason M. Billse2d1aee2018-10-03 15:57:18 -0700494 }
Jason M. Billse2d1aee2018-10-03 15:57:18 -0700495
Jayaprakash Mutyala1e2ab062020-08-03 16:57:00 +0000496 ipmi::Cc ret = getFru(ctx, fruDeviceId);
497 if (ret != ipmi::ccSuccess)
498 {
499 return ipmi::response(ret);
500 }
Jason M. Billse2d1aee2018-10-03 15:57:18 -0700501
jayaprakash Mutyalad33acd62019-05-17 19:37:25 +0000502 constexpr uint8_t accessType =
503 static_cast<uint8_t>(GetFRUAreaAccessType::byte);
Jason M. Billse2d1aee2018-10-03 15:57:18 -0700504
jayaprakash Mutyalad33acd62019-05-17 19:37:25 +0000505 return ipmi::responseSuccess(fruCache.size(), accessType);
Jason M. Billse2d1aee2018-10-03 15:57:18 -0700506}
507
Vernon Mauerydcff1502022-09-28 11:12:46 -0700508ipmi::Cc getFruSdrCount(ipmi::Context::ptr&, size_t& count)
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700509{
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700510 count = deviceHashes.size();
Vernon Mauerydcff1502022-09-28 11:12:46 -0700511 return ipmi::ccSuccess;
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700512}
513
Vernon Mauerydcff1502022-09-28 11:12:46 -0700514ipmi::Cc getFruSdrs(ipmi::Context::ptr& ctx, size_t index,
515 get_sdr::SensorDataFruRecord& resp)
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700516{
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700517 if (deviceHashes.size() < index)
518 {
Vernon Mauerydcff1502022-09-28 11:12:46 -0700519 return ipmi::ccInvalidFieldRequest;
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700520 }
521 auto device = deviceHashes.begin() + index;
Johnathan Mantey07574002022-12-13 14:52:54 -0800522 uint16_t& bus = device->second.first;
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700523 uint8_t& address = device->second.second;
524
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700525 boost::container::flat_map<std::string, DbusVariant>* fruData = nullptr;
Patrick Williams1bcced02024-08-16 15:20:24 -0400526 auto fru = std::find_if(
527 frus.begin(), frus.end(),
528 [bus, address, &fruData](ManagedEntry& entry) {
529 auto findFruDevice =
530 entry.second.find("xyz.openbmc_project.FruDevice");
531 if (findFruDevice == entry.second.end())
532 {
533 return false;
534 }
535 fruData = &(findFruDevice->second);
536 auto findBus = findFruDevice->second.find("BUS");
537 auto findAddress = findFruDevice->second.find("ADDRESS");
538 if (findBus == findFruDevice->second.end() ||
539 findAddress == findFruDevice->second.end())
540 {
541 return false;
542 }
543 if (std::get<uint32_t>(findBus->second) != bus)
544 {
545 return false;
546 }
547 if (std::get<uint32_t>(findAddress->second) != address)
548 {
549 return false;
550 }
551 return true;
552 });
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700553 if (fru == frus.end())
554 {
Vernon Mauerydcff1502022-09-28 11:12:46 -0700555 return ipmi::ccResponseError;
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700556 }
Patrick Venture9ce789f2019-10-17 09:09:39 -0700557
James Feist25690252019-12-23 12:25:49 -0800558#ifdef USING_ENTITY_MANAGER_DECORATORS
559
Patrick Venture9ce789f2019-10-17 09:09:39 -0700560 boost::container::flat_map<std::string, DbusVariant>* entityData = nullptr;
Patrick Venture9ce789f2019-10-17 09:09:39 -0700561
James Feist25690252019-12-23 12:25:49 -0800562 // todo: this should really use caching, this is a very inefficient lookup
563 boost::system::error_code ec;
564 ManagedObjectType entities = ctx->bus->yield_method_call<ManagedObjectType>(
Nan Zhou9d2894d2022-09-20 22:22:00 +0000565 ctx->yield, ec, "xyz.openbmc_project.EntityManager",
566 "/xyz/openbmc_project/inventory", "org.freedesktop.DBus.ObjectManager",
567 "GetManagedObjects");
James Feist25690252019-12-23 12:25:49 -0800568
569 if (ec)
Patrick Venture9ce789f2019-10-17 09:09:39 -0700570 {
James Feist25690252019-12-23 12:25:49 -0800571 phosphor::logging::log<phosphor::logging::level::ERR>(
572 "GetMangagedObjects for getSensorMap failed",
573 phosphor::logging::entry("ERROR=%s", ec.message().c_str()));
Patrick Venture9ce789f2019-10-17 09:09:39 -0700574
James Feist25690252019-12-23 12:25:49 -0800575 return ipmi::ccResponseError;
576 }
Patrick Venture9ce789f2019-10-17 09:09:39 -0700577
Patrick Williams1bcced02024-08-16 15:20:24 -0400578 auto entity = std::find_if(
579 entities.begin(), entities.end(),
580 [bus, address, &entityData](ManagedEntry& entry) {
581 auto findFruDevice = entry.second.find(
582 "xyz.openbmc_project.Inventory.Decorator.FruDevice");
583 if (findFruDevice == entry.second.end())
584 {
585 return false;
586 }
James Feist25690252019-12-23 12:25:49 -0800587
Patrick Williams1bcced02024-08-16 15:20:24 -0400588 // Integer fields added via Entity-Manager json are uint64_ts by
589 // default.
590 auto findBus = findFruDevice->second.find("Bus");
591 auto findAddress = findFruDevice->second.find("Address");
James Feist25690252019-12-23 12:25:49 -0800592
Patrick Williams1bcced02024-08-16 15:20:24 -0400593 if (findBus == findFruDevice->second.end() ||
594 findAddress == findFruDevice->second.end())
595 {
596 return false;
597 }
598 if ((std::get<uint64_t>(findBus->second) != bus) ||
599 (std::get<uint64_t>(findAddress->second) != address))
600 {
601 return false;
602 }
James Feist25690252019-12-23 12:25:49 -0800603
Patrick Williams1bcced02024-08-16 15:20:24 -0400604 // At this point we found the device entry and should return
605 // true.
606 auto findIpmiDevice = entry.second.find(
607 "xyz.openbmc_project.Inventory.Decorator.Ipmi");
608 if (findIpmiDevice != entry.second.end())
609 {
610 entityData = &(findIpmiDevice->second);
611 }
James Feist25690252019-12-23 12:25:49 -0800612
Patrick Williams1bcced02024-08-16 15:20:24 -0400613 return true;
614 });
James Feist25690252019-12-23 12:25:49 -0800615
616 if (entity == entities.end())
617 {
618 if constexpr (DEBUG)
619 {
620 std::fprintf(stderr, "Ipmi or FruDevice Decorator interface "
621 "not found for Fru\n");
Patrick Venture9ce789f2019-10-17 09:09:39 -0700622 }
623 }
James Feist25690252019-12-23 12:25:49 -0800624
625#endif
Patrick Venture9ce789f2019-10-17 09:09:39 -0700626
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700627 std::string name;
628 auto findProductName = fruData->find("BOARD_PRODUCT_NAME");
629 auto findBoardName = fruData->find("PRODUCT_PRODUCT_NAME");
630 if (findProductName != fruData->end())
631 {
Vernon Mauery8166c8d2019-05-23 11:22:30 -0700632 name = std::get<std::string>(findProductName->second);
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700633 }
634 else if (findBoardName != fruData->end())
635 {
Vernon Mauery8166c8d2019-05-23 11:22:30 -0700636 name = std::get<std::string>(findBoardName->second);
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700637 }
638 else
639 {
640 name = "UNKNOWN";
641 }
642 if (name.size() > maxFruSdrNameSize)
643 {
644 name = name.substr(0, maxFruSdrNameSize);
645 }
646 size_t sizeDiff = maxFruSdrNameSize - name.size();
647
648 resp.header.record_id_lsb = 0x0; // calling code is to implement these
649 resp.header.record_id_msb = 0x0;
650 resp.header.sdr_version = ipmiSdrVersion;
Patrick Venture73d01352019-10-11 18:32:59 -0700651 resp.header.record_type = get_sdr::SENSOR_DATA_FRU_RECORD;
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700652 resp.header.record_length = sizeof(resp.body) + sizeof(resp.key) - sizeDiff;
653 resp.key.deviceAddress = 0x20;
654 resp.key.fruID = device->first;
655 resp.key.accessLun = 0x80; // logical / physical fru device
656 resp.key.channelNumber = 0x0;
657 resp.body.reserved = 0x0;
658 resp.body.deviceType = 0x10;
James Feist4f86d1f2019-04-03 10:30:26 -0700659 resp.body.deviceTypeModifier = 0x0;
Patrick Venture9ce789f2019-10-17 09:09:39 -0700660
661 uint8_t entityID = 0;
662 uint8_t entityInstance = 0x1;
663
James Feist25690252019-12-23 12:25:49 -0800664#ifdef USING_ENTITY_MANAGER_DECORATORS
Patrick Venture9ce789f2019-10-17 09:09:39 -0700665 if (entityData)
666 {
667 auto entityIdProperty = entityData->find("EntityId");
668 auto entityInstanceProperty = entityData->find("EntityInstance");
669
670 if (entityIdProperty != entityData->end())
671 {
672 entityID = static_cast<uint8_t>(
673 std::get<uint64_t>(entityIdProperty->second));
674 }
675 if (entityInstanceProperty != entityData->end())
676 {
677 entityInstance = static_cast<uint8_t>(
678 std::get<uint64_t>(entityInstanceProperty->second));
679 }
680 }
James Feist25690252019-12-23 12:25:49 -0800681#endif
Patrick Venture9ce789f2019-10-17 09:09:39 -0700682
683 resp.body.entityID = entityID;
684 resp.body.entityInstance = entityInstance;
685
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700686 resp.body.oem = 0x0;
687 resp.body.deviceIDLen = name.size();
688 name.copy(resp.body.deviceID, name.size());
689
Vernon Mauerydcff1502022-09-28 11:12:46 -0700690 return ipmi::ccSuccess;
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700691}
Jason M. Billse2d1aee2018-10-03 15:57:18 -0700692
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700693static bool getSELLogFiles(std::vector<std::filesystem::path>& selLogFiles)
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800694{
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700695 // Loop through the directory looking for ipmi_sel log files
696 for (const std::filesystem::directory_entry& dirEnt :
697 std::filesystem::directory_iterator(intel_oem::ipmi::sel::selLogDir))
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800698 {
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700699 std::string filename = dirEnt.path().filename();
700 if (boost::starts_with(filename, intel_oem::ipmi::sel::selLogFilename))
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800701 {
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700702 // If we find an ipmi_sel log file, save the path
Patrick Williams1bcced02024-08-16 15:20:24 -0400703 selLogFiles.emplace_back(
704 intel_oem::ipmi::sel::selLogDir / filename);
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800705 }
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800706 }
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700707 // As the log files rotate, they are appended with a ".#" that is higher for
708 // the older logs. Since we don't expect more than 10 log files, we
709 // can just sort the list to get them in order from newest to oldest
710 std::sort(selLogFiles.begin(), selLogFiles.end());
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800711
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700712 return !selLogFiles.empty();
713}
714
715static int countSELEntries()
716{
717 // Get the list of ipmi_sel log files
718 std::vector<std::filesystem::path> selLogFiles;
719 if (!getSELLogFiles(selLogFiles))
720 {
721 return 0;
722 }
723 int numSELEntries = 0;
724 // Loop through each log file and count the number of logs
725 for (const std::filesystem::path& file : selLogFiles)
726 {
727 std::ifstream logStream(file);
728 if (!logStream.is_open())
729 {
730 continue;
731 }
732
733 std::string line;
734 while (std::getline(logStream, line))
735 {
736 numSELEntries++;
737 }
738 }
739 return numSELEntries;
740}
741
742static bool findSELEntry(const int recordID,
Patrick Ventureff7e15b2019-09-25 16:48:26 -0700743 const std::vector<std::filesystem::path>& selLogFiles,
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700744 std::string& entry)
745{
746 // Record ID is the first entry field following the timestamp. It is
747 // preceded by a space and followed by a comma
748 std::string search = " " + std::to_string(recordID) + ",";
749
750 // Loop through the ipmi_sel log entries
751 for (const std::filesystem::path& file : selLogFiles)
752 {
753 std::ifstream logStream(file);
754 if (!logStream.is_open())
755 {
756 continue;
757 }
758
759 while (std::getline(logStream, entry))
760 {
761 // Check if the record ID matches
762 if (entry.find(search) != std::string::npos)
763 {
764 return true;
765 }
766 }
767 }
768 return false;
769}
770
771static uint16_t
772 getNextRecordID(const uint16_t recordID,
Patrick Ventureff7e15b2019-09-25 16:48:26 -0700773 const std::vector<std::filesystem::path>& selLogFiles)
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700774{
775 uint16_t nextRecordID = recordID + 1;
776 std::string entry;
777 if (findSELEntry(nextRecordID, selLogFiles, entry))
778 {
779 return nextRecordID;
780 }
781 else
782 {
783 return ipmi::sel::lastEntry;
784 }
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800785}
786
Patrick Ventureff7e15b2019-09-25 16:48:26 -0700787static int fromHexStr(const std::string& hexStr, std::vector<uint8_t>& data)
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800788{
789 for (unsigned int i = 0; i < hexStr.size(); i += 2)
790 {
791 try
792 {
793 data.push_back(static_cast<uint8_t>(
794 std::stoul(hexStr.substr(i, 2), nullptr, 16)));
795 }
Patrick Williamsbd51e6a2021-10-06 13:09:44 -0500796 catch (const std::invalid_argument& e)
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800797 {
798 phosphor::logging::log<phosphor::logging::level::ERR>(e.what());
799 return -1;
800 }
Patrick Williamsbd51e6a2021-10-06 13:09:44 -0500801 catch (const std::out_of_range& e)
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800802 {
803 phosphor::logging::log<phosphor::logging::level::ERR>(e.what());
804 return -1;
805 }
806 }
807 return 0;
808}
809
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700810ipmi::RspType<uint8_t, // SEL version
811 uint16_t, // SEL entry count
812 uint16_t, // free space
813 uint32_t, // last add timestamp
814 uint32_t, // last erase timestamp
815 uint8_t> // operation support
816 ipmiStorageGetSELInfo()
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800817{
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700818 constexpr uint8_t selVersion = ipmi::sel::selVersion;
819 uint16_t entries = countSELEntries();
820 uint32_t addTimeStamp = intel_oem::ipmi::sel::getFileTimestamp(
821 intel_oem::ipmi::sel::selLogDir / intel_oem::ipmi::sel::selLogFilename);
822 uint32_t eraseTimeStamp = intel_oem::ipmi::sel::erase_time::get();
823 constexpr uint8_t operationSupport =
824 intel_oem::ipmi::sel::selOperationSupport;
825 constexpr uint16_t freeSpace =
826 0xffff; // Spec indicates that more than 64kB is free
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800827
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700828 return ipmi::responseSuccess(selVersion, entries, freeSpace, addTimeStamp,
829 eraseTimeStamp, operationSupport);
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800830}
831
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700832using systemEventType = std::tuple<
833 uint32_t, // Timestamp
834 uint16_t, // Generator ID
835 uint8_t, // EvM Rev
836 uint8_t, // Sensor Type
837 uint8_t, // Sensor Number
838 uint7_t, // Event Type
839 bool, // Event Direction
840 std::array<uint8_t, intel_oem::ipmi::sel::systemEventSize>>; // Event Data
841using oemTsEventType = std::tuple<
Patrick Williamsb37abfb2023-05-10 07:50:33 -0500842 uint32_t, // Timestamp
843 std::array<uint8_t, intel_oem::ipmi::sel::oemTsEventSize>>; // Event Data
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700844using oemEventType =
Patrick Williamsb37abfb2023-05-10 07:50:33 -0500845 std::array<uint8_t, intel_oem::ipmi::sel::oemEventSize>; // Event Data
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800846
Patrick Williamsb37abfb2023-05-10 07:50:33 -0500847ipmi::RspType<uint16_t, // Next Record ID
848 uint16_t, // Record ID
849 uint8_t, // Record Type
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700850 std::variant<systemEventType, oemTsEventType,
851 oemEventType>> // Record Content
852 ipmiStorageGetSELEntry(uint16_t reservationID, uint16_t targetID,
853 uint8_t offset, uint8_t size)
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800854{
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700855 // Only support getting the entire SEL record. If a partial size or non-zero
856 // offset is requested, return an error
857 if (offset != 0 || size != ipmi::sel::entireRecord)
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800858 {
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700859 return ipmi::responseRetBytesUnavailable();
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800860 }
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800861
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700862 // Check the reservation ID if one is provided or required (only if the
863 // offset is non-zero)
864 if (reservationID != 0 || offset != 0)
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800865 {
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700866 if (!checkSELReservation(reservationID))
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800867 {
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700868 return ipmi::responseInvalidReservationId();
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800869 }
870 }
871
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700872 // Get the ipmi_sel log files
873 std::vector<std::filesystem::path> selLogFiles;
874 if (!getSELLogFiles(selLogFiles))
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800875 {
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700876 return ipmi::responseSensorInvalid();
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800877 }
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800878
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700879 std::string targetEntry;
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800880
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800881 if (targetID == ipmi::sel::firstEntry)
882 {
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700883 // The first entry will be at the top of the oldest log file
884 std::ifstream logStream(selLogFiles.back());
885 if (!logStream.is_open())
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800886 {
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700887 return ipmi::responseUnspecifiedError();
888 }
889
890 if (!std::getline(logStream, targetEntry))
891 {
892 return ipmi::responseUnspecifiedError();
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800893 }
894 }
895 else if (targetID == ipmi::sel::lastEntry)
896 {
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700897 // The last entry will be at the bottom of the newest log file
898 std::ifstream logStream(selLogFiles.front());
899 if (!logStream.is_open())
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800900 {
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700901 return ipmi::responseUnspecifiedError();
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800902 }
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700903
904 std::string line;
905 while (std::getline(logStream, line))
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800906 {
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700907 targetEntry = line;
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800908 }
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800909 }
910 else
911 {
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700912 if (!findSELEntry(targetID, selLogFiles, targetEntry))
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800913 {
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700914 return ipmi::responseSensorInvalid();
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800915 }
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800916 }
917
Jason M. Bills52aaa7d2019-05-08 15:21:39 -0700918 // The format of the ipmi_sel message is "<Timestamp>
919 // <ID>,<Type>,<EventData>,[<Generator ID>,<Path>,<Direction>]".
920 // First get the Timestamp
921 size_t space = targetEntry.find_first_of(" ");
922 if (space == std::string::npos)
923 {
924 return ipmi::responseUnspecifiedError();
925 }
926 std::string entryTimestamp = targetEntry.substr(0, space);
927 // Then get the log contents
928 size_t entryStart = targetEntry.find_first_not_of(" ", space);
929 if (entryStart == std::string::npos)
930 {
931 return ipmi::responseUnspecifiedError();
932 }
933 std::string_view entry(targetEntry);
934 entry.remove_prefix(entryStart);
935 // Use split to separate the entry into its fields
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700936 std::vector<std::string> targetEntryFields;
Jason M. Bills52aaa7d2019-05-08 15:21:39 -0700937 boost::split(targetEntryFields, entry, boost::is_any_of(","),
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700938 boost::token_compress_on);
Jason M. Bills52aaa7d2019-05-08 15:21:39 -0700939 if (targetEntryFields.size() < 3)
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700940 {
941 return ipmi::responseUnspecifiedError();
942 }
Jason M. Bills1a2fbdd2019-05-10 09:05:37 -0700943 std::string& recordIDStr = targetEntryFields[0];
944 std::string& recordTypeStr = targetEntryFields[1];
945 std::string& eventDataStr = targetEntryFields[2];
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700946
Jason M. Bills1a2fbdd2019-05-10 09:05:37 -0700947 uint16_t recordID;
948 uint8_t recordType;
949 try
950 {
951 recordID = std::stoul(recordIDStr);
952 recordType = std::stoul(recordTypeStr, nullptr, 16);
953 }
954 catch (const std::invalid_argument&)
955 {
956 return ipmi::responseUnspecifiedError();
957 }
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700958 uint16_t nextRecordID = getNextRecordID(recordID, selLogFiles);
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700959 std::vector<uint8_t> eventDataBytes;
Jason M. Bills1a2fbdd2019-05-10 09:05:37 -0700960 if (fromHexStr(eventDataStr, eventDataBytes) < 0)
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700961 {
962 return ipmi::responseUnspecifiedError();
963 }
964
965 if (recordType == intel_oem::ipmi::sel::systemEvent)
966 {
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700967 // Get the timestamp
968 std::tm timeStruct = {};
Jason M. Bills52aaa7d2019-05-08 15:21:39 -0700969 std::istringstream entryStream(entryTimestamp);
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700970
971 uint32_t timestamp = ipmi::sel::invalidTimeStamp;
972 if (entryStream >> std::get_time(&timeStruct, "%Y-%m-%dT%H:%M:%S"))
973 {
974 timestamp = std::mktime(&timeStruct);
975 }
976
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700977 // Set the event message revision
978 uint8_t evmRev = intel_oem::ipmi::sel::eventMsgRev;
979
Jason M. Bills1a2fbdd2019-05-10 09:05:37 -0700980 uint16_t generatorID = 0;
981 uint8_t sensorType = 0;
Johnathan Mantey308c3a82020-07-22 11:50:54 -0700982 uint16_t sensorAndLun = 0;
Jason M. Bills1a2fbdd2019-05-10 09:05:37 -0700983 uint8_t sensorNum = 0xFF;
984 uint7_t eventType = 0;
985 bool eventDir = 0;
986 // System type events should have six fields
987 if (targetEntryFields.size() >= 6)
988 {
989 std::string& generatorIDStr = targetEntryFields[3];
990 std::string& sensorPath = targetEntryFields[4];
991 std::string& eventDirStr = targetEntryFields[5];
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700992
Jason M. Bills1a2fbdd2019-05-10 09:05:37 -0700993 // Get the generator ID
994 try
995 {
996 generatorID = std::stoul(generatorIDStr, nullptr, 16);
997 }
998 catch (const std::invalid_argument&)
999 {
1000 std::cerr << "Invalid Generator ID\n";
1001 }
1002
1003 // Get the sensor type, sensor number, and event type for the sensor
1004 sensorType = getSensorTypeFromPath(sensorPath);
Johnathan Mantey308c3a82020-07-22 11:50:54 -07001005 sensorAndLun = getSensorNumberFromPath(sensorPath);
1006 sensorNum = static_cast<uint8_t>(sensorAndLun);
1007 generatorID |= sensorAndLun >> 8;
Jason M. Bills1a2fbdd2019-05-10 09:05:37 -07001008 eventType = getSensorEventTypeFromPath(sensorPath);
1009
1010 // Get the event direction
1011 try
1012 {
1013 eventDir = std::stoul(eventDirStr) ? 0 : 1;
1014 }
1015 catch (const std::invalid_argument&)
1016 {
1017 std::cerr << "Invalid Event Direction\n";
1018 }
1019 }
Jason M. Bills1d4d54d2019-04-23 11:26:11 -07001020
1021 // Only keep the eventData bytes that fit in the record
1022 std::array<uint8_t, intel_oem::ipmi::sel::systemEventSize> eventData{};
1023 std::copy_n(eventDataBytes.begin(),
1024 std::min(eventDataBytes.size(), eventData.size()),
1025 eventData.begin());
1026
1027 return ipmi::responseSuccess(
1028 nextRecordID, recordID, recordType,
1029 systemEventType{timestamp, generatorID, evmRev, sensorType,
1030 sensorNum, eventType, eventDir, eventData});
1031 }
1032 else if (recordType >= intel_oem::ipmi::sel::oemTsEventFirst &&
1033 recordType <= intel_oem::ipmi::sel::oemTsEventLast)
1034 {
1035 // Get the timestamp
1036 std::tm timeStruct = {};
Jason M. Bills52aaa7d2019-05-08 15:21:39 -07001037 std::istringstream entryStream(entryTimestamp);
Jason M. Bills1d4d54d2019-04-23 11:26:11 -07001038
1039 uint32_t timestamp = ipmi::sel::invalidTimeStamp;
1040 if (entryStream >> std::get_time(&timeStruct, "%Y-%m-%dT%H:%M:%S"))
1041 {
1042 timestamp = std::mktime(&timeStruct);
1043 }
1044
1045 // Only keep the bytes that fit in the record
1046 std::array<uint8_t, intel_oem::ipmi::sel::oemTsEventSize> eventData{};
1047 std::copy_n(eventDataBytes.begin(),
1048 std::min(eventDataBytes.size(), eventData.size()),
1049 eventData.begin());
1050
1051 return ipmi::responseSuccess(nextRecordID, recordID, recordType,
1052 oemTsEventType{timestamp, eventData});
1053 }
Patrick Venturec5136aa2019-10-04 20:39:31 -07001054 else if (recordType >= intel_oem::ipmi::sel::oemEventFirst)
Jason M. Bills1d4d54d2019-04-23 11:26:11 -07001055 {
1056 // Only keep the bytes that fit in the record
1057 std::array<uint8_t, intel_oem::ipmi::sel::oemEventSize> eventData{};
1058 std::copy_n(eventDataBytes.begin(),
1059 std::min(eventDataBytes.size(), eventData.size()),
1060 eventData.begin());
1061
1062 return ipmi::responseSuccess(nextRecordID, recordID, recordType,
1063 eventData);
1064 }
1065
1066 return ipmi::responseUnspecifiedError();
Jason M. Billsc04e2e72018-11-28 15:15:56 -08001067}
1068
Jason M. Bills6dd8f042019-04-11 10:39:02 -07001069ipmi::RspType<uint16_t> ipmiStorageAddSELEntry(
1070 uint16_t recordID, uint8_t recordType, uint32_t timestamp,
1071 uint16_t generatorID, uint8_t evmRev, uint8_t sensorType, uint8_t sensorNum,
1072 uint8_t eventType, uint8_t eventData1, uint8_t eventData2,
1073 uint8_t eventData3)
Jason M. Billsc04e2e72018-11-28 15:15:56 -08001074{
Jason M. Billsc04e2e72018-11-28 15:15:56 -08001075 // Per the IPMI spec, need to cancel any reservation when a SEL entry is
1076 // added
1077 cancelSELReservation();
1078
Jason M. Bills6dd8f042019-04-11 10:39:02 -07001079 // Send this request to the Redfish hooks to log it as a Redfish message
1080 // instead. There is no need to add it to the SEL, so just return success.
1081 intel_oem::ipmi::sel::checkRedfishHooks(
1082 recordID, recordType, timestamp, generatorID, evmRev, sensorType,
1083 sensorNum, eventType, eventData1, eventData2, eventData3);
Jason M. Bills99b78ec2019-01-18 10:42:18 -08001084
Jason M. Bills6dd8f042019-04-11 10:39:02 -07001085 uint16_t responseID = 0xFFFF;
1086 return ipmi::responseSuccess(responseID);
Jason M. Billsc04e2e72018-11-28 15:15:56 -08001087}
1088
Patrick Williams1bcced02024-08-16 15:20:24 -04001089ipmi::RspType<uint8_t> ipmiStorageClearSEL(
1090 ipmi::Context::ptr&, uint16_t reservationID,
1091 const std::array<uint8_t, 3>& clr, uint8_t eraseOperation)
Jason M. Billsc04e2e72018-11-28 15:15:56 -08001092{
Jason M. Bills1d4d54d2019-04-23 11:26:11 -07001093 if (!checkSELReservation(reservationID))
Jason M. Billsc04e2e72018-11-28 15:15:56 -08001094 {
Jason M. Bills1d4d54d2019-04-23 11:26:11 -07001095 return ipmi::responseInvalidReservationId();
Jason M. Billsc04e2e72018-11-28 15:15:56 -08001096 }
1097
Jason M. Bills1d4d54d2019-04-23 11:26:11 -07001098 static constexpr std::array<uint8_t, 3> clrExpected = {'C', 'L', 'R'};
1099 if (clr != clrExpected)
Jason M. Billsc04e2e72018-11-28 15:15:56 -08001100 {
Jason M. Bills1d4d54d2019-04-23 11:26:11 -07001101 return ipmi::responseInvalidFieldRequest();
Jason M. Billsc04e2e72018-11-28 15:15:56 -08001102 }
1103
Jason M. Bills1d4d54d2019-04-23 11:26:11 -07001104 // Erasure status cannot be fetched, so always return erasure status as
1105 // `erase completed`.
1106 if (eraseOperation == ipmi::sel::getEraseStatus)
Jason M. Billsc04e2e72018-11-28 15:15:56 -08001107 {
Jason M. Bills1d4d54d2019-04-23 11:26:11 -07001108 return ipmi::responseSuccess(ipmi::sel::eraseComplete);
Jason M. Billsc04e2e72018-11-28 15:15:56 -08001109 }
1110
Jason M. Bills1d4d54d2019-04-23 11:26:11 -07001111 // Check that initiate erase is correct
1112 if (eraseOperation != ipmi::sel::initiateErase)
1113 {
1114 return ipmi::responseInvalidFieldRequest();
1115 }
1116
1117 // Per the IPMI spec, need to cancel any reservation when the SEL is
1118 // cleared
Jason M. Billsc04e2e72018-11-28 15:15:56 -08001119 cancelSELReservation();
1120
Jason M. Bills7944c302019-03-20 15:24:05 -07001121 // Save the erase time
1122 intel_oem::ipmi::sel::erase_time::save();
1123
Jason M. Bills1d4d54d2019-04-23 11:26:11 -07001124 // Clear the SEL by deleting the log files
1125 std::vector<std::filesystem::path> selLogFiles;
1126 if (getSELLogFiles(selLogFiles))
Jason M. Billsc04e2e72018-11-28 15:15:56 -08001127 {
Jason M. Bills1d4d54d2019-04-23 11:26:11 -07001128 for (const std::filesystem::path& file : selLogFiles)
1129 {
1130 std::error_code ec;
1131 std::filesystem::remove(file, ec);
1132 }
Jason M. Billsc04e2e72018-11-28 15:15:56 -08001133 }
1134
Jason M. Bills1d4d54d2019-04-23 11:26:11 -07001135 // Reload rsyslog so it knows to start new log files
Vernon Mauery15419dd2019-05-24 09:40:30 -07001136 std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus();
Patrick Williamsf944d2e2022-07-22 19:26:52 -05001137 sdbusplus::message_t rsyslogReload = dbus->new_method_call(
Jason M. Bills1d4d54d2019-04-23 11:26:11 -07001138 "org.freedesktop.systemd1", "/org/freedesktop/systemd1",
1139 "org.freedesktop.systemd1.Manager", "ReloadUnit");
1140 rsyslogReload.append("rsyslog.service", "replace");
1141 try
1142 {
Patrick Williamsf944d2e2022-07-22 19:26:52 -05001143 sdbusplus::message_t reloadResponse = dbus->call(rsyslogReload);
Jason M. Bills1d4d54d2019-04-23 11:26:11 -07001144 }
Patrick Williamsbd51e6a2021-10-06 13:09:44 -05001145 catch (const sdbusplus::exception_t& e)
Jason M. Bills1d4d54d2019-04-23 11:26:11 -07001146 {
1147 phosphor::logging::log<phosphor::logging::level::ERR>(e.what());
1148 }
1149
1150 return ipmi::responseSuccess(ipmi::sel::eraseComplete);
Jason M. Billsc04e2e72018-11-28 15:15:56 -08001151}
1152
Jason M. Bills1a474622019-06-14 14:51:33 -07001153ipmi::RspType<uint32_t> ipmiStorageGetSELTime()
1154{
1155 struct timespec selTime = {};
1156
1157 if (clock_gettime(CLOCK_REALTIME, &selTime) < 0)
1158 {
1159 return ipmi::responseUnspecifiedError();
1160 }
1161
1162 return ipmi::responseSuccess(selTime.tv_sec);
1163}
1164
Vernon Mauerydcff1502022-09-28 11:12:46 -07001165ipmi::RspType<> ipmiStorageSetSELTime([[maybe_unused]] uint32_t selTime)
Jason M. Billscac97a52019-01-30 14:43:46 -08001166{
1167 // Set SEL Time is not supported
Jason M. Bills1d4d54d2019-04-23 11:26:11 -07001168 return ipmi::responseInvalidCommand();
Jason M. Billscac97a52019-01-30 14:43:46 -08001169}
1170
James Feist74c50c62019-08-14 14:18:41 -07001171std::vector<uint8_t> getType12SDRs(uint16_t index, uint16_t recordId)
1172{
1173 std::vector<uint8_t> resp;
1174 if (index == 0)
1175 {
James Feist74c50c62019-08-14 14:18:41 -07001176 std::string bmcName = "Basbrd Mgmt Ctlr";
Johnathan Manteyf4d5e052021-09-22 12:58:08 -07001177 Type12Record bmc(recordId, 0x20, 0, 0, 0xbf, 0x2e, 1, 0, bmcName);
James Feist74c50c62019-08-14 14:18:41 -07001178 uint8_t* bmcPtr = reinterpret_cast<uint8_t*>(&bmc);
1179 resp.insert(resp.end(), bmcPtr, bmcPtr + sizeof(Type12Record));
1180 }
1181 else if (index == 1)
1182 {
James Feist74c50c62019-08-14 14:18:41 -07001183 std::string meName = "Mgmt Engine";
Johnathan Manteyf4d5e052021-09-22 12:58:08 -07001184 Type12Record me(recordId, 0x2c, 6, 0x24, 0x21, 0x2e, 2, 0, meName);
James Feist74c50c62019-08-14 14:18:41 -07001185 uint8_t* mePtr = reinterpret_cast<uint8_t*>(&me);
1186 resp.insert(resp.end(), mePtr, mePtr + sizeof(Type12Record));
1187 }
1188 else
1189 {
Patrick Williams1bcced02024-08-16 15:20:24 -04001190 throw std::runtime_error(
1191 "getType12SDRs:: Illegal index " + std::to_string(index));
James Feist74c50c62019-08-14 14:18:41 -07001192 }
1193
1194 return resp;
1195}
1196
Yong Lifee5e4c2020-01-17 19:36:29 +08001197std::vector<uint8_t> getNMDiscoverySDR(uint16_t index, uint16_t recordId)
1198{
1199 std::vector<uint8_t> resp;
1200 if (index == 0)
1201 {
1202 NMDiscoveryRecord nm = {};
1203 nm.header.record_id_lsb = recordId;
1204 nm.header.record_id_msb = recordId >> 8;
1205 nm.header.sdr_version = ipmiSdrVersion;
1206 nm.header.record_type = 0xC0;
1207 nm.header.record_length = 0xB;
1208 nm.oemID0 = 0x57;
1209 nm.oemID1 = 0x1;
1210 nm.oemID2 = 0x0;
1211 nm.subType = 0x0D;
1212 nm.version = 0x1;
Matt Simmering80d4d5f2023-02-15 15:18:51 -08001213 nm.targetAddress = 0x2C;
Yong Lifee5e4c2020-01-17 19:36:29 +08001214 nm.channelNumber = 0x60;
1215 nm.healthEventSensor = 0x19;
1216 nm.exceptionEventSensor = 0x18;
1217 nm.operationalCapSensor = 0x1A;
1218 nm.thresholdExceededSensor = 0x1B;
1219
1220 uint8_t* nmPtr = reinterpret_cast<uint8_t*>(&nm);
1221 resp.insert(resp.end(), nmPtr, nmPtr + sizeof(NMDiscoveryRecord));
1222 }
1223 else
1224 {
Patrick Williams1bcced02024-08-16 15:20:24 -04001225 throw std::runtime_error(
1226 "getNMDiscoverySDR:: Illegal index " + std::to_string(index));
Yong Lifee5e4c2020-01-17 19:36:29 +08001227 }
1228
1229 return resp;
1230}
1231
Jason M. Billse2d1aee2018-10-03 15:57:18 -07001232void registerStorageFunctions()
1233{
James Feist25690252019-12-23 12:25:49 -08001234 createTimers();
James Feiste4f710d2020-05-20 15:50:30 -07001235 startMatch();
1236
Jason M. Billse2d1aee2018-10-03 15:57:18 -07001237 // <Get FRU Inventory Area Info>
jayaprakash Mutyalad33acd62019-05-17 19:37:25 +00001238 ipmi::registerHandler(ipmi::prioOemBase, ipmi::netFnStorage,
1239 ipmi::storage::cmdGetFruInventoryAreaInfo,
1240 ipmi::Privilege::User, ipmiStorageGetFruInvAreaInfo);
Jason M. Billsc04e2e72018-11-28 15:15:56 -08001241 // <READ FRU Data>
jayaprakash Mutyala5f4194e2019-05-20 16:17:01 +00001242 ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnStorage,
1243 ipmi::storage::cmdReadFruData, ipmi::Privilege::User,
1244 ipmiStorageReadFruData);
Jason M. Billse2d1aee2018-10-03 15:57:18 -07001245
Jason M. Billsc04e2e72018-11-28 15:15:56 -08001246 // <WRITE FRU Data>
jayaprakash Mutyala5f4194e2019-05-20 16:17:01 +00001247 ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnStorage,
1248 ipmi::storage::cmdWriteFruData,
1249 ipmi::Privilege::Operator, ipmiStorageWriteFruData);
Jason M. Billsc04e2e72018-11-28 15:15:56 -08001250
1251 // <Get SEL Info>
Jason M. Bills1d4d54d2019-04-23 11:26:11 -07001252 ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnStorage,
Jason M. Bills542498e2019-06-24 16:57:42 -07001253 ipmi::storage::cmdGetSelInfo, ipmi::Privilege::User,
1254 ipmiStorageGetSELInfo);
Jason M. Billsc04e2e72018-11-28 15:15:56 -08001255
1256 // <Get SEL Entry>
Jason M. Bills1d4d54d2019-04-23 11:26:11 -07001257 ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnStorage,
Jason M. Bills542498e2019-06-24 16:57:42 -07001258 ipmi::storage::cmdGetSelEntry, ipmi::Privilege::User,
1259 ipmiStorageGetSELEntry);
Jason M. Billsc04e2e72018-11-28 15:15:56 -08001260
1261 // <Add SEL Entry>
Jason M. Bills6dd8f042019-04-11 10:39:02 -07001262 ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnStorage,
Vernon Mauery98bbf692019-09-16 11:14:59 -07001263 ipmi::storage::cmdAddSelEntry,
Jason M. Bills6dd8f042019-04-11 10:39:02 -07001264 ipmi::Privilege::Operator, ipmiStorageAddSELEntry);
Jason M. Billsc04e2e72018-11-28 15:15:56 -08001265
1266 // <Clear SEL>
Jason M. Bills1d4d54d2019-04-23 11:26:11 -07001267 ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnStorage,
1268 ipmi::storage::cmdClearSel, ipmi::Privilege::Operator,
1269 ipmiStorageClearSEL);
Jason M. Billscac97a52019-01-30 14:43:46 -08001270
Jason M. Bills1a474622019-06-14 14:51:33 -07001271 // <Get SEL Time>
1272 ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnStorage,
Jason M. Bills542498e2019-06-24 16:57:42 -07001273 ipmi::storage::cmdGetSelTime, ipmi::Privilege::User,
1274 ipmiStorageGetSELTime);
Jason M. Bills1a474622019-06-14 14:51:33 -07001275
Jason M. Billscac97a52019-01-30 14:43:46 -08001276 // <Set SEL Time>
Jason M. Bills1d4d54d2019-04-23 11:26:11 -07001277 ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnStorage,
1278 ipmi::storage::cmdSetSelTime,
1279 ipmi::Privilege::Operator, ipmiStorageSetSELTime);
Jason M. Billse2d1aee2018-10-03 15:57:18 -07001280}
Jason M. Bills3f7c5e42018-10-03 14:00:41 -07001281} // namespace storage
Jason M. Billsc04e2e72018-11-28 15:15:56 -08001282} // namespace ipmi