Skip to content

Commit 2a374a8

Browse files
committed
Take PON upstream & ONU address in account for reconfiguring
1 parent cc6c484 commit 2a374a8

File tree

3 files changed

+35
-5
lines changed

3 files changed

+35
-5
lines changed

src/Cru/Common.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ struct ReportInfo {
6464
std::map<int, Link> linkMap;
6565
uint32_t ttcClock;
6666
uint32_t downstreamData;
67+
uint32_t ponStatusRegister;
68+
uint32_t onuAddress;
6769
};
6870

6971
uint32_t getWrapperBaseAddress(int wrapper);

src/Cru/CruBar.cxx

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,30 @@ uint32_t CruBar::getFpgaChipLow()
307307
return readRegister(Cru::Registers::FPGA_CHIP_LOW.index);
308308
}
309309

310+
uint32_t CruBar::getPonStatusRegister()
311+
{
312+
assertBarIndex(2, "Can only get PON status register from BAR 2");
313+
return readRegister((Cru::Registers::ONU_USER_LOGIC.address + 0x0c)/4);
314+
}
315+
316+
uint32_t CruBar::getOnuAddress()
317+
{
318+
assertBarIndex(2, "Can only get PON status register from BAR 2");
319+
return readRegister(Cru::Registers::ONU_USER_LOGIC.index) >> 1;
320+
}
321+
322+
bool CruBar::checkPonUpstreamStatusExpected(uint32_t ponUpstreamRegister, uint32_t onuAddress)
323+
{
324+
if (!mPonUpstream) { //no need to check if ponUpstream is disabled
325+
return true;
326+
} else if ((ponUpstreamRegister == 0xff || ponUpstreamRegister == 0xf7) && (mOnuAddress == onuAddress)) {
327+
//ponUpstream should be 0b11110111 or 0b11111111
328+
//onuAddress should be the same as requested
329+
return true;
330+
} else {
331+
return false;
332+
}
333+
}
310334
/// Get the enabled features for the card's firmware.
311335
FirmwareFeatures CruBar::parseFirmwareFeatures()
312336
{
@@ -427,15 +451,15 @@ Cru::ReportInfo CruBar::report()
427451
// setClock: 2 for Local clock, 0 for TTC clock
428452
uint32_t clock = (ttc.getPllClock() == 0 ? Clock::Local : Clock::Ttc);
429453
uint32_t downstreamData = ttc.getDownstreamData();
430-
//bool ponUpstream = true; //TODO: ponUpstream currently irrelevant for configuration
431-
//uint32_t onuAddress = 0xdeadbeef; //TODO: onuAddress currently irrelevant for configuration
454+
uint32_t ponStatusRegister = getPonStatusRegister();
455+
uint32_t onuAddress = getOnuAddress();
432456

433457
Cru::ReportInfo reportInfo = {
434458
linkMap,
435459
clock,
436460
downstreamData,
437-
//ponUpstream
438-
//onuAddress
461+
ponStatusRegister,
462+
onuAddress
439463
};
440464

441465
return reportInfo;
@@ -450,7 +474,8 @@ void CruBar::reconfigure()
450474

451475
if (static_cast<uint32_t>(mClock) == reportInfo.ttcClock &&
452476
static_cast<uint32_t>(mDownstreamData) == reportInfo.downstreamData &&
453-
std::equal(mLinkMap.begin(), mLinkMap.end(), reportInfo.linkMap.begin())) {
477+
std::equal(mLinkMap.begin(), mLinkMap.end(), reportInfo.linkMap.begin()) &&
478+
checkPonUpstreamStatusExpected(reportInfo.ponStatusRegister, reportInfo.onuAddress)){
454479
log("No need to reconfigure further");
455480
} else {
456481
log("Reconfiguring");

src/Cru/CruBar.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ class CruBar final : public BarInterfaceBase
103103
uint32_t getFirmwareTime();
104104
uint32_t getFpgaChipHigh();
105105
uint32_t getFpgaChipLow();
106+
uint32_t getPonStatusRegister();
107+
uint32_t getOnuAddress();
108+
bool checkPonUpstreamStatusExpected(uint32_t ponUpstreamRegister, uint32_t onuAddress);
106109
std::map<int, Link> initializeLinkMap();
107110
void populateLinkMap(std::map<int, Link> &linkMap);
108111

0 commit comments

Comments
 (0)