blob: 5d478f2b52d1a5bb8dd1935242c01199516dda2e [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
Jason M. Bills1d4d54d2019-04-23 11:26:11 -070017#include <boost/algorithm/string.hpp>
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070018#include <boost/container/flat_map.hpp>
Jason M. Billsc04e2e72018-11-28 15:15:56 -080019#include <boost/process.hpp>
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070020#include <commandutils.hpp>
Jason M. Bills1d4d54d2019-04-23 11:26:11 -070021#include <filesystem>
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070022#include <iostream>
Jason M. Bills99b78ec2019-01-18 10:42:18 -080023#include <ipmi_to_redfish_hooks.hpp>
James Feist2a265d52019-04-08 11:16:27 -070024#include <ipmid/api.hpp>
Jason M. Billsc04e2e72018-11-28 15:15:56 -080025#include <phosphor-ipmi-host/selutility.hpp>
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070026#include <phosphor-logging/log.hpp>
27#include <sdbusplus/message/types.hpp>
28#include <sdbusplus/timer.hpp>
Jason M. Billsc04e2e72018-11-28 15:15:56 -080029#include <sdrutils.hpp>
30#include <stdexcept>
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070031#include <storagecommands.hpp>
Jason M. Bills52aaa7d2019-05-08 15:21:39 -070032#include <string_view>
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070033
Jason M. Bills1d4d54d2019-04-23 11:26:11 -070034namespace intel_oem::ipmi::sel
35{
36static const std::filesystem::path selLogDir = "/var/log";
37static const std::string selLogFilename = "ipmi_sel";
38
39static int getFileTimestamp(const std::filesystem::path& file)
40{
41 struct stat st;
42
43 if (stat(file.c_str(), &st) >= 0)
44 {
45 return st.st_mtime;
46 }
47 return ::ipmi::sel::invalidTimeStamp;
48}
49
50namespace erase_time
Jason M. Bills7944c302019-03-20 15:24:05 -070051{
52static constexpr const char* selEraseTimestamp = "/var/lib/ipmi/sel_erase_time";
53
54void save()
55{
56 // open the file, creating it if necessary
57 int fd = open(selEraseTimestamp, O_WRONLY | O_CREAT | O_CLOEXEC, 0644);
58 if (fd < 0)
59 {
60 std::cerr << "Failed to open file\n";
61 return;
62 }
63
64 // update the file timestamp to the current time
65 if (futimens(fd, NULL) < 0)
66 {
67 std::cerr << "Failed to update timestamp: "
68 << std::string(strerror(errno));
69 }
70 close(fd);
71}
72
73int get()
74{
Jason M. Bills1d4d54d2019-04-23 11:26:11 -070075 return getFileTimestamp(selEraseTimestamp);
Jason M. Bills7944c302019-03-20 15:24:05 -070076}
Jason M. Bills1d4d54d2019-04-23 11:26:11 -070077} // namespace erase_time
78} // namespace intel_oem::ipmi::sel
Jason M. Bills7944c302019-03-20 15:24:05 -070079
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070080namespace ipmi
81{
82
83namespace storage
84{
85
Jason M. Billse2d1aee2018-10-03 15:57:18 -070086constexpr static const size_t maxMessageSize = 64;
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070087constexpr static const size_t maxFruSdrNameSize = 16;
88using ManagedObjectType = boost::container::flat_map<
89 sdbusplus::message::object_path,
90 boost::container::flat_map<
91 std::string, boost::container::flat_map<std::string, DbusVariant>>>;
92using ManagedEntry = std::pair<
93 sdbusplus::message::object_path,
94 boost::container::flat_map<
95 std::string, boost::container::flat_map<std::string, DbusVariant>>>;
96
James Feist3bcba452018-12-20 12:31:03 -080097constexpr static const char* fruDeviceServiceName =
98 "xyz.openbmc_project.FruDevice";
Jason M. Billse2d1aee2018-10-03 15:57:18 -070099constexpr static const size_t cacheTimeoutSeconds = 10;
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700100
Jason M. Bills4ed6f2c2019-04-02 12:21:25 -0700101// event direction is bit[7] of eventType where 1b = Deassertion event
102constexpr static const uint8_t deassertionEvent = 0x80;
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800103
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700104static std::vector<uint8_t> fruCache;
105static uint8_t cacheBus = 0xFF;
106static uint8_t cacheAddr = 0XFF;
107
108std::unique_ptr<phosphor::Timer> cacheTimer = nullptr;
109
110// we unfortunately have to build a map of hashes in case there is a
111// collision to verify our dev-id
112boost::container::flat_map<uint8_t, std::pair<uint8_t, uint8_t>> deviceHashes;
113
Jason M. Billse2d1aee2018-10-03 15:57:18 -0700114void registerStorageFunctions() __attribute__((constructor));
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700115static sdbusplus::bus::bus dbus(ipmid_get_sd_bus_connection());
116
117bool writeFru()
118{
119 sdbusplus::message::message writeFru = dbus.new_method_call(
120 fruDeviceServiceName, "/xyz/openbmc_project/FruDevice",
121 "xyz.openbmc_project.FruDeviceManager", "WriteFru");
122 writeFru.append(cacheBus, cacheAddr, fruCache);
123 try
124 {
125 sdbusplus::message::message writeFruResp = dbus.call(writeFru);
126 }
127 catch (sdbusplus::exception_t&)
128 {
129 // todo: log sel?
130 phosphor::logging::log<phosphor::logging::level::ERR>(
131 "error writing fru");
132 return false;
133 }
134 return true;
135}
136
Jason M. Billse2d1aee2018-10-03 15:57:18 -0700137void createTimer()
138{
139 if (cacheTimer == nullptr)
140 {
141 cacheTimer = std::make_unique<phosphor::Timer>(writeFru);
142 }
143}
144
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700145ipmi_ret_t replaceCacheFru(uint8_t devId)
146{
147 static uint8_t lastDevId = 0xFF;
148
149 bool timerRunning = (cacheTimer != nullptr) && !cacheTimer->isExpired();
150 if (lastDevId == devId && timerRunning)
151 {
152 return IPMI_CC_OK; // cache already up to date
153 }
154 // if timer is running, stop it and writeFru manually
155 else if (timerRunning)
156 {
157 cacheTimer->stop();
158 writeFru();
159 }
160
161 sdbusplus::message::message getObjects = dbus.new_method_call(
162 fruDeviceServiceName, "/", "org.freedesktop.DBus.ObjectManager",
163 "GetManagedObjects");
164 ManagedObjectType frus;
165 try
166 {
167 sdbusplus::message::message resp = dbus.call(getObjects);
168 resp.read(frus);
169 }
170 catch (sdbusplus::exception_t&)
171 {
172 phosphor::logging::log<phosphor::logging::level::ERR>(
173 "replaceCacheFru: error getting managed objects");
174 return IPMI_CC_RESPONSE_ERROR;
175 }
176
177 deviceHashes.clear();
178
179 // hash the object paths to create unique device id's. increment on
180 // collision
181 std::hash<std::string> hasher;
182 for (const auto& fru : frus)
183 {
184 auto fruIface = fru.second.find("xyz.openbmc_project.FruDevice");
185 if (fruIface == fru.second.end())
186 {
187 continue;
188 }
189
190 auto busFind = fruIface->second.find("BUS");
191 auto addrFind = fruIface->second.find("ADDRESS");
192 if (busFind == fruIface->second.end() ||
193 addrFind == fruIface->second.end())
194 {
195 phosphor::logging::log<phosphor::logging::level::INFO>(
196 "fru device missing Bus or Address",
197 phosphor::logging::entry("FRU=%s", fru.first.str.c_str()));
198 continue;
199 }
200
Vernon Mauery8166c8d2019-05-23 11:22:30 -0700201 uint8_t fruBus = std::get<uint32_t>(busFind->second);
202 uint8_t fruAddr = std::get<uint32_t>(addrFind->second);
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700203
204 uint8_t fruHash = 0;
205 if (fruBus != 0 || fruAddr != 0)
206 {
207 fruHash = hasher(fru.first.str);
208 // can't be 0xFF based on spec, and 0 is reserved for baseboard
209 if (fruHash == 0 || fruHash == 0xFF)
210 {
211 fruHash = 1;
212 }
213 }
214 std::pair<uint8_t, uint8_t> newDev(fruBus, fruAddr);
215
216 bool emplacePassed = false;
217 while (!emplacePassed)
218 {
219 auto resp = deviceHashes.emplace(fruHash, newDev);
220 emplacePassed = resp.second;
221 if (!emplacePassed)
222 {
223 fruHash++;
224 // can't be 0xFF based on spec, and 0 is reserved for
225 // baseboard
226 if (fruHash == 0XFF)
227 {
228 fruHash = 0x1;
229 }
230 }
231 }
232 }
233 auto deviceFind = deviceHashes.find(devId);
234 if (deviceFind == deviceHashes.end())
235 {
236 return IPMI_CC_SENSOR_INVALID;
237 }
238
239 fruCache.clear();
240 sdbusplus::message::message getRawFru = dbus.new_method_call(
241 fruDeviceServiceName, "/xyz/openbmc_project/FruDevice",
242 "xyz.openbmc_project.FruDeviceManager", "GetRawFru");
243 cacheBus = deviceFind->second.first;
244 cacheAddr = deviceFind->second.second;
245 getRawFru.append(cacheBus, cacheAddr);
246 try
247 {
248 sdbusplus::message::message getRawResp = dbus.call(getRawFru);
249 getRawResp.read(fruCache);
250 }
251 catch (sdbusplus::exception_t&)
252 {
253 lastDevId = 0xFF;
254 cacheBus = 0xFF;
255 cacheAddr = 0xFF;
256 return IPMI_CC_RESPONSE_ERROR;
257 }
258
259 lastDevId = devId;
260 return IPMI_CC_OK;
261}
262
Jason M. Billse2d1aee2018-10-03 15:57:18 -0700263ipmi_ret_t ipmiStorageReadFRUData(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
264 ipmi_request_t request,
265 ipmi_response_t response,
266 ipmi_data_len_t dataLen,
267 ipmi_context_t context)
268{
269 if (*dataLen != 4)
270 {
271 *dataLen = 0;
272 return IPMI_CC_REQ_DATA_LEN_INVALID;
273 }
274 *dataLen = 0; // default to 0 in case of an error
275
276 auto req = static_cast<GetFRUAreaReq*>(request);
277
278 if (req->countToRead > maxMessageSize - 1)
279 {
280 return IPMI_CC_INVALID_FIELD_REQUEST;
281 }
282 ipmi_ret_t status = replaceCacheFru(req->fruDeviceID);
283
284 if (status != IPMI_CC_OK)
285 {
286 return status;
287 }
288
289 size_t fromFRUByteLen = 0;
290 if (req->countToRead + req->fruInventoryOffset < fruCache.size())
291 {
292 fromFRUByteLen = req->countToRead;
293 }
294 else if (fruCache.size() > req->fruInventoryOffset)
295 {
296 fromFRUByteLen = fruCache.size() - req->fruInventoryOffset;
297 }
298 size_t padByteLen = req->countToRead - fromFRUByteLen;
299 uint8_t* respPtr = static_cast<uint8_t*>(response);
300 *respPtr = req->countToRead;
301 std::copy(fruCache.begin() + req->fruInventoryOffset,
302 fruCache.begin() + req->fruInventoryOffset + fromFRUByteLen,
303 ++respPtr);
304 // if longer than the fru is requested, fill with 0xFF
305 if (padByteLen)
306 {
307 respPtr += fromFRUByteLen;
308 std::fill(respPtr, respPtr + padByteLen, 0xFF);
309 }
310 *dataLen = fromFRUByteLen + 1;
311
312 return IPMI_CC_OK;
313}
314
315ipmi_ret_t ipmiStorageWriteFRUData(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
316 ipmi_request_t request,
317 ipmi_response_t response,
318 ipmi_data_len_t dataLen,
319 ipmi_context_t context)
320{
321 if (*dataLen < 4 ||
322 *dataLen >=
323 0xFF + 3) // count written return is one byte, so limit to one byte
324 // of data after the three request data bytes
325 {
326 *dataLen = 0;
327 return IPMI_CC_REQ_DATA_LEN_INVALID;
328 }
329
330 auto req = static_cast<WriteFRUDataReq*>(request);
331 size_t writeLen = *dataLen - 3;
332 *dataLen = 0; // default to 0 in case of an error
333
334 ipmi_ret_t status = replaceCacheFru(req->fruDeviceID);
335 if (status != IPMI_CC_OK)
336 {
337 return status;
338 }
339 int lastWriteAddr = req->fruInventoryOffset + writeLen;
340 if (fruCache.size() < lastWriteAddr)
341 {
342 fruCache.resize(req->fruInventoryOffset + writeLen);
343 }
344
345 std::copy(req->data, req->data + writeLen,
346 fruCache.begin() + req->fruInventoryOffset);
347
348 bool atEnd = false;
349
350 if (fruCache.size() >= sizeof(FRUHeader))
351 {
352
353 FRUHeader* header = reinterpret_cast<FRUHeader*>(fruCache.data());
354
355 int lastRecordStart = std::max(
356 header->internalOffset,
357 std::max(header->chassisOffset,
358 std::max(header->boardOffset, header->productOffset)));
359 // TODO: Handle Multi-Record FRUs?
360
361 lastRecordStart *= 8; // header starts in are multiples of 8 bytes
362
363 // get the length of the area in multiples of 8 bytes
364 if (lastWriteAddr > (lastRecordStart + 1))
365 {
366 // second byte in record area is the length
367 int areaLength(fruCache[lastRecordStart + 1]);
368 areaLength *= 8; // it is in multiples of 8 bytes
369
370 if (lastWriteAddr >= (areaLength + lastRecordStart))
371 {
372 atEnd = true;
373 }
374 }
375 }
376 uint8_t* respPtr = static_cast<uint8_t*>(response);
377 if (atEnd)
378 {
379 // cancel timer, we're at the end so might as well send it
380 cacheTimer->stop();
381 if (!writeFru())
382 {
383 return IPMI_CC_INVALID_FIELD_REQUEST;
384 }
385 *respPtr = std::min(fruCache.size(), static_cast<size_t>(0xFF));
386 }
387 else
388 {
389 // start a timer, if no further data is sent in cacheTimeoutSeconds
390 // seconds, check to see if it is valid
391 createTimer();
392 cacheTimer->start(std::chrono::duration_cast<std::chrono::microseconds>(
393 std::chrono::seconds(cacheTimeoutSeconds)));
394 *respPtr = 0;
395 }
396
397 *dataLen = 1;
398
399 return IPMI_CC_OK;
400}
401
402ipmi_ret_t ipmiStorageGetFRUInvAreaInfo(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
403 ipmi_request_t request,
404 ipmi_response_t response,
405 ipmi_data_len_t dataLen,
406 ipmi_context_t context)
407{
408 if (*dataLen != 1)
409 {
410 *dataLen = 0;
411 return IPMI_CC_REQ_DATA_LEN_INVALID;
412 }
413 *dataLen = 0; // default to 0 in case of an error
414
415 uint8_t reqDev = *(static_cast<uint8_t*>(request));
416 if (reqDev == 0xFF)
417 {
418 return IPMI_CC_INVALID_FIELD_REQUEST;
419 }
420 ipmi_ret_t status = replaceCacheFru(reqDev);
421
422 if (status != IPMI_CC_OK)
423 {
424 return status;
425 }
426
427 GetFRUAreaResp* respPtr = static_cast<GetFRUAreaResp*>(response);
428 respPtr->inventorySizeLSB = fruCache.size() & 0xFF;
429 respPtr->inventorySizeMSB = fruCache.size() >> 8;
430 respPtr->accessType = static_cast<uint8_t>(GetFRUAreaAccessType::byte);
431
432 *dataLen = sizeof(GetFRUAreaResp);
433 return IPMI_CC_OK;
434}
435
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700436ipmi_ret_t getFruSdrCount(size_t& count)
437{
438 ipmi_ret_t ret = replaceCacheFru(0);
439 if (ret != IPMI_CC_OK)
440 {
441 return ret;
442 }
443 count = deviceHashes.size();
444 return IPMI_CC_OK;
445}
446
447ipmi_ret_t getFruSdrs(size_t index, get_sdr::SensorDataFruRecord& resp)
448{
449 ipmi_ret_t ret = replaceCacheFru(0); // this will update the hash list
450 if (ret != IPMI_CC_OK)
451 {
452 return ret;
453 }
454 if (deviceHashes.size() < index)
455 {
456 return IPMI_CC_INVALID_FIELD_REQUEST;
457 }
458 auto device = deviceHashes.begin() + index;
459 uint8_t& bus = device->second.first;
460 uint8_t& address = device->second.second;
461
462 ManagedObjectType frus;
463
464 sdbusplus::message::message getObjects = dbus.new_method_call(
465 fruDeviceServiceName, "/", "org.freedesktop.DBus.ObjectManager",
466 "GetManagedObjects");
467 try
468 {
469 sdbusplus::message::message resp = dbus.call(getObjects);
470 resp.read(frus);
471 }
472 catch (sdbusplus::exception_t&)
473 {
474 return IPMI_CC_RESPONSE_ERROR;
475 }
476 boost::container::flat_map<std::string, DbusVariant>* fruData = nullptr;
477 auto fru =
478 std::find_if(frus.begin(), frus.end(),
479 [bus, address, &fruData](ManagedEntry& entry) {
480 auto findFruDevice =
481 entry.second.find("xyz.openbmc_project.FruDevice");
482 if (findFruDevice == entry.second.end())
483 {
484 return false;
485 }
486 fruData = &(findFruDevice->second);
487 auto findBus = findFruDevice->second.find("BUS");
488 auto findAddress =
489 findFruDevice->second.find("ADDRESS");
490 if (findBus == findFruDevice->second.end() ||
491 findAddress == findFruDevice->second.end())
492 {
493 return false;
494 }
Vernon Mauery8166c8d2019-05-23 11:22:30 -0700495 if (std::get<uint32_t>(findBus->second) != bus)
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700496 {
497 return false;
498 }
Vernon Mauery8166c8d2019-05-23 11:22:30 -0700499 if (std::get<uint32_t>(findAddress->second) != address)
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700500 {
501 return false;
502 }
503 return true;
504 });
505 if (fru == frus.end())
506 {
507 return IPMI_CC_RESPONSE_ERROR;
508 }
509 std::string name;
510 auto findProductName = fruData->find("BOARD_PRODUCT_NAME");
511 auto findBoardName = fruData->find("PRODUCT_PRODUCT_NAME");
512 if (findProductName != fruData->end())
513 {
Vernon Mauery8166c8d2019-05-23 11:22:30 -0700514 name = std::get<std::string>(findProductName->second);
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700515 }
516 else if (findBoardName != fruData->end())
517 {
Vernon Mauery8166c8d2019-05-23 11:22:30 -0700518 name = std::get<std::string>(findBoardName->second);
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700519 }
520 else
521 {
522 name = "UNKNOWN";
523 }
524 if (name.size() > maxFruSdrNameSize)
525 {
526 name = name.substr(0, maxFruSdrNameSize);
527 }
528 size_t sizeDiff = maxFruSdrNameSize - name.size();
529
530 resp.header.record_id_lsb = 0x0; // calling code is to implement these
531 resp.header.record_id_msb = 0x0;
532 resp.header.sdr_version = ipmiSdrVersion;
533 resp.header.record_type = 0x11; // FRU Device Locator
534 resp.header.record_length = sizeof(resp.body) + sizeof(resp.key) - sizeDiff;
535 resp.key.deviceAddress = 0x20;
536 resp.key.fruID = device->first;
537 resp.key.accessLun = 0x80; // logical / physical fru device
538 resp.key.channelNumber = 0x0;
539 resp.body.reserved = 0x0;
540 resp.body.deviceType = 0x10;
James Feist4f86d1f2019-04-03 10:30:26 -0700541 resp.body.deviceTypeModifier = 0x0;
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700542 resp.body.entityID = 0x0;
543 resp.body.entityInstance = 0x1;
544 resp.body.oem = 0x0;
545 resp.body.deviceIDLen = name.size();
546 name.copy(resp.body.deviceID, name.size());
547
548 return IPMI_CC_OK;
549}
Jason M. Billse2d1aee2018-10-03 15:57:18 -0700550
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700551static bool getSELLogFiles(std::vector<std::filesystem::path>& selLogFiles)
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800552{
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700553 // Loop through the directory looking for ipmi_sel log files
554 for (const std::filesystem::directory_entry& dirEnt :
555 std::filesystem::directory_iterator(intel_oem::ipmi::sel::selLogDir))
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800556 {
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700557 std::string filename = dirEnt.path().filename();
558 if (boost::starts_with(filename, intel_oem::ipmi::sel::selLogFilename))
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800559 {
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700560 // If we find an ipmi_sel log file, save the path
561 selLogFiles.emplace_back(intel_oem::ipmi::sel::selLogDir /
562 filename);
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800563 }
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800564 }
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700565 // As the log files rotate, they are appended with a ".#" that is higher for
566 // the older logs. Since we don't expect more than 10 log files, we
567 // can just sort the list to get them in order from newest to oldest
568 std::sort(selLogFiles.begin(), selLogFiles.end());
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800569
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700570 return !selLogFiles.empty();
571}
572
573static int countSELEntries()
574{
575 // Get the list of ipmi_sel log files
576 std::vector<std::filesystem::path> selLogFiles;
577 if (!getSELLogFiles(selLogFiles))
578 {
579 return 0;
580 }
581 int numSELEntries = 0;
582 // Loop through each log file and count the number of logs
583 for (const std::filesystem::path& file : selLogFiles)
584 {
585 std::ifstream logStream(file);
586 if (!logStream.is_open())
587 {
588 continue;
589 }
590
591 std::string line;
592 while (std::getline(logStream, line))
593 {
594 numSELEntries++;
595 }
596 }
597 return numSELEntries;
598}
599
600static bool findSELEntry(const int recordID,
601 const std::vector<std::filesystem::path> selLogFiles,
602 std::string& entry)
603{
604 // Record ID is the first entry field following the timestamp. It is
605 // preceded by a space and followed by a comma
606 std::string search = " " + std::to_string(recordID) + ",";
607
608 // Loop through the ipmi_sel log entries
609 for (const std::filesystem::path& file : selLogFiles)
610 {
611 std::ifstream logStream(file);
612 if (!logStream.is_open())
613 {
614 continue;
615 }
616
617 while (std::getline(logStream, entry))
618 {
619 // Check if the record ID matches
620 if (entry.find(search) != std::string::npos)
621 {
622 return true;
623 }
624 }
625 }
626 return false;
627}
628
629static uint16_t
630 getNextRecordID(const uint16_t recordID,
631 const std::vector<std::filesystem::path> selLogFiles)
632{
633 uint16_t nextRecordID = recordID + 1;
634 std::string entry;
635 if (findSELEntry(nextRecordID, selLogFiles, entry))
636 {
637 return nextRecordID;
638 }
639 else
640 {
641 return ipmi::sel::lastEntry;
642 }
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800643}
644
645static int fromHexStr(const std::string hexStr, std::vector<uint8_t>& data)
646{
647 for (unsigned int i = 0; i < hexStr.size(); i += 2)
648 {
649 try
650 {
651 data.push_back(static_cast<uint8_t>(
652 std::stoul(hexStr.substr(i, 2), nullptr, 16)));
653 }
654 catch (std::invalid_argument& e)
655 {
656 phosphor::logging::log<phosphor::logging::level::ERR>(e.what());
657 return -1;
658 }
659 catch (std::out_of_range& e)
660 {
661 phosphor::logging::log<phosphor::logging::level::ERR>(e.what());
662 return -1;
663 }
664 }
665 return 0;
666}
667
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700668ipmi::RspType<uint8_t, // SEL version
669 uint16_t, // SEL entry count
670 uint16_t, // free space
671 uint32_t, // last add timestamp
672 uint32_t, // last erase timestamp
673 uint8_t> // operation support
674 ipmiStorageGetSELInfo()
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800675{
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700676 constexpr uint8_t selVersion = ipmi::sel::selVersion;
677 uint16_t entries = countSELEntries();
678 uint32_t addTimeStamp = intel_oem::ipmi::sel::getFileTimestamp(
679 intel_oem::ipmi::sel::selLogDir / intel_oem::ipmi::sel::selLogFilename);
680 uint32_t eraseTimeStamp = intel_oem::ipmi::sel::erase_time::get();
681 constexpr uint8_t operationSupport =
682 intel_oem::ipmi::sel::selOperationSupport;
683 constexpr uint16_t freeSpace =
684 0xffff; // Spec indicates that more than 64kB is free
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800685
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700686 return ipmi::responseSuccess(selVersion, entries, freeSpace, addTimeStamp,
687 eraseTimeStamp, operationSupport);
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800688}
689
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700690using systemEventType = std::tuple<
691 uint32_t, // Timestamp
692 uint16_t, // Generator ID
693 uint8_t, // EvM Rev
694 uint8_t, // Sensor Type
695 uint8_t, // Sensor Number
696 uint7_t, // Event Type
697 bool, // Event Direction
698 std::array<uint8_t, intel_oem::ipmi::sel::systemEventSize>>; // Event Data
699using oemTsEventType = std::tuple<
700 uint32_t, // Timestamp
701 std::array<uint8_t, intel_oem::ipmi::sel::oemTsEventSize>>; // Event Data
702using oemEventType =
703 std::array<uint8_t, intel_oem::ipmi::sel::oemEventSize>; // Event Data
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800704
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700705ipmi::RspType<uint16_t, // Next Record ID
706 uint16_t, // Record ID
707 uint8_t, // Record Type
708 std::variant<systemEventType, oemTsEventType,
709 oemEventType>> // Record Content
710 ipmiStorageGetSELEntry(uint16_t reservationID, uint16_t targetID,
711 uint8_t offset, uint8_t size)
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800712{
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700713 // Only support getting the entire SEL record. If a partial size or non-zero
714 // offset is requested, return an error
715 if (offset != 0 || size != ipmi::sel::entireRecord)
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800716 {
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700717 return ipmi::responseRetBytesUnavailable();
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800718 }
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800719
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700720 // Check the reservation ID if one is provided or required (only if the
721 // offset is non-zero)
722 if (reservationID != 0 || offset != 0)
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800723 {
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700724 if (!checkSELReservation(reservationID))
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800725 {
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700726 return ipmi::responseInvalidReservationId();
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800727 }
728 }
729
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700730 // Get the ipmi_sel log files
731 std::vector<std::filesystem::path> selLogFiles;
732 if (!getSELLogFiles(selLogFiles))
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800733 {
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700734 return ipmi::responseSensorInvalid();
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800735 }
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800736
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700737 std::string targetEntry;
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800738
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800739 if (targetID == ipmi::sel::firstEntry)
740 {
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700741 // The first entry will be at the top of the oldest log file
742 std::ifstream logStream(selLogFiles.back());
743 if (!logStream.is_open())
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800744 {
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700745 return ipmi::responseUnspecifiedError();
746 }
747
748 if (!std::getline(logStream, targetEntry))
749 {
750 return ipmi::responseUnspecifiedError();
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800751 }
752 }
753 else if (targetID == ipmi::sel::lastEntry)
754 {
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700755 // The last entry will be at the bottom of the newest log file
756 std::ifstream logStream(selLogFiles.front());
757 if (!logStream.is_open())
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800758 {
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700759 return ipmi::responseUnspecifiedError();
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800760 }
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700761
762 std::string line;
763 while (std::getline(logStream, line))
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800764 {
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700765 targetEntry = line;
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800766 }
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800767 }
768 else
769 {
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700770 if (!findSELEntry(targetID, selLogFiles, targetEntry))
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800771 {
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700772 return ipmi::responseSensorInvalid();
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800773 }
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800774 }
775
Jason M. Bills52aaa7d2019-05-08 15:21:39 -0700776 // The format of the ipmi_sel message is "<Timestamp>
777 // <ID>,<Type>,<EventData>,[<Generator ID>,<Path>,<Direction>]".
778 // First get the Timestamp
779 size_t space = targetEntry.find_first_of(" ");
780 if (space == std::string::npos)
781 {
782 return ipmi::responseUnspecifiedError();
783 }
784 std::string entryTimestamp = targetEntry.substr(0, space);
785 // Then get the log contents
786 size_t entryStart = targetEntry.find_first_not_of(" ", space);
787 if (entryStart == std::string::npos)
788 {
789 return ipmi::responseUnspecifiedError();
790 }
791 std::string_view entry(targetEntry);
792 entry.remove_prefix(entryStart);
793 // Use split to separate the entry into its fields
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700794 std::vector<std::string> targetEntryFields;
Jason M. Bills52aaa7d2019-05-08 15:21:39 -0700795 boost::split(targetEntryFields, entry, boost::is_any_of(","),
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700796 boost::token_compress_on);
Jason M. Bills52aaa7d2019-05-08 15:21:39 -0700797 if (targetEntryFields.size() < 3)
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700798 {
799 return ipmi::responseUnspecifiedError();
800 }
Jason M. Bills1a2fbdd2019-05-10 09:05:37 -0700801 std::string& recordIDStr = targetEntryFields[0];
802 std::string& recordTypeStr = targetEntryFields[1];
803 std::string& eventDataStr = targetEntryFields[2];
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700804
Jason M. Bills1a2fbdd2019-05-10 09:05:37 -0700805 uint16_t recordID;
806 uint8_t recordType;
807 try
808 {
809 recordID = std::stoul(recordIDStr);
810 recordType = std::stoul(recordTypeStr, nullptr, 16);
811 }
812 catch (const std::invalid_argument&)
813 {
814 return ipmi::responseUnspecifiedError();
815 }
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700816 uint16_t nextRecordID = getNextRecordID(recordID, selLogFiles);
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700817 std::vector<uint8_t> eventDataBytes;
Jason M. Bills1a2fbdd2019-05-10 09:05:37 -0700818 if (fromHexStr(eventDataStr, eventDataBytes) < 0)
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700819 {
820 return ipmi::responseUnspecifiedError();
821 }
822
823 if (recordType == intel_oem::ipmi::sel::systemEvent)
824 {
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700825 // Get the timestamp
826 std::tm timeStruct = {};
Jason M. Bills52aaa7d2019-05-08 15:21:39 -0700827 std::istringstream entryStream(entryTimestamp);
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700828
829 uint32_t timestamp = ipmi::sel::invalidTimeStamp;
830 if (entryStream >> std::get_time(&timeStruct, "%Y-%m-%dT%H:%M:%S"))
831 {
832 timestamp = std::mktime(&timeStruct);
833 }
834
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700835 // Set the event message revision
836 uint8_t evmRev = intel_oem::ipmi::sel::eventMsgRev;
837
Jason M. Bills1a2fbdd2019-05-10 09:05:37 -0700838 uint16_t generatorID = 0;
839 uint8_t sensorType = 0;
840 uint8_t sensorNum = 0xFF;
841 uint7_t eventType = 0;
842 bool eventDir = 0;
843 // System type events should have six fields
844 if (targetEntryFields.size() >= 6)
845 {
846 std::string& generatorIDStr = targetEntryFields[3];
847 std::string& sensorPath = targetEntryFields[4];
848 std::string& eventDirStr = targetEntryFields[5];
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700849
Jason M. Bills1a2fbdd2019-05-10 09:05:37 -0700850 // Get the generator ID
851 try
852 {
853 generatorID = std::stoul(generatorIDStr, nullptr, 16);
854 }
855 catch (const std::invalid_argument&)
856 {
857 std::cerr << "Invalid Generator ID\n";
858 }
859
860 // Get the sensor type, sensor number, and event type for the sensor
861 sensorType = getSensorTypeFromPath(sensorPath);
862 sensorNum = getSensorNumberFromPath(sensorPath);
863 eventType = getSensorEventTypeFromPath(sensorPath);
864
865 // Get the event direction
866 try
867 {
868 eventDir = std::stoul(eventDirStr) ? 0 : 1;
869 }
870 catch (const std::invalid_argument&)
871 {
872 std::cerr << "Invalid Event Direction\n";
873 }
874 }
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700875
876 // Only keep the eventData bytes that fit in the record
877 std::array<uint8_t, intel_oem::ipmi::sel::systemEventSize> eventData{};
878 std::copy_n(eventDataBytes.begin(),
879 std::min(eventDataBytes.size(), eventData.size()),
880 eventData.begin());
881
882 return ipmi::responseSuccess(
883 nextRecordID, recordID, recordType,
884 systemEventType{timestamp, generatorID, evmRev, sensorType,
885 sensorNum, eventType, eventDir, eventData});
886 }
887 else if (recordType >= intel_oem::ipmi::sel::oemTsEventFirst &&
888 recordType <= intel_oem::ipmi::sel::oemTsEventLast)
889 {
890 // Get the timestamp
891 std::tm timeStruct = {};
Jason M. Bills52aaa7d2019-05-08 15:21:39 -0700892 std::istringstream entryStream(entryTimestamp);
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700893
894 uint32_t timestamp = ipmi::sel::invalidTimeStamp;
895 if (entryStream >> std::get_time(&timeStruct, "%Y-%m-%dT%H:%M:%S"))
896 {
897 timestamp = std::mktime(&timeStruct);
898 }
899
900 // Only keep the bytes that fit in the record
901 std::array<uint8_t, intel_oem::ipmi::sel::oemTsEventSize> eventData{};
902 std::copy_n(eventDataBytes.begin(),
903 std::min(eventDataBytes.size(), eventData.size()),
904 eventData.begin());
905
906 return ipmi::responseSuccess(nextRecordID, recordID, recordType,
907 oemTsEventType{timestamp, eventData});
908 }
909 else if (recordType >= intel_oem::ipmi::sel::oemEventFirst &&
910 recordType <= intel_oem::ipmi::sel::oemEventLast)
911 {
912 // Only keep the bytes that fit in the record
913 std::array<uint8_t, intel_oem::ipmi::sel::oemEventSize> eventData{};
914 std::copy_n(eventDataBytes.begin(),
915 std::min(eventDataBytes.size(), eventData.size()),
916 eventData.begin());
917
918 return ipmi::responseSuccess(nextRecordID, recordID, recordType,
919 eventData);
920 }
921
922 return ipmi::responseUnspecifiedError();
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800923}
924
Jason M. Bills6dd8f042019-04-11 10:39:02 -0700925ipmi::RspType<uint16_t> ipmiStorageAddSELEntry(
926 uint16_t recordID, uint8_t recordType, uint32_t timestamp,
927 uint16_t generatorID, uint8_t evmRev, uint8_t sensorType, uint8_t sensorNum,
928 uint8_t eventType, uint8_t eventData1, uint8_t eventData2,
929 uint8_t eventData3)
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800930{
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800931 // Per the IPMI spec, need to cancel any reservation when a SEL entry is
932 // added
933 cancelSELReservation();
934
Jason M. Bills6dd8f042019-04-11 10:39:02 -0700935 // Send this request to the Redfish hooks to log it as a Redfish message
936 // instead. There is no need to add it to the SEL, so just return success.
937 intel_oem::ipmi::sel::checkRedfishHooks(
938 recordID, recordType, timestamp, generatorID, evmRev, sensorType,
939 sensorNum, eventType, eventData1, eventData2, eventData3);
Jason M. Bills99b78ec2019-01-18 10:42:18 -0800940
Jason M. Bills6dd8f042019-04-11 10:39:02 -0700941 uint16_t responseID = 0xFFFF;
942 return ipmi::responseSuccess(responseID);
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800943}
944
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700945ipmi::RspType<uint8_t> ipmiStorageClearSEL(ipmi::Context::ptr ctx,
946 uint16_t reservationID,
947 const std::array<uint8_t, 3>& clr,
948 uint8_t eraseOperation)
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800949{
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700950 if (!checkSELReservation(reservationID))
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800951 {
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700952 return ipmi::responseInvalidReservationId();
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800953 }
954
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700955 static constexpr std::array<uint8_t, 3> clrExpected = {'C', 'L', 'R'};
956 if (clr != clrExpected)
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800957 {
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700958 return ipmi::responseInvalidFieldRequest();
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800959 }
960
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700961 // Erasure status cannot be fetched, so always return erasure status as
962 // `erase completed`.
963 if (eraseOperation == ipmi::sel::getEraseStatus)
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800964 {
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700965 return ipmi::responseSuccess(ipmi::sel::eraseComplete);
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800966 }
967
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700968 // Check that initiate erase is correct
969 if (eraseOperation != ipmi::sel::initiateErase)
970 {
971 return ipmi::responseInvalidFieldRequest();
972 }
973
974 // Per the IPMI spec, need to cancel any reservation when the SEL is
975 // cleared
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800976 cancelSELReservation();
977
Jason M. Bills7944c302019-03-20 15:24:05 -0700978 // Save the erase time
979 intel_oem::ipmi::sel::erase_time::save();
980
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700981 // Clear the SEL by deleting the log files
982 std::vector<std::filesystem::path> selLogFiles;
983 if (getSELLogFiles(selLogFiles))
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800984 {
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700985 for (const std::filesystem::path& file : selLogFiles)
986 {
987 std::error_code ec;
988 std::filesystem::remove(file, ec);
989 }
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800990 }
991
Jason M. Bills1d4d54d2019-04-23 11:26:11 -0700992 // Reload rsyslog so it knows to start new log files
993 sdbusplus::message::message rsyslogReload = dbus.new_method_call(
994 "org.freedesktop.systemd1", "/org/freedesktop/systemd1",
995 "org.freedesktop.systemd1.Manager", "ReloadUnit");
996 rsyslogReload.append("rsyslog.service", "replace");
997 try
998 {
999 sdbusplus::message::message reloadResponse = dbus.call(rsyslogReload);
1000 }
1001 catch (sdbusplus::exception_t& e)
1002 {
1003 phosphor::logging::log<phosphor::logging::level::ERR>(e.what());
1004 }
1005
1006 return ipmi::responseSuccess(ipmi::sel::eraseComplete);
Jason M. Billsc04e2e72018-11-28 15:15:56 -08001007}
1008
Jason M. Bills1a474622019-06-14 14:51:33 -07001009ipmi::RspType<uint32_t> ipmiStorageGetSELTime()
1010{
1011 struct timespec selTime = {};
1012
1013 if (clock_gettime(CLOCK_REALTIME, &selTime) < 0)
1014 {
1015 return ipmi::responseUnspecifiedError();
1016 }
1017
1018 return ipmi::responseSuccess(selTime.tv_sec);
1019}
1020
Jason M. Bills1d4d54d2019-04-23 11:26:11 -07001021ipmi::RspType<> ipmiStorageSetSELTime(uint32_t selTime)
Jason M. Billscac97a52019-01-30 14:43:46 -08001022{
1023 // Set SEL Time is not supported
Jason M. Bills1d4d54d2019-04-23 11:26:11 -07001024 return ipmi::responseInvalidCommand();
Jason M. Billscac97a52019-01-30 14:43:46 -08001025}
1026
Jason M. Billse2d1aee2018-10-03 15:57:18 -07001027void registerStorageFunctions()
1028{
1029 // <Get FRU Inventory Area Info>
1030 ipmiPrintAndRegister(
1031 NETFUN_STORAGE,
1032 static_cast<ipmi_cmd_t>(IPMINetfnStorageCmds::ipmiCmdGetFRUInvAreaInfo),
1033 NULL, ipmiStorageGetFRUInvAreaInfo, PRIVILEGE_OPERATOR);
1034
Jason M. Billsc04e2e72018-11-28 15:15:56 -08001035 // <READ FRU Data>
Jason M. Billse2d1aee2018-10-03 15:57:18 -07001036 ipmiPrintAndRegister(
1037 NETFUN_STORAGE,
1038 static_cast<ipmi_cmd_t>(IPMINetfnStorageCmds::ipmiCmdReadFRUData), NULL,
1039 ipmiStorageReadFRUData, PRIVILEGE_OPERATOR);
1040
Jason M. Billsc04e2e72018-11-28 15:15:56 -08001041 // <WRITE FRU Data>
Jason M. Billse2d1aee2018-10-03 15:57:18 -07001042 ipmiPrintAndRegister(
1043 NETFUN_STORAGE,
1044 static_cast<ipmi_cmd_t>(IPMINetfnStorageCmds::ipmiCmdWriteFRUData),
1045 NULL, ipmiStorageWriteFRUData, PRIVILEGE_OPERATOR);
Jason M. Billsc04e2e72018-11-28 15:15:56 -08001046
1047 // <Get SEL Info>
Jason M. Bills1d4d54d2019-04-23 11:26:11 -07001048 ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnStorage,
1049 ipmi::storage::cmdGetSelInfo,
1050 ipmi::Privilege::Operator, ipmiStorageGetSELInfo);
Jason M. Billsc04e2e72018-11-28 15:15:56 -08001051
1052 // <Get SEL Entry>
Jason M. Bills1d4d54d2019-04-23 11:26:11 -07001053 ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnStorage,
1054 ipmi::storage::cmdGetSelEntry,
1055 ipmi::Privilege::Operator, ipmiStorageGetSELEntry);
Jason M. Billsc04e2e72018-11-28 15:15:56 -08001056
1057 // <Add SEL Entry>
Jason M. Bills6dd8f042019-04-11 10:39:02 -07001058 ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnStorage,
1059 static_cast<ipmi::Cmd>(ipmi::storage::cmdAddSelEntry),
1060 ipmi::Privilege::Operator, ipmiStorageAddSELEntry);
Jason M. Billsc04e2e72018-11-28 15:15:56 -08001061
1062 // <Clear SEL>
Jason M. Bills1d4d54d2019-04-23 11:26:11 -07001063 ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnStorage,
1064 ipmi::storage::cmdClearSel, ipmi::Privilege::Operator,
1065 ipmiStorageClearSEL);
Jason M. Billscac97a52019-01-30 14:43:46 -08001066
Jason M. Bills1a474622019-06-14 14:51:33 -07001067 // <Get SEL Time>
1068 ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnStorage,
1069 ipmi::storage::cmdGetSelTime,
1070 ipmi::Privilege::Operator, ipmiStorageGetSELTime);
1071
Jason M. Billscac97a52019-01-30 14:43:46 -08001072 // <Set SEL Time>
Jason M. Bills1d4d54d2019-04-23 11:26:11 -07001073 ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnStorage,
1074 ipmi::storage::cmdSetSelTime,
1075 ipmi::Privilege::Operator, ipmiStorageSetSELTime);
Jason M. Billse2d1aee2018-10-03 15:57:18 -07001076}
Jason M. Bills3f7c5e42018-10-03 14:00:41 -07001077} // namespace storage
Jason M. Billsc04e2e72018-11-28 15:15:56 -08001078} // namespace ipmi