xref: /openbmc/smbios-mdr/src/mdrv2.cpp (revision bc924d0f9f590d7d420b9f7bc98bdb9b8688618e)
1 /*
2 // Copyright (c) 2018 Intel Corporation
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //      http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 */
16 
17 #include "mdrv2.hpp"
18 
19 #include "pcieslot.hpp"
20 
21 #include <sys/mman.h>
22 
23 #include <phosphor-logging/elog-errors.hpp>
24 #include <sdbusplus/exception.hpp>
25 #include <xyz/openbmc_project/Smbios/MDR_V2/error.hpp>
26 
27 #include <fstream>
28 
29 namespace phosphor
30 {
31 namespace smbios
32 {
33 
34 std::vector<uint8_t> MDR_V2::getDirectoryInformation(uint8_t dirIndex)
35 {
36     std::vector<uint8_t> responseDir;
37 
38     std::ifstream smbiosFile(mdrType2File, std::ios_base::binary);
39     if (!smbiosFile.good())
40     {
41         phosphor::logging::log<phosphor::logging::level::ERR>(
42             "Read data from flash error - Open MDRV2 table file failure");
43         throw sdbusplus::xyz::openbmc_project::Smbios::MDR_V2::Error::
44             InvalidParameter();
45     }
46     if (dirIndex > smbiosDir.dirEntries)
47     {
48         responseDir.push_back(0);
49         throw sdbusplus::xyz::openbmc_project::Smbios::MDR_V2::Error::
50             InvalidParameter();
51     }
52     responseDir.push_back(mdr2Version);
53     responseDir.push_back(smbiosDir.dirVersion);
54     uint8_t returnedEntries = smbiosDir.dirEntries - dirIndex;
55     responseDir.push_back(returnedEntries);
56     if ((dirIndex + returnedEntries) >= smbiosDir.dirEntries)
57     {
58         responseDir.push_back(0);
59     }
60     else
61     {
62         responseDir.push_back(smbiosDir.dirEntries - dirIndex -
63                               returnedEntries);
64     }
65     for (uint8_t index = dirIndex; index < smbiosDir.dirEntries; index++)
66     {
67         for (uint8_t indexId = 0; indexId < sizeof(DataIdStruct); indexId++)
68         {
69             responseDir.push_back(
70                 smbiosDir.dir[index].common.id.dataInfo[indexId]);
71         }
72     }
73 
74     return responseDir;
75 }
76 
77 bool MDR_V2::smbiosIsAvailForUpdate(uint8_t index)
78 {
79     bool ret = false;
80     if (index >= maxDirEntries)
81     {
82         return ret;
83     }
84 
85     switch (smbiosDir.dir[index].stage)
86     {
87         case MDR2SMBIOSStatusEnum::mdr2Updating:
88             ret = false;
89             break;
90 
91         case MDR2SMBIOSStatusEnum::mdr2Init:
92             // This *looks* like there should be a break statement here,
93             // as the effects of the previous statement are a noop given
94             // the following code that this falls through to.
95             // We've elected not to change it, though, since it's been
96             // this way since the old generation, and it would affect
97             // the way the code functions.
98             // If it ain't broke, don't fix it.
99 
100         case MDR2SMBIOSStatusEnum::mdr2Loaded:
101         case MDR2SMBIOSStatusEnum::mdr2Updated:
102             if (smbiosDir.dir[index].lock == MDR2DirLockEnum::mdr2DirLock)
103             {
104                 ret = false;
105             }
106             else
107             {
108                 ret = true;
109             }
110             break;
111 
112         default:
113             break;
114     }
115 
116     return ret;
117 }
118 
119 std::vector<uint8_t> MDR_V2::getDataOffer()
120 {
121     std::vector<uint8_t> offer(sizeof(DataIdStruct));
122     if (smbiosIsAvailForUpdate(0))
123     {
124         std::copy(smbiosDir.dir[0].common.id.dataInfo,
125                   &smbiosDir.dir[0].common.id.dataInfo[16], offer.data());
126     }
127     else
128     {
129         phosphor::logging::log<phosphor::logging::level::ERR>(
130             "smbios is not ready for update");
131         throw sdbusplus::xyz::openbmc_project::Smbios::MDR_V2::Error::
132             UpdateInProgress();
133     }
134     return offer;
135 }
136 
137 inline uint8_t MDR_V2::smbiosValidFlag(uint8_t index)
138 {
139     FlagStatus ret = FlagStatus::flagIsInvalid;
140     MDR2SMBIOSStatusEnum stage = smbiosDir.dir[index].stage;
141     MDR2DirLockEnum lock = smbiosDir.dir[index].lock;
142 
143     switch (stage)
144     {
145         case MDR2SMBIOSStatusEnum::mdr2Loaded:
146         case MDR2SMBIOSStatusEnum::mdr2Updated:
147             if (lock == MDR2DirLockEnum::mdr2DirLock)
148             {
149                 ret = FlagStatus::flagIsLocked; // locked
150             }
151             else
152             {
153                 ret = FlagStatus::flagIsValid; // valid
154             }
155             break;
156 
157         case MDR2SMBIOSStatusEnum::mdr2Updating:
158         case MDR2SMBIOSStatusEnum::mdr2Init:
159             ret = FlagStatus::flagIsInvalid; // invalid
160             break;
161 
162         default:
163             break;
164     }
165 
166     return static_cast<uint8_t>(ret);
167 }
168 
169 // If source variable size is 4 bytes (uint32_t) and destination is Vector type
170 // is 1 byte (uint8_t), then by using this API can copy data byte by byte. For
171 // Example copying data from smbiosDir.dir[idIndex].common.size and
172 // smbiosDir.dir[idIndex].common.timestamp to vector variable responseInfo
173 template <typename T>
174 void appendReversed(std::vector<uint8_t>& vector, const T& value)
175 {
176     auto data = reinterpret_cast<const uint8_t*>(&value);
177     std::reverse_copy(data, data + sizeof(value), std::back_inserter(vector));
178 }
179 
180 std::vector<uint8_t> MDR_V2::getDataInformation(uint8_t idIndex)
181 {
182     std::vector<uint8_t> responseInfo;
183     responseInfo.push_back(mdr2Version);
184 
185     if (idIndex >= maxDirEntries)
186     {
187         throw sdbusplus::xyz::openbmc_project::Smbios::MDR_V2::Error::
188             InvalidParameter();
189     }
190 
191     for (uint8_t index = 0; index < sizeof(DataIdStruct); index++)
192     {
193         responseInfo.push_back(
194             smbiosDir.dir[idIndex].common.id.dataInfo[index]);
195     }
196 
197     responseInfo.push_back(smbiosValidFlag(idIndex));
198     appendReversed(responseInfo, smbiosDir.dir[idIndex].common.size);
199     responseInfo.push_back(smbiosDir.dir[idIndex].common.dataVersion);
200     appendReversed(responseInfo, smbiosDir.dir[idIndex].common.timestamp);
201 
202     return responseInfo;
203 }
204 
205 bool MDR_V2::readDataFromFlash(MDRSMBIOSHeader* mdrHdr, uint8_t* data)
206 {
207     if (mdrHdr == nullptr)
208     {
209         phosphor::logging::log<phosphor::logging::level::ERR>(
210             "Read data from flash error - Invalid mdr header");
211         return false;
212     }
213     if (data == nullptr)
214     {
215         phosphor::logging::log<phosphor::logging::level::ERR>(
216             "Read data from flash error - Invalid data point");
217         return false;
218     }
219     std::ifstream smbiosFile(mdrType2File, std::ios_base::binary);
220     if (!smbiosFile.good())
221     {
222         phosphor::logging::log<phosphor::logging::level::ERR>(
223             "Read data from flash error - Open MDRV2 table file failure");
224         return false;
225     }
226     smbiosFile.clear();
227     smbiosFile.seekg(0, std::ios_base::end);
228     int fileLength = smbiosFile.tellg();
229     smbiosFile.seekg(0, std::ios_base::beg);
230     if (fileLength < sizeof(MDRSMBIOSHeader))
231     {
232         phosphor::logging::log<phosphor::logging::level::ERR>(
233             "MDR V2 file size is smaller than mdr header");
234         return false;
235     }
236     smbiosFile.read(reinterpret_cast<char*>(mdrHdr), sizeof(MDRSMBIOSHeader));
237     if (mdrHdr->dataSize > smbiosTableStorageSize)
238     {
239         phosphor::logging::log<phosphor::logging::level::ERR>(
240             "Data size out of limitation");
241         smbiosFile.close();
242         return false;
243     }
244     fileLength -= sizeof(MDRSMBIOSHeader);
245     if (fileLength < mdrHdr->dataSize)
246     {
247         smbiosFile.read(reinterpret_cast<char*>(data), fileLength);
248     }
249     else
250     {
251         smbiosFile.read(reinterpret_cast<char*>(data), mdrHdr->dataSize);
252     }
253     smbiosFile.close();
254     return true;
255 }
256 
257 bool MDR_V2::sendDirectoryInformation(uint8_t dirVersion, uint8_t dirIndex,
258                                       uint8_t returnedEntries,
259                                       uint8_t remainingEntries,
260                                       std::vector<uint8_t> dirEntry)
261 {
262     bool teminate = false;
263     if ((dirIndex >= maxDirEntries) || (returnedEntries < 1))
264     {
265         phosphor::logging::log<phosphor::logging::level::ERR>(
266             "Send Dir info failed - input parameter invalid");
267         throw sdbusplus::xyz::openbmc_project::Smbios::MDR_V2::Error::
268             InvalidParameter();
269     }
270     if ((static_cast<size_t>(returnedEntries) * sizeof(DataIdStruct)) !=
271         dirEntry.size())
272     {
273         phosphor::logging::log<phosphor::logging::level::ERR>(
274             "Directory size invalid");
275         throw sdbusplus::xyz::openbmc_project::Smbios::MDR_V2::Error::
276             InvalidParameter();
277     }
278     if (dirVersion == smbiosDir.dirVersion)
279     {
280         teminate = true;
281     }
282     else
283     {
284         if (remainingEntries > 0)
285         {
286             teminate = false;
287         }
288         else
289         {
290             teminate = true;
291             smbiosDir.dirVersion = dirVersion;
292         }
293         uint8_t idIndex = dirIndex;
294         smbiosDir.dirEntries = returnedEntries;
295 
296         uint8_t* pData = dirEntry.data();
297         if (pData == nullptr)
298         {
299             return false;
300         }
301         for (uint8_t index = 0; index < returnedEntries; index++)
302         {
303             auto data = reinterpret_cast<const DataIdStruct*>(pData);
304             std::copy(data->dataInfo, data->dataInfo + sizeof(DataIdStruct),
305                       smbiosDir.dir[idIndex + index].common.id.dataInfo);
306             pData += sizeof(DataIdStruct);
307         }
308     }
309     return teminate;
310 }
311 
312 bool MDR_V2::sendDataInformation(uint8_t idIndex, uint8_t flag,
313                                  uint32_t dataLen, uint32_t dataVer,
314                                  uint32_t timeStamp)
315 {
316     if (idIndex >= maxDirEntries)
317     {
318         throw sdbusplus::xyz::openbmc_project::Smbios::MDR_V2::Error::
319             InvalidParameter();
320     }
321     int entryChanged = 0;
322     if (smbiosDir.dir[idIndex].common.dataSetSize != dataLen)
323     {
324         entryChanged++;
325         smbiosDir.dir[idIndex].common.dataSetSize = dataLen;
326     }
327 
328     if (smbiosDir.dir[idIndex].common.dataVersion != dataVer)
329     {
330         entryChanged++;
331         smbiosDir.dir[idIndex].common.dataVersion = dataVer;
332     }
333 
334     if (smbiosDir.dir[idIndex].common.timestamp != timeStamp)
335     {
336         entryChanged++;
337         smbiosDir.dir[idIndex].common.timestamp = timeStamp;
338     }
339     if (entryChanged == 0)
340     {
341         return false;
342     }
343     return true;
344 }
345 
346 int MDR_V2::findIdIndex(std::vector<uint8_t> dataInfo)
347 {
348     if (dataInfo.size() != sizeof(DataIdStruct))
349     {
350         phosphor::logging::log<phosphor::logging::level::ERR>(
351             "Length of dataInfo invalid");
352         throw sdbusplus::xyz::openbmc_project::Smbios::MDR_V2::Error::
353             InvalidId();
354     }
355     std::array<uint8_t, 16> arrayDataInfo;
356 
357     std::copy(dataInfo.begin(), dataInfo.end(), arrayDataInfo.begin());
358 
359     for (int index = 0; index < smbiosDir.dirEntries; index++)
360     {
361         int info = 0;
362         for (; info < arrayDataInfo.size(); info++)
363         {
364             if (arrayDataInfo[info] !=
365                 smbiosDir.dir[index].common.id.dataInfo[info])
366             {
367                 break;
368             }
369         }
370         if (info == arrayDataInfo.size())
371         {
372             return index;
373         }
374     }
375     throw sdbusplus::xyz::openbmc_project::Smbios::MDR_V2::Error::InvalidId();
376 }
377 
378 uint8_t MDR_V2::directoryEntries(uint8_t value)
379 {
380     std::ifstream smbiosFile(mdrType2File, std::ios_base::binary);
381     if (!smbiosFile.good())
382     {
383         phosphor::logging::log<phosphor::logging::level::ERR>(
384             "Read data from flash error - Open MDRV2 table file failure");
385         value = 0;
386     }
387     else
388     {
389         value = smbiosDir.dirEntries;
390     }
391     return sdbusplus::xyz::openbmc_project::Smbios::server::MDR_V2::
392         directoryEntries(value);
393 }
394 
395 void MDR_V2::systemInfoUpdate()
396 {
397     std::string motherboardPath;
398     sdbusplus::message::message method =
399         bus.new_method_call("xyz.openbmc_project.EntityManager",
400                             "/xyz/openbmc_project/EntityManager",
401                             "xyz.openbmc_project.EntityManager", "ReScan");
402     try
403     {
404         sdbusplus::message::message reply = bus.call(method);
405         reply.read(motherboardPath);
406     }
407     catch (const sdbusplus::exception_t& e)
408     {
409         phosphor::logging::log<phosphor::logging::level::ERR>(
410             "Failed to query system motherboard",
411             phosphor::logging::entry("ERROR=%s", e.what()));
412     }
413 
414     cpus.clear();
415     int num = getTotalCpuSlot();
416     if (num == -1)
417     {
418         phosphor::logging::log<phosphor::logging::level::ERR>(
419             "get cpu total slot failed");
420         return;
421     }
422 
423     for (int index = 0; index < num; index++)
424     {
425         std::string path = cpuPath + std::to_string(index);
426         cpus.emplace_back(std::make_unique<phosphor::smbios::Cpu>(
427             bus, path, index, smbiosDir.dir[smbiosDirIndex].dataStorage,
428             motherboardPath));
429     }
430 
431 #ifdef DIMM_DBUS
432 
433     dimms.clear();
434 
435     num = getTotalDimmSlot();
436     if (num == -1)
437     {
438         phosphor::logging::log<phosphor::logging::level::ERR>(
439             "get dimm total slot failed");
440         return;
441     }
442 
443     for (int index = 0; index < num; index++)
444     {
445         std::string path = dimmPath + std::to_string(index);
446         dimms.emplace_back(std::make_unique<phosphor::smbios::Dimm>(
447             bus, path, index, smbiosDir.dir[smbiosDirIndex].dataStorage,
448             motherboardPath));
449     }
450 
451 #endif
452 
453     pcies.clear();
454     num = getTotalPcieSlot();
455     if (num == -1)
456     {
457         phosphor::logging::log<phosphor::logging::level::ERR>(
458             "get pcie total slot failed");
459         return;
460     }
461 
462     for (int index = 0; index < num; index++)
463     {
464         std::string path = pciePath + std::to_string(index);
465         pcies.emplace_back(std::make_unique<phosphor::smbios::Pcie>(
466             bus, path, index, smbiosDir.dir[smbiosDirIndex].dataStorage,
467             motherboardPath));
468     }
469 
470     system.reset();
471     system = std::make_unique<System>(
472         bus, systemPath, smbiosDir.dir[smbiosDirIndex].dataStorage);
473 }
474 
475 int MDR_V2::getTotalCpuSlot()
476 {
477     uint8_t* dataIn = smbiosDir.dir[smbiosDirIndex].dataStorage;
478     int num = 0;
479 
480     if (dataIn == nullptr)
481     {
482         phosphor::logging::log<phosphor::logging::level::ERR>(
483             "get cpu total slot failed - no storage data");
484         return -1;
485     }
486 
487     while (1)
488     {
489         dataIn = getSMBIOSTypePtr(dataIn, processorsType);
490         if (dataIn == nullptr)
491         {
492             break;
493         }
494         num++;
495         dataIn = smbiosNextPtr(dataIn);
496         if (dataIn == nullptr)
497         {
498             break;
499         }
500         if (num >= limitEntryLen)
501         {
502             break;
503         }
504     }
505 
506     return num;
507 }
508 
509 int MDR_V2::getTotalDimmSlot()
510 {
511     uint8_t* dataIn = smbiosDir.dir[smbiosDirIndex].dataStorage;
512     uint8_t num = 0;
513 
514     if (dataIn == nullptr)
515     {
516         phosphor::logging::log<phosphor::logging::level::ERR>(
517             "Fail to get dimm total slot - no storage data");
518         return -1;
519     }
520 
521     while (1)
522     {
523         dataIn = getSMBIOSTypePtr(dataIn, memoryDeviceType);
524         if (dataIn == nullptr)
525         {
526             break;
527         }
528         num++;
529         dataIn = smbiosNextPtr(dataIn);
530         if (dataIn == nullptr)
531         {
532             break;
533         }
534         if (num >= limitEntryLen)
535         {
536             break;
537         }
538     }
539 
540     return num;
541 }
542 
543 int MDR_V2::getTotalPcieSlot()
544 {
545     uint8_t* dataIn = smbiosDir.dir[smbiosDirIndex].dataStorage;
546     int num = 0;
547 
548     if (dataIn == nullptr)
549     {
550         phosphor::logging::log<phosphor::logging::level::ERR>(
551             "Fail to get total system slot - no storage data");
552         return -1;
553     }
554 
555     while (1)
556     {
557         dataIn = getSMBIOSTypePtr(dataIn, systemSlots);
558         if (dataIn == nullptr)
559         {
560             break;
561         }
562 
563         /* System slot type offset. Check if the slot is a PCIE slots. All
564          * PCIE slot type are hardcoded in a table.
565          */
566         if (pcieSmbiosType.find(*(dataIn + 5)) != pcieSmbiosType.end())
567         {
568             num++;
569         }
570         dataIn = smbiosNextPtr(dataIn);
571         if (dataIn == nullptr)
572         {
573             break;
574         }
575         if (num >= limitEntryLen)
576         {
577             break;
578         }
579     }
580 
581     return num;
582 }
583 
584 bool MDR_V2::agentSynchronizeData()
585 {
586     struct MDRSMBIOSHeader mdr2SMBIOS;
587     bool status = readDataFromFlash(&mdr2SMBIOS,
588                                     smbiosDir.dir[smbiosDirIndex].dataStorage);
589     if (!status)
590     {
591         phosphor::logging::log<phosphor::logging::level::ERR>(
592             "agent data sync failed - read data from flash failed");
593         return false;
594     }
595     else
596     {
597         systemInfoUpdate();
598         smbiosDir.dir[smbiosDirIndex].common.dataVersion = mdr2SMBIOS.dirVer;
599         smbiosDir.dir[smbiosDirIndex].common.timestamp = mdr2SMBIOS.timestamp;
600         smbiosDir.dir[smbiosDirIndex].common.size = mdr2SMBIOS.dataSize;
601         smbiosDir.dir[smbiosDirIndex].stage = MDR2SMBIOSStatusEnum::mdr2Loaded;
602         smbiosDir.dir[smbiosDirIndex].lock = MDR2DirLockEnum::mdr2DirUnlock;
603     }
604     return true;
605 }
606 
607 std::vector<uint32_t> MDR_V2::synchronizeDirectoryCommonData(uint8_t idIndex,
608                                                              uint32_t size)
609 {
610     std::chrono::microseconds usec(
611         defaultTimeout); // default lock time out is 2s
612     std::vector<uint32_t> result;
613     smbiosDir.dir[idIndex].common.size = size;
614     result.push_back(smbiosDir.dir[idIndex].common.dataSetSize);
615     result.push_back(smbiosDir.dir[idIndex].common.dataVersion);
616     result.push_back(smbiosDir.dir[idIndex].common.timestamp);
617 
618     timer.expires_after(usec);
619     timer.async_wait([this](boost::system::error_code ec) {
620         if (ec || this == nullptr)
621         {
622             phosphor::logging::log<phosphor::logging::level::ERR>(
623                 "Timer Error!");
624             return;
625         }
626         agentSynchronizeData();
627     });
628     return result;
629 }
630 
631 std::vector<boost::container::flat_map<std::string, RecordVariant>>
632     MDR_V2::getRecordType(size_t type)
633 {
634 
635     std::vector<boost::container::flat_map<std::string, RecordVariant>> ret;
636     if (type == memoryDeviceType)
637     {
638 
639         uint8_t* dataIn = smbiosDir.dir[smbiosDirIndex].dataStorage;
640 
641         if (dataIn == nullptr)
642         {
643             throw std::runtime_error("Data not populated");
644         }
645 
646         do
647         {
648             dataIn =
649                 getSMBIOSTypePtr(dataIn, memoryDeviceType, sizeof(MemoryInfo));
650             if (dataIn == nullptr)
651             {
652                 break;
653             }
654             boost::container::flat_map<std::string, RecordVariant>& record =
655                 ret.emplace_back();
656 
657             auto memoryInfo = reinterpret_cast<MemoryInfo*>(dataIn);
658 
659             record["Type"] = memoryInfo->type;
660             record["Length"] = memoryInfo->length;
661             record["Handle"] = uint16_t(memoryInfo->handle);
662             record["Physical Memory Array Handle"] =
663                 uint16_t(memoryInfo->phyArrayHandle);
664             record["Memory Error Information Handle"] =
665                 uint16_t(memoryInfo->errInfoHandle);
666             record["Total Width"] = uint16_t(memoryInfo->totalWidth);
667             record["Data Width"] = uint16_t(memoryInfo->dataWidth);
668             record["Size"] = uint16_t(memoryInfo->size);
669             record["Form Factor"] = memoryInfo->formFactor;
670             record["Device Set"] = memoryInfo->deviceSet;
671             record["Device Locator"] = positionToString(
672                 memoryInfo->deviceLocator, memoryInfo->length, dataIn);
673             record["Bank Locator"] = positionToString(
674                 memoryInfo->bankLocator, memoryInfo->length, dataIn);
675             record["Memory Type"] = memoryInfo->memoryType;
676             record["Type Detail"] = uint16_t(memoryInfo->typeDetail);
677             record["Speed"] = uint16_t(memoryInfo->speed);
678             record["Manufacturer"] = positionToString(
679                 memoryInfo->manufacturer, memoryInfo->length, dataIn);
680             record["Serial Number"] = positionToString(
681                 memoryInfo->serialNum, memoryInfo->length, dataIn);
682             record["Asset Tag"] = positionToString(memoryInfo->assetTag,
683                                                    memoryInfo->length, dataIn);
684             record["Part Number"] = positionToString(
685                 memoryInfo->partNum, memoryInfo->length, dataIn);
686             record["Attributes"] = memoryInfo->attributes;
687             record["Extended Size"] = uint32_t(memoryInfo->extendedSize);
688             record["Configured Memory Speed"] =
689                 uint32_t(memoryInfo->confClockSpeed);
690             record["Minimum voltage"] = uint16_t(memoryInfo->minimumVoltage);
691             record["Maximum voltage"] = uint16_t(memoryInfo->maximumVoltage);
692             record["Configured voltage"] =
693                 uint16_t(memoryInfo->configuredVoltage);
694             record["Memory Technology"] = memoryInfo->memoryTechnology;
695             record["Memory Operating Mode Capabilty"] =
696                 uint16_t(memoryInfo->memoryOperatingModeCap);
697             record["Firmare Version"] = memoryInfo->firwareVersion;
698             record["Module Manufacturer ID"] =
699                 uint16_t(memoryInfo->modelManufId);
700             record["Module Product ID"] = uint16_t(memoryInfo->modelProdId);
701             record["Memory Subsystem Controller Manufacturer ID"] =
702                 uint16_t(memoryInfo->memSubConManufId);
703             record["Memory Subsystem Controller Product Id"] =
704                 uint16_t(memoryInfo->memSubConProdId);
705             record["Non-volatile Size"] = uint64_t(memoryInfo->nvSize);
706             record["Volatile Size"] = uint64_t(memoryInfo->volatileSize);
707             record["Cache Size"] = uint64_t(memoryInfo->cacheSize);
708             record["Logical Size"] = uint64_t(memoryInfo->logicalSize);
709         } while ((dataIn = smbiosNextPtr(dataIn)) != nullptr);
710 
711         return ret;
712     }
713 
714     throw std::invalid_argument("Invalid record type");
715     return ret;
716 }
717 
718 } // namespace smbios
719 } // namespace phosphor
720