Skip to content

Commit 879aead

Browse files
committed
[roc-status] Add PON RX power
1 parent 9a19b2d commit 879aead

File tree

10 files changed

+44
-5
lines changed

10 files changed

+44
-5
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,7 @@ metric format for the CRORC and the CRU is different, as different parameters ar
600600
| `"mgtTxPllLocked"` | 0/1 (False/True) | int |
601601
| `"mgtRxPllLocked"` | 0/1 (False/True) | int |
602602
| `"ponQualityStatus"` | 0/1 (Bad/Good) | int |
603+
| `"ponRxPower"` | dBm | int |
603604
604605
| Tag key | Value |
605606
| --------------------- | --------------------- |

src/CommandLineUtilities/ProgramStatus.cxx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ class ProgramStatus : public Program
272272
.addValue(onuStatus.mgtTxPllLocked, "mgtTxPllLocked")
273273
.addValue(onuStatus.mgtRxPllLocked, "mgtRxPllLocked")
274274
.addValue(onuStatus.ponQualityStatus, "ponQualityStatus")
275+
.addValue(onuStatus.ponRxPower, "ponRxPower")
275276
.addTag(tags::Key::SerialId, card.serialId.getSerial())
276277
.addTag(tags::Key::Endpoint, card.serialId.getEndpoint())
277278
.addTag(tags::Key::ID, card.sequenceId)
@@ -289,6 +290,7 @@ class ProgramStatus : public Program
289290
root.put("ONU MGT RX PLL locked", onuStatus.mgtRxPllLocked);
290291
root.put("PON quality", Utilities::toHexString(onuStatus.ponQuality));
291292
root.put("PON quality Status", ponQualityStatusStr);
293+
root.put("PON RX power (dBm)", onuStatus.ponRxPower);
292294
} else {
293295
std::cout << "=============================" << std::endl;
294296
std::cout << "ONU status: \t\t" << onuStickyStatus << std::endl;
@@ -304,6 +306,7 @@ class ProgramStatus : public Program
304306
std::cout << "ONU MGT RX PLL locked: \t" << std::boolalpha << onuStatus.mgtRxPllLocked << std::endl;
305307
std::cout << "PON quality: \t\t0x" << std::hex << onuStatus.ponQuality << std::endl;
306308
std::cout << "PON quality status: \t" << ponQualityStatusStr << std::endl;
309+
std::cout << "PON RX power (dBm): \t" << onuStatus.ponRxPower << std::endl;
307310
}
308311
}
309312

src/Cru/Common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ struct OnuStatus {
114114
LinkStatus stickyBit;
115115
uint32_t ponQuality;
116116
int ponQualityStatus;
117+
double ponRxPower;
117118
};
118119

119120
struct FecStatus {

src/Cru/Constants.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ static constexpr Register DDG_CTRL2(0x00d00004);
164164
/// Register to control BSP
165165
static constexpr Register BSP_USER_CONTROL(0x00000018);
166166

167+
/// Register to access I2C SFP information
168+
static constexpr Register BSP_I2C_SFP_1(0x00030200);
169+
167170
/// Register to access I2C minipod information
168171
static constexpr Register BSP_I2C_MINIPODS(0x00030300);
169172

src/Cru/CruBar.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ Cru::ReportInfo CruBar::report(bool forConfig)
498498
// Update the link map with optical power information through I2C
499499
I2c i2c = I2c(Cru::Registers::BSP_I2C_MINIPODS.address, 0x0, mPdaBar, mEndpoint);
500500

501-
// lock I2C operation
501+
// lock I2C operations
502502
std::unique_ptr<Interprocess::Lock> i2cLock = std::make_unique<Interprocess::Lock>("_Alice_O2_RoC_I2C_" + std::to_string(mSerial) + "_lock", true);
503503
i2c.getOpticalPower(linkMap);
504504
i2cLock.reset();
@@ -1061,7 +1061,7 @@ void CruBar::patternPlayer(PatternPlayer::Info info)
10611061

10621062
Cru::OnuStatus CruBar::reportOnuStatus()
10631063
{
1064-
Ttc ttc = Ttc(mPdaBar, mSerial);
1064+
Ttc ttc = Ttc(mPdaBar, mSerial, mEndpoint);
10651065
return ttc.onuStatus();
10661066
}
10671067

src/Cru/I2c.cxx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,5 +241,19 @@ void I2c::getOpticalPower(std::map<int, Link>& linkMap)
241241
return;
242242
}
243243

244+
double I2c::getRxPower()
245+
{
246+
resetI2c();
247+
uint32_t address = 0x68;
248+
uint32_t rxPower = readI2c(address) << 8;
249+
rxPower |= readI2c(address + 1); // unit: 0.1*uW
250+
if (rxPower) {
251+
double watts = rxPower * 0.1 * 1e-6;
252+
return 10 * log10(watts / 1e-3); // convert to dBm
253+
} else {
254+
return -1 * std::numeric_limits<double>::infinity();
255+
}
256+
}
257+
244258
} // namespace roc
245259
} // namespace AliceO2

src/Cru/I2c.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class I2c
4141
void configurePll();
4242
uint32_t getSelectedClock();
4343
void getOpticalPower(std::map<int, Link>& linkMap);
44+
double getRxPower(); //unit: dBm
4445
uint32_t readI2c(uint32_t address);
4546

4647
private:

src/Cru/Ttc.cxx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ using LinkStatus = Cru::LinkStatus;
3333
using OnuStatus = Cru::OnuStatus;
3434
using FecStatus = Cru::FecStatus;
3535

36-
Ttc::Ttc(std::shared_ptr<BarInterface> bar, int serial) : mBar(bar), mSerial(serial)
36+
Ttc::Ttc(std::shared_ptr<BarInterface> bar, int serial, int endpoint) : mBar(bar), mSerial(serial), mEndpoint(endpoint)
3737
{
3838
}
3939

@@ -177,7 +177,8 @@ OnuStatus Ttc::onuStatus()
177177
(calStatus >> 7 & 0x1) == 1,
178178
getOnuStickyBit(),
179179
getPonQuality(),
180-
getPonQualityStatus()
180+
getPonQualityStatus(),
181+
getPonRxPower()
181182
};
182183
}
183184

@@ -429,6 +430,18 @@ int Ttc::getPonQualityStatus()
429430
return 0; // BAD
430431
}
431432

433+
double Ttc::getPonRxPower()
434+
{
435+
I2c i2c = I2c(Cru::Registers::BSP_I2C_SFP_1.address, 0x51, mBar, mEndpoint);
436+
437+
// lock I2C operations
438+
std::unique_ptr<Interprocess::Lock> i2cLock = std::make_unique<Interprocess::Lock>("_Alice_O2_RoC_I2C_" + std::to_string(mSerial) + "_lock", true);
439+
auto rxPower = i2c.getRxPower();
440+
i2cLock.reset();
441+
442+
return rxPower;
443+
}
444+
432445
// Currently unused by RoC
433446
/*void Ttc::atxref(uint32_t refClock)
434447
{

src/Cru/Ttc.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Ttc
2222
using LinkStatus = Cru::LinkStatus;
2323

2424
public:
25-
Ttc(std::shared_ptr<BarInterface> bar, int serial = -1);
25+
Ttc(std::shared_ptr<BarInterface> bar, int serial = -1, int endpoint = -1);
2626

2727
void calibrateTtc();
2828
void setClock(uint32_t clock);
@@ -60,11 +60,13 @@ class Ttc
6060
LinkStatus getOnuStickyBit();
6161
uint32_t getPonQuality();
6262
int getPonQualityStatus();
63+
double getPonRxPower();
6364

6465
std::shared_ptr<BarInterface> mBar;
6566
std::unique_ptr<Interprocess::Lock> mI2cLock;
6667

6768
int mSerial;
69+
int mEndpoint;
6870
static constexpr uint32_t MAX_BCID = 3564 - 1;
6971
};
7072
} // namespace roc

src/Cru/cru_constants_populate.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@
106106
'add_gbt_bank_fpll':'GBT_BANK_FPLL',
107107
'add_bsp_i2c_eeprom':"BSP_I2C_EEPROM",
108108
'add_bsp_i2c_minipods':"BSP_I2C_MINIPODS",
109+
'add_bsp_i2c_sfp1':"BSP_I2C_SFP_1",
109110
'add_bsp_i2c_si5345_1':'SI5345_1',
110111
'add_bsp_i2c_si5345_2':'SI5345_2',
111112
'add_bsp_i2c_si5344':'SI5344',

0 commit comments

Comments
 (0)