Skip to content

Commit d803ecb

Browse files
Proc data corruption defect
Signed-off-by: Sunny Srivastava <[email protected]>
1 parent 4209d41 commit d803ecb

File tree

5 files changed

+55
-5
lines changed

5 files changed

+55
-5
lines changed

ibm_vpd_app.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <iterator>
2828
#include <regex>
2929
#include <thread>
30+
#include <chrono>
3031

3132
using namespace std;
3233
using namespace openpower::vpd;
@@ -932,8 +933,9 @@ std::variant<KeywordVpdMap, openpower::vpd::Store>
932933
break;
933934
}
934935
}
935-
936+
executeCmd("hexdump -C -s 196608 -n 1024 /sys/bus/spi/drivers/at25/spi42.0/eeprom > /tmp/spi42_beforeGetDataInVector.txt");
936937
Binary vpdVector = getVpdDataInVector(js, vpdFilePath);
938+
executeCmd("hexdump -C -s 196608 -n 1024 /sys/bus/spi/drivers/at25/spi42.0/eeprom > /tmp/spi42_afterGetDataInVector.txt");
937939

938940
ParserInterface* parser = ParserFactory::getParser(
939941
vpdVector,
@@ -998,6 +1000,7 @@ void updateVpdDataOnHw(const std::string& vpdFilePath, nlohmann::json& js,
9981000
const std::string& recName, const std::string& kwName,
9991001
const Binary& kwdData)
10001002
{
1003+
std::cout<<"test_ updateVpdDataOnHw called "<<std::endl;
10011004
const std::string& fruInvPath =
10021005
js["frus"][vpdFilePath][0]["inventoryPath"]
10031006
.get_ref<const nlohmann::json::string_t&>();
@@ -1034,6 +1037,7 @@ void updateVpdDataOnHw(const std::string& vpdFilePath, nlohmann::json& js,
10341037
void restoreSystemVPD(Parsed& vpdMap, const string& objectPath,
10351038
nlohmann::json& js, bool isBackupOnCache = true)
10361039
{
1040+
std::cout<<"Restore system VPD called"<<std::endl;
10371041
std::string systemVpdBackupPath{};
10381042
std::string backupVpdInvPath{};
10391043
Parsed backupVpdMap{};
@@ -1207,6 +1211,7 @@ void restoreSystemVPD(Parsed& vpdMap, const string& objectPath,
12071211
// to the cache & hardware in the same code path.
12081212
if (!isBackupOnCache)
12091213
{
1214+
std::cout<<"test_ Back up is not on cache"<<std::endl;
12101215
// copy backup VPD on to system backplane
12111216
// EEPROM file.
12121217
updateVpdDataOnHw(systemVpdFilePath, js, recordName,
@@ -1235,6 +1240,7 @@ void restoreSystemVPD(Parsed& vpdMap, const string& objectPath,
12351240
else if ((kwdDataInBinary != defaultValue) &&
12361241
(!isBackupOnCache))
12371242
{
1243+
std::cout<<"test_ BAck up and restore 2"<<std::endl;
12381244
// update primary VPD on to backup VPD file
12391245
updateVpdDataOnHw(systemVpdBackupPath, js,
12401246
backupVpdRecName, backupVpdKwName,
@@ -1739,6 +1745,8 @@ int main(int argc, char** argv)
17391745
isSystemVpd = true;
17401746
}
17411747

1748+
std::cout<<"test_ file path being processed is ="<<file<<std::endl;
1749+
17421750
// Check if input file is not empty.
17431751
if ((file.empty()) || (driver.empty()))
17441752
{
@@ -1866,14 +1874,20 @@ int main(int argc, char** argv)
18661874
if (!needsRecollection(js, file))
18671875
{
18681876
std::cout << "Skip VPD recollection for: " << file << std::endl;
1869-
return 0;
1877+
// return 0;
18701878
}
18711879

18721880
try
18731881
{
1882+
executeCmd("hexdump -C -s 196608 -n 1024 /sys/bus/spi/drivers/at25/spi42.0/eeprom > /tmp/spi42_beforeParse.txt");
18741883
variant<KeywordVpdMap, Store> parseResult;
18751884
parseResult = parseVpdFile(file, js);
18761885

1886+
std::cout<<"test_ parsing done, sleeping for 10s to check file content"<<std::endl;
1887+
executeCmd("hexdump -C -s 196608 -n 1024 /sys/bus/spi/drivers/at25/spi42.0/eeprom > /tmp/spi42_afterParse.txt");
1888+
using namespace std::chrono_literals;
1889+
std::this_thread::sleep_for(10s);
1890+
18771891
if (isSystemVpd)
18781892
{
18791893
// Get the value of systemVpdBackupPath field from json

impl.cpp

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ RecordOffset Impl::getVtocOffset() const
7676
#ifdef IPZ_PARSER
7777
int Impl::vhdrEccCheck()
7878
{
79+
executeCmd("hexdump -C -s 196608 -n 1024 /sys/bus/spi/drivers/at25/spi42.0/eeprom > /tmp/spi42_beforeHDRECC_IPZ.txt");
7980
int rc = eccStatus::SUCCESS;
8081
auto vpdPtr = vpd.cbegin();
8182

@@ -88,13 +89,17 @@ int Impl::vhdrEccCheck()
8889
{
8990
try
9091
{
92+
std::cout<<"Correction HDR ERR"<<std::endl;
93+
vpdFileStream.open(vpdFilePath,
94+
std::ios::in | std::ios::out | std::ios::binary);
9195
if (vpdFileStream.is_open())
9296
{
9397
vpdFileStream.seekp(vpdStartOffset + offsets::VHDR_RECORD,
9498
std::ios::beg);
9599
vpdFileStream.write(
96100
reinterpret_cast<const char*>(&vpd[offsets::VHDR_RECORD]),
97101
lengths::VHDR_RECORD_LENGTH);
102+
vpdFileStream.close();
98103
}
99104
else
100105
{
@@ -113,12 +118,14 @@ int Impl::vhdrEccCheck()
113118
{
114119
rc = eccStatus::FAILED;
115120
}
121+
executeCmd("hexdump -C -s 196608 -n 1024 /sys/bus/spi/drivers/at25/spi42.0/eeprom > /tmp/spi42_afterHRDECC_IPZ.txt");
116122

117123
return rc;
118124
}
119125

120126
int Impl::vtocEccCheck()
121127
{
128+
executeCmd("hexdump -C -s 196608 -n 1024 /sys/bus/spi/drivers/at25/spi42.0/eeprom > /tmp/spi42_beforeTOCECC_IPZ.txt");
122129
int rc = eccStatus::SUCCESS;
123130
// Use another pointer to get ECC information from VHDR,
124131
// actual pointer is pointing to VTOC data
@@ -150,12 +157,17 @@ int Impl::vtocEccCheck()
150157
{
151158
try
152159
{
160+
std::cout<<"Correction TOC ERR"<<std::endl;
161+
vpdFileStream.open(vpdFilePath,
162+
std::ios::in | std::ios::out | std::ios::binary);
163+
153164
if (vpdFileStream.is_open())
154165
{
155166
vpdFileStream.seekp(vpdStartOffset + vtocOffset, std::ios::beg);
156167
vpdFileStream.write(
157168
reinterpret_cast<const char*>(&vpdPtr[vtocOffset]),
158169
vtocLength);
170+
vpdFileStream.close();
159171
}
160172
else
161173
{
@@ -174,7 +186,7 @@ int Impl::vtocEccCheck()
174186
{
175187
rc = eccStatus::FAILED;
176188
}
177-
189+
executeCmd("hexdump -C -s 196608 -n 1024 /sys/bus/spi/drivers/at25/spi42.0/eeprom > /tmp/spi42_afterTOCECC_IPZ.txt");
178190
return rc;
179191
}
180192

@@ -214,13 +226,19 @@ int Impl::recordEccCheck(Binary::const_iterator iterator)
214226
{
215227
try
216228
{
229+
std::cout<<"Correction REC ERR"<<std::endl;
230+
vpdFileStream.open(vpdFilePath,
231+
std::ios::in | std::ios::out | std::ios::binary);
232+
217233
if (vpdFileStream.is_open())
218234
{
219235
vpdFileStream.seekp(vpdStartOffset + recordOffset,
220236
std::ios::beg);
221237
vpdFileStream.write(
222238
reinterpret_cast<const char*>(&vpdPtr[recordOffset]),
223239
recordLength);
240+
241+
vpdFileStream.close();
224242
}
225243
else
226244
{
@@ -246,6 +264,7 @@ int Impl::recordEccCheck(Binary::const_iterator iterator)
246264

247265
void Impl::checkHeader()
248266
{
267+
executeCmd("hexdump -C -s 196608 -n 1024 /sys/bus/spi/drivers/at25/spi42.0/eeprom > /tmp/spi42_beforeCheckHeader_IPZ.txt");
249268
if (vpd.empty() || (lengths::RECORD_MIN > vpd.size()))
250269
{
251270
throw(VpdDataException("Malformed VPD"));
@@ -271,10 +290,12 @@ void Impl::checkHeader()
271290
}
272291
#endif
273292
}
293+
executeCmd("hexdump -C -s 196608 -n 1024 /sys/bus/spi/drivers/at25/spi42.0/eeprom > /tmp/spi42_afterCheckHeader_IPZ.txt");
274294
}
275295

276296
std::size_t Impl::readTOC(Binary::const_iterator& iterator)
277297
{
298+
executeCmd("hexdump -C -s 196608 -n 1024 /sys/bus/spi/drivers/at25/spi42.0/eeprom > /tmp/spi42_beforeReadTOC_IPZ.txt");
278299
// The offset to VTOC could be 1 or 2 bytes long
279300
RecordOffset vtocOffset = getVtocOffset();
280301

@@ -310,6 +331,7 @@ std::size_t Impl::readTOC(Binary::const_iterator& iterator)
310331
std::size_t ptLen = *iterator;
311332
// Skip past PT size
312333
std::advance(iterator, sizeof(KwSize));
334+
executeCmd("hexdump -C -s 196608 -n 1024 /sys/bus/spi/drivers/at25/spi42.0/eeprom > /tmp/spi42_afterReadTOC_IPZ.txt");
313335

314336
// length of PT keyword
315337
return ptLen;
@@ -318,6 +340,7 @@ std::size_t Impl::readTOC(Binary::const_iterator& iterator)
318340
internal::OffsetList Impl::readPT(Binary::const_iterator iterator,
319341
std::size_t ptLength)
320342
{
343+
executeCmd("hexdump -C -s 196608 -n 1024 /sys/bus/spi/drivers/at25/spi42.0/eeprom > /tmp/spi42_beforeReadPT_IPZ.txt");
321344
internal::OffsetList offsets{};
322345

323346
auto end = iterator;
@@ -380,11 +403,13 @@ internal::OffsetList Impl::readPT(Binary::const_iterator iterator,
380403
sizeof(ECCOffset) + sizeof(ECCLength));
381404
}
382405

406+
executeCmd("hexdump -C -s 196608 -n 1024 /sys/bus/spi/drivers/at25/spi42.0/eeprom > /tmp/spi42_afterReadPT_IPZ.txt");
383407
return offsets;
384408
}
385409

386410
void Impl::processRecord(std::size_t recordOffset)
387411
{
412+
executeCmd("hexdump -C -s 196608 -n 1024 /sys/bus/spi/drivers/at25/spi42.0/eeprom > /tmp/spi42_beforeProcessRecord_IPZ.txt");
388413
// Jump to record name
389414
auto nameOffset = recordOffset + sizeof(RecordId) + sizeof(RecordSize) +
390415
// Skip past the RT keyword, which contains
@@ -415,6 +440,8 @@ void Impl::processRecord(std::size_t recordOffset)
415440
// to the parsed vpd output.
416441
out.emplace(std::move(name), std::move(kwMap));
417442

443+
executeCmd("hexdump -C -s 196608 -n 1024 /sys/bus/spi/drivers/at25/spi42.0/eeprom > /tmp/spi42_afterProcessRecord_IPZ.txt");
444+
418445
#ifndef IPZ_PARSER
419446
}
420447
#endif
@@ -518,6 +545,7 @@ std::string Impl::readKwData(const internal::KeywordInfo& keyword,
518545

519546
internal::KeywordMap Impl::readKeywords(Binary::const_iterator iterator)
520547
{
548+
executeCmd("hexdump -C -s 196608 -n 1024 /sys/bus/spi/drivers/at25/spi42.0/eeprom > /tmp/spi42_beforeReadKWD_IPZ.txt");
521549
internal::KeywordMap map{};
522550
while (true)
523551
{
@@ -576,6 +604,8 @@ internal::KeywordMap Impl::readKeywords(Binary::const_iterator iterator)
576604
std::advance(iterator, length);
577605
}
578606

607+
executeCmd("hexdump -C -s 196608 -n 1024 /sys/bus/spi/drivers/at25/spi42.0/eeprom > /tmp/spi42_afterReadKWD_IPZ.txt");
608+
579609
return map;
580610
}
581611

@@ -596,6 +626,8 @@ Store Impl::run()
596626
{
597627
processRecord(offset);
598628
}
629+
630+
599631
// Return a Store object, which has interfaces to
600632
// access parsed VPD by record:keyword
601633
return Store(std::move(out));

impl.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,10 @@ class Impl
8484
#endif
8585
try
8686
{
87-
vpdFileStream.open(vpdFilePath,
88-
std::ios::in | std::ios::out | std::ios::binary);
87+
executeCmd("hexdump -C -s 196608 -n 1024 /sys/bus/spi/drivers/at25/spi42.0/eeprom > /tmp/spi42_beforeOpeningStream_IPZ.txt");
88+
/* vpdFileStream.open(vpdFilePath,
89+
std::ios::in | std::ios::out | std::ios::binary);*/
90+
executeCmd("hexdump -C -s 196608 -n 1024 /sys/bus/spi/drivers/at25/spi42.0/eeprom > /tmp/spi42_afterOpeningStream_IPZ.txt");
8991
}
9092
catch (const std::fstream::failure& fail)
9193
{

vpd-manager/editor_impl.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,7 @@ static void disableRebootGuard()
593593
void EditorImpl::updateKeyword(const Binary& kwdData, uint32_t offset,
594594
const bool& updCache)
595595
{
596+
std::cout<<"test_ editor update keyword called"<<std::endl;
596597
try
597598
{
598599
startOffset = offset;

vpd-parser/ipz_parser.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ std::variant<kwdVpdMap, Store> IpzVpdParser::parse()
1717
{
1818
Impl p(vpd, inventoryPath, vpdFilePath, vpdStartOffset);
1919
Store s = p.run();
20+
executeCmd("hexdump -C -s 196608 -n 1024 /sys/bus/spi/drivers/at25/spi42.0/eeprom > /tmp/spi42_afterallParsingDone_IPZ.txt");
2021
return s;
2122
}
2223

0 commit comments

Comments
 (0)