Skip to content

Commit c8301df

Browse files
committed
[status] Report ONU status sticky bit
1 parent 13fcbda commit c8301df

File tree

8 files changed

+87
-49
lines changed

8 files changed

+87
-49
lines changed

README.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -481,17 +481,18 @@ metric format for the CRORC and the CRU is different, as different parameters ar
481481
482482
###### Metric: `"onu"`
483483
484-
| Value name | Value | Type |
485-
| -------------------| -----------------| ------ |
486-
| `"onuAddress"` | ONU Address | string |
487-
| `"rx40Locked"` | 0/1 (False/True) | int |
488-
| `"phaseGood"` | 0/1 (False/True) | int |
489-
| `"rxLocked"` | 0/1 (False/True) | int |
490-
| `"operational"` | 0/1 (False/True) | int |
491-
| `"mgtTxReady"` | 0/1 (False/True) | int |
492-
| `"mgtRxReady"` | 0/1 (False/True) | int |
493-
| `"mgtTxPllLocked"` | 0/1 (False/True) | int |
494-
| `"mgtRxPllLocked"` | 0/1 (False/True) | int |
484+
| Value name | Value | Type |
485+
| -------------------| --------------------------- | ------ |
486+
| `"onuStatus"` | 0/1/2 (DOWN/UP/UP was DOWN) | int |
487+
| `"onuAddress"` | ONU Address | string |
488+
| `"rx40Locked"` | 0/1 (False/True) | int |
489+
| `"phaseGood"` | 0/1 (False/True) | int |
490+
| `"rxLocked"` | 0/1 (False/True) | int |
491+
| `"operational"` | 0/1 (False/True) | int |
492+
| `"mgtTxReady"` | 0/1 (False/True) | int |
493+
| `"mgtRxReady"` | 0/1 (False/True) | int |
494+
| `"mgtTxPllLocked"` | 0/1 (False/True) | int |
495+
| `"mgtRxPllLocked"` | 0/1 (False/True) | int |
495496
496497
497498
###### Metric: `"link"`

src/CommandLineUtilities/ProgramStatus.cxx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,19 @@ class ProgramStatus : public Program
237237
/* ONU PARAMETERS */
238238
if (mOptions.onu) {
239239
Cru::OnuStatus onuStatus = cruBar2->reportOnuStatus();
240+
std::string onuStickyStatus;
241+
242+
if (onuStatus.stickyBit == Cru::LinkStatus::Up) {
243+
onuStickyStatus = "UP";
244+
} else if (onuStatus.stickyBit == Cru::LinkStatus::UpWasDown) {
245+
onuStickyStatus = "UP (was DOWN)";
246+
} else if (onuStatus.stickyBit == Cru::LinkStatus::Down) {
247+
onuStickyStatus = "DOWN";
248+
}
240249

241250
if (mOptions.monitoring) {
242251
monitoring->send(Metric{ "onu" }
252+
.addValue(onuStickyStatus, "onuStickyStatus")
243253
.addValue(std::to_string(onuStatus.onuAddress), "onuAddress")
244254
.addValue(onuStatus.rx40Locked, "rx40Locked")
245255
.addValue(onuStatus.phaseGood, "phaseGood")
@@ -250,6 +260,7 @@ class ProgramStatus : public Program
250260
.addValue(onuStatus.mgtTxPllLocked, "mgtTxPllLocked")
251261
.addValue(onuStatus.mgtRxPllLocked, "mgtRxPllLocked"));
252262
} else if (mOptions.jsonOut) {
263+
root.put("ONU status", onuStickyStatus);
253264
root.put("ONU address", onuStatus.onuAddress);
254265
root.put("ONU RX40 locked", onuStatus.rx40Locked);
255266
root.put("ONU phase good", onuStatus.phaseGood);
@@ -261,6 +272,7 @@ class ProgramStatus : public Program
261272
root.put("ONU MGT RX PLL locked", onuStatus.mgtRxPllLocked);
262273
} else {
263274
std::cout << "=============================" << std::endl;
275+
std::cout << "ONU status: \t\t" << onuStickyStatus << std::endl;
264276
std::cout << "ONU address: \t\t0x" << std::hex << onuStatus.onuAddress << std::endl;
265277
std::cout << "-----------------------------" << std::endl;
266278
std::cout << "ONU RX40 locked: \t" << std::boolalpha << onuStatus.rx40Locked << std::endl;

src/Cru/Common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ struct OnuStatus {
105105
bool mgtRxReady;
106106
bool mgtTxPllLocked;
107107
bool mgtRxPllLocked;
108+
LinkStatus stickyBit;
108109
};
109110

110111
struct LinkPacketInfo {

src/Cru/Constants.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ static constexpr Register LOCK_CLOCK_TO_REF(0x00220000);
181181

182182
/// Register for modifying TTC parameters (CLOCK_/DATA_)
183183
static constexpr Register TTC_DATA(0x00200000);
184+
static constexpr Register TTC_ONU_STICKY(0x00200014);
184185
/*static constexpr uint32_t CLOCK_TTC(0x0);
185186
static constexpr uint32_t CLOCK_LOCAL(0x2);
186187
static constexpr uint32_t DATA_CTP(0x0);

src/Cru/Ttc.cxx

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ namespace AliceO2
2828
namespace roc
2929
{
3030

31+
using LinkStatus = Cru::LinkStatus;
32+
using OnuStatus = Cru::OnuStatus;
33+
3134
Ttc::Ttc(std::shared_ptr<BarInterface> bar) : mBar(bar)
3235
{
3336
}
@@ -137,7 +140,22 @@ bool Ttc::configurePonTx(uint32_t onuAddress)
137140
//TODO: Show calibration status..
138141
}
139142

140-
Cru::OnuStatus Ttc::onuStatus()
143+
LinkStatus Ttc::getOnuStickyBit()
144+
{
145+
uint32_t was = mBar->readRegister(Cru::Registers::TTC_ONU_STICKY.index);
146+
mBar->modifyRegister(Cru::Registers::TTC_DATA.index, 28, 1, 0x1);
147+
mBar->modifyRegister(Cru::Registers::TTC_DATA.index, 28, 1, 0x0);
148+
uint32_t is = mBar->readRegister(Cru::Registers::TTC_ONU_STICKY.index);
149+
150+
if (was == 1 && is == 1) {
151+
return LinkStatus::Up;
152+
} else if (was == 0 && is == 1) {
153+
return LinkStatus::UpWasDown;
154+
}
155+
return LinkStatus::Down;
156+
}
157+
158+
OnuStatus Ttc::onuStatus()
141159
{
142160
uint32_t calStatus = mBar->readRegister(Cru::Registers::ONU_USER_LOGIC.index + 0xc / 4);
143161
uint32_t onuAddress = mBar->readRegister(Cru::Registers::ONU_USER_LOGIC.index) >> 1;
@@ -151,7 +169,8 @@ Cru::OnuStatus Ttc::onuStatus()
151169
calStatus >> 4 & 0x1,
152170
calStatus >> 5 & 0x1,
153171
calStatus >> 6 & 0x1,
154-
calStatus >> 7 & 0x1
172+
calStatus >> 7 & 0x1,
173+
getOnuStickyBit()
155174
};
156175

157176
return onuStatus;

src/Cru/Ttc.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ namespace roc
1616

1717
class Ttc
1818
{
19+
using OnuStatus = Cru::OnuStatus;
20+
using LinkStatus = Cru::LinkStatus;
21+
1922
public:
2023
Ttc(std::shared_ptr<BarInterface> bar);
2124

@@ -41,11 +44,13 @@ class Ttc
4144
void setEmulatorHCDIV(uint32_t hcdiv);
4245
void setFixedBCTrigger(std::vector<uint32_t> FBCTVector);
4346

44-
Cru::OnuStatus onuStatus();
47+
OnuStatus onuStatus();
4548

4649
private:
4750
void configurePlls(uint32_t clock);
4851
void setRefGen(int frequency = 240);
52+
LinkStatus getOnuStickyBit();
53+
4954
std::shared_ptr<BarInterface> mBar;
5055

5156
static constexpr uint32_t MAX_BCID = 3564 - 1;

src/Cru/cru_constants_populate.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
'add_ttc_clkgen_clkctrl':'CLOCK_CONTROL',
2828
'add_ttc_data_ctrl':'TTC_DATA',
2929
'add_ttc_onu_ctrl':'LOCK_CLOCK_TO_REF',
30+
'add_ttc_onuerror_sticky':'TTC_ONU_STICKY',
3031
'add_ctp_emu_runmode':'CTP_EMU_RUNMODE',
3132
'add_ctp_emu_ctrl':'CTP_EMU_CTRL',
3233
'add_ctp_emu_bc_max':'CTP_EMU_BCMAX',

src/Cru/pack_cru_core.vhd

Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ package pack_cru_core is
1313

1414
-- type declaration
1515
type Array2bit is array(natural range <>) of std_logic_vector(1 downto 0);
16+
type Array3bit is array(natural range <>) of std_logic_vector(2 downto 0);
1617
type Array4bit is array(natural range <>) of std_logic_vector(3 downto 0);
1718
type Array8bit is array(natural range <>) of std_logic_vector(7 downto 0);
1819
type Array16bit is array(natural range <>) of std_logic_vector(15 downto 0);
@@ -74,22 +75,34 @@ type t_cru_gbt_array is array (natural range <>) of t_cru_gbt;
7475
constant c_GBT : std_logic_vector(11 downto 0) := x"B69"; -- x"47_42_54"
7576
constant c_TRD : std_logic_vector(11 downto 0) := x"978"; -- x"54_52_44"
7677

78+
--------------------------------------------------------------------------------
79+
-- CRU BASE ADD
80+
--------------------------------------------------------------------------------
81+
constant add_bsp : unsigned(31 downto 0):=X"0000_0000";
82+
constant add_ro_protocol_base : unsigned(31 downto 0):=X"0010_0000";
83+
constant add_ttc_pon : unsigned(31 downto 0):=X"0020_0000";
84+
constant add_gbt_wrapper0 : unsigned(31 downto 0):=X"0040_0000";
85+
constant add_gbt_wrapper1 : unsigned(31 downto 0):=X"0050_0000";
86+
constant add_base_datapathwrapper0 : unsigned(31 downto 0):=X"0060_0000";
87+
constant add_base_datapathwrapper1 : unsigned(31 downto 0):=X"0070_0000";
88+
constant add_serial_flash_csr : unsigned(31 downto 0):=X"00A0_0000";
89+
constant add_serial_flash_wr_rst : unsigned(31 downto 0):=X"00B0_0000";
90+
constant add_userlogic : unsigned(31 downto 0):=X"00C0_0000";
91+
constant add_ddg : unsigned(31 downto 0):=X"00D0_0000";
92+
constant add_gbt_sc : unsigned(31 downto 0):=X"00F0_0000";
7793
-------------------------------------------------------------------------------
7894
-- Redaout protocol address tables
7995
-------------------------------------------------------------------------------
80-
constant add_ro_protocol_base : unsigned(31 downto 0):=X"0010_0000";
81-
constant add_ro_prot_conf_reg : unsigned(31 downto 0):=X"0000_0000"+add_ro_protocol_base;
96+
constant add_ro_prot_conf_reg : unsigned(31 downto 0):=X"0000_0000"+add_ro_protocol_base;
8297
constant add_ro_prot_check_mask : unsigned(31 downto 0):=X"0000_0004"+add_ro_protocol_base;
8398
constant add_ro_prot_alloc_fail : unsigned(31 downto 0):=X"0000_0008"+add_ro_protocol_base;
84-
constant add_ro_prot_ttc_linkerr : unsigned(31 downto 0):=X"0000_000C"+add_ro_protocol_base;
99+
constant add_ro_prot_ttc_linkerr : unsigned(31 downto 0):=X"0000_000C"+add_ro_protocol_base;
100+
constant add_ro_prot_nack_dly_reg : unsigned(31 downto 0):=X"0000_0010"+add_ro_protocol_base;
85101

86102
-------------------------------------------------------------------------------
87103
-- GBT address tables
88104
-------------------------------------------------------------------------------
89105
-- GBT wrapper pages
90-
constant add_gbt_wrapper0 : unsigned(31 downto 0):=X"0040_0000";
91-
constant add_gbt_wrapper1 : unsigned(31 downto 0):=X"0050_0000";
92-
93106
constant add_gbt_wrapper_gregs : unsigned(31 downto 0):=X"0000_0000";
94107
constant add_gbt_wrapper_bank_offset: unsigned(31 downto 0):=X"0002_0000"; -- multiply by 1 to 6 (for 6 banks)
95108
constant add_gbt_wrapper_atx_pll : unsigned(31 downto 0):=X"000E_0000"; -- alt_a10_gx_240mhz_atx_pll
@@ -132,7 +145,6 @@ constant add_gbt_link_rx_ctrl_offset : unsigned(31 downto 0) := x"0000_003C";
132145
-- GBTSC address tables
133146
-------------------------------------------------------------------------------
134147
-- GBTSCA wrapper pages
135-
constant add_gbt_sc : unsigned(31 downto 0):=X"00f0_0000";
136148
-- SCA WR
137149
constant add_gbt_sca_wr_data : unsigned(31 downto 0):=add_gbt_sc+X"0000_0000";
138150
constant add_gbt_sca_wr_cmd : unsigned(31 downto 0):=add_gbt_sc+X"0000_0004";
@@ -165,8 +177,6 @@ constant add_gbt_sc_rst : unsigned(31 downto 0):=add_gbt
165177
-------------------------------------------------------------------------------
166178
-- TTC PON address tables
167179
-------------------------------------------------------------------------------
168-
constant add_ttc_pon : unsigned(31 downto 0):=X"0020_0000";
169-
170180
constant add_ttc_regs : unsigned(31 downto 0):=add_ttc_pon+X"0000_0000";
171181
constant add_ttc_onu : unsigned(31 downto 0):=add_ttc_pon+X"0002_0000";
172182
constant add_ttc_clkgen : unsigned(31 downto 0):=add_ttc_pon+X"0004_0000";
@@ -246,7 +256,6 @@ constant add_ctp_emu_fbct : unsigned(31 downto 0):=add_ctp_emu_core+
246256
-------------------------------------------------------------------------------
247257
-- DDG address tables
248258
-------------------------------------------------------------------------------
249-
constant add_ddg : unsigned(31 downto 0):=X"00D0_0000";
250259
constant add_ddg_ctrl : unsigned(31 downto 0):=add_ddg+X"0000_0000";
251260
constant add_ddg_ctrl2 : unsigned(31 downto 0):=add_ddg+X"0000_0004";
252261
constant add_ddg_ctrl3 : unsigned(31 downto 0):=add_ddg+X"0000_0008";
@@ -257,9 +266,6 @@ constant add_ddg_trgmiss_cnt : unsigned(31 downto 0):=add_ddg+X"0000_0014";
257266
-------------------------------------------------------------------------------
258267
-- datapath wrapper address tables
259268
-------------------------------------------------------------------------------
260-
constant add_base_datapathwrapper0 : unsigned(31 downto 0):=X"0060_0000";
261-
constant add_base_datapathwrapper1 : unsigned(31 downto 0):=X"0070_0000";
262-
263269
constant add_dwrapper_gregs : unsigned(31 downto 0):=X"0000_0000";
264270
constant add_datapathlink_offset : unsigned(31 downto 0):=X"0004_0000"; -- add link offset to access it
265271
constant add_flowctrl_offset : unsigned(31 downto 0):=X"000C_0000";
@@ -286,7 +292,7 @@ constant add_dwrapper_trigsize : unsigned(31 downto 0):=X"0000_0034"; -- WO
286292

287293
--datapath link registers
288294
constant add_datalink_ctrl : unsigned(31 downto 0):=X"0000_0000";
289-
295+
constant add_datalink_feeid : unsigned(31 downto 0):=X"0000_0004";
290296
constant add_datalink_rej_pkt : unsigned(31 downto 0):=X"0000_0008";
291297
constant add_datalink_acc_pkt : unsigned(31 downto 0):=X"0000_000C";
292298
constant add_datalink_forced_pkt : unsigned(31 downto 0):=X"0000_0010";
@@ -300,15 +306,13 @@ constant add_flowctrl_pkt_tot : unsigned(31 downto 0):=X"0000_0008";
300306
-------------------------------------------------------------------------------
301307
-- Serial Flash address tables
302308
-------------------------------------------------------------------------------
303-
constant add_serial_flash_csr : unsigned(31 downto 0):=X"00A0_0000";
304-
constant add_serial_flash_wr_rst : unsigned(31 downto 0):=X"00B0_0000";
309+
305310
constant add_serial_flash_wr_data : unsigned(31 downto 0):=X"00B0_0004";
306311

307312

308313
-------------------------------------------------------------------------------
309314
-- BSP address tables
310315
-------------------------------------------------------------------------------
311-
constant add_bsp : unsigned(31 downto 0):=X"0000_0000";
312316
constant add_bsp_info : unsigned(31 downto 0):=add_bsp+X"0000_0000";
313317
constant add_bsp_hkeeping : unsigned(31 downto 0):=add_bsp+X"0001_0000";
314318
constant add_bsp_rsu : unsigned(31 downto 0):=add_bsp+X"0002_0000";
@@ -364,9 +368,17 @@ constant add_bsp_i2c_eeprom : unsigned(31 downto 0):=add_bsp_i2c+X"0000_08
364368
-------------------------------------------------------------------------------
365369
-- User logic
366370
-------------------------------------------------------------------------------
367-
constant add_userlogic : unsigned(31 downto 0):=X"00C0_0000";
371+
constant add_userlogic_info : unsigned(31 downto 0):=add_userlogic+X"0000_0000";
372+
constant add_userlogic_ctrl : unsigned(31 downto 0):=add_userlogic+X"0008_0000";
368373

369-
constant add_userlogic_ctrl : unsigned(31 downto 0):=add_userlogic+X"0000_0000";
374+
constant add_user_logic_dirty_idcode : unsigned(31 downto 0) :=add_userlogic_info+X"0000_0000";
375+
constant add_user_logic_shorthash : unsigned(31 downto 0) :=add_userlogic_info+X"0000_0004";
376+
constant add_user_logic_builddate : unsigned(31 downto 0) :=add_userlogic_info+X"0000_0008";
377+
constant add_user_logic_buildtime : unsigned(31 downto 0) :=add_userlogic_info+X"0000_000C";
378+
379+
constant add_user_logic_reset : unsigned(31 downto 0) := add_userlogic_ctrl+X"0000_0000";
380+
constant add_user_logic_eventsize : unsigned(31 downto 0) := add_userlogic_ctrl+X"0000_0004";
381+
constant add_user_logic_rand_eventsize_toggle : unsigned(31 downto 0) := add_userlogic_ctrl+X"0000_0008";
370382

371383
--------------------------------------------------------------------------------
372384
-- BAR 0 REGISTERs (DMA)
@@ -507,21 +519,7 @@ component ddg is
507519
-- GBT Downlink (CRU -> FE)
508520
--------------------------------------------------------------------------------
509521
gbt_tx_ready_i : in std_logic_vector(g_NUM_GBT_LINKS-1 downto 0);
510-
511-
gbt_tx_bus_o : out t_cru_gbt;
512-
--------------------------------------------------------------------------------
513-
-- GBT Uplink (FE -> CRU)
514-
--------------------------------------------------------------------------------
515-
gbt_rx_ready_i : in std_logic_vector(g_NUM_GBT_LINKS-1 downto 0);
516-
gbt_rx_bus_i : in t_cru_gbt_array (g_NUM_GBT_LINKS-1 downto 0);
517-
--------------------------------------------------------------------------------
518-
-- DMA interface
519-
--------------------------------------------------------------------------------
520-
FCLK0 : out std_logic;
521-
FVAL0 : out std_logic;
522-
FSOP0 : out std_logic;
523-
FEOP0 : out std_logic;
524-
FD0 : out std_logic_vector(255 downto 0)
522+
gbt_tx_bus_o : out t_cru_gbt
525523
);
526524
end component ddg;
527525

@@ -648,7 +646,7 @@ component datapath_wrapper is
648646
---------------------------------------------------------------------------
649647
PCIe_CLK : in std_logic; -- clock for this FIFO interface
650648
PCIe_RST : in std_logic;
651-
PCIe_AFULL : in std_logic; -- almost full
649+
PCIe_RD : in std_logic; -- PCIe RD
652650
PCIe_SOP : out std_logic; -- start of packet
653651
PCIe_EOP : out std_logic; -- end of packet
654652
PCIe_VAL : out std_logic; -- data valid

0 commit comments

Comments
 (0)