@@ -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.
311335FirmwareFeatures 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" );
0 commit comments