Skip to content

Commit

Permalink
Reorganization of DTC packet counter register handling
Browse files Browse the repository at this point in the history
  • Loading branch information
rrivera747 committed Jul 11, 2024
1 parent caebdc2 commit 36111f9
Show file tree
Hide file tree
Showing 2 changed files with 145 additions and 108 deletions.
180 changes: 94 additions & 86 deletions dtcInterfaceLib/DTC_Registers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5932,8 +5932,14 @@ DTCLib::RegisterFormatter DTCLib::DTC_Registers::FormatCFOLinkError()
auto form = CreateFormatter(DTC_Register_CFOLinkErrorFlags);
form.description = "CFO Link Error Flags";
std::stringstream o;
o << "0x" << std::hex << ReadRegister_(DTC_Register_CFOLinkErrorFlags);
o << "0x" << std::hex << form.value;
form.vals.push_back(o.str());
//bit 9 - Event Start marker tx error
//bit 10 - Clock marker tx error
form.vals.push_back(std::string("CFO Event Start Marker tx Error: [") +
(((form.value >> 9)&1) ? "x" : " ") + "]");
form.vals.push_back(std::string("CFO Clock Marker tx Error: [") +
(((form.value >> 10)&1) ? "x" : " ") + "]");
return form;
}

Expand Down Expand Up @@ -8439,6 +8445,59 @@ DTCLib::RegisterFormatter DTCLib::DTC_Registers::FormatROCEmulatorInterpacketDel
return form;
}

// TX Data Request Packet Count
uint32_t DTCLib::DTC_Registers::ReadTXEventWindowMarkerCountLinkRegister(DTC_Link_ID const& link, std::optional<uint32_t> val)
{
return val.has_value() ? *val : ReadRegister_(GetTXEventWindowMarkerCountLinkRegister(link));
} //end ReadTXEventWindowMarkerCountLinkRegister()

DTCLib::RegisterFormatter DTCLib::DTC_Registers::FormatTXEventWindowMarkerCountLink(DTC_Link_ID const& link)
{
auto form = CreateFormatter(GetTXEventWindowMarkerCountLinkRegister(link));
form.description = "Data Request Packet TX Counter Link " +
std::to_string((GetTXEventWindowMarkerCountLinkRegister(link) -
GetTXEventWindowMarkerCountLinkRegister(DTC_Link_0))/4 );
std::stringstream o;
o << std::dec << ReadTXDataRequestPacketCount(link, form.value);
form.vals.push_back(o.str());
return form;
} //end FormatTXEventWindowMarkerCountLink()

DTCLib::DTC_Register DTCLib::DTC_Registers::GetTXEventWindowMarkerCountLinkRegister(DTC_Link_ID const& link)
{
DTC_Register reg;
switch (link)
{
case DTC_Link_0:
reg = DTC_Register_TXEventWindowMarkerCount_Link0;
break;
case DTC_Link_1:
reg = DTC_Register_TXEventWindowMarkerCount_Link1;
break;
case DTC_Link_2:
reg = DTC_Register_TXEventWindowMarkerCount_Link2;
break;
case DTC_Link_3:
reg = DTC_Register_TXEventWindowMarkerCount_Link3;
break;
case DTC_Link_4:
reg = DTC_Register_TXEventWindowMarkerCount_Link4;
break;
case DTC_Link_5:
reg = DTC_Register_TXEventWindowMarkerCount_Link5;
break;
case DTC_Link_CFO:
reg = DTC_Register_CFOTXEventWindowMarkerCount_Link6;
break;
default: {
__SS__ << "Illegal link index provided: " << link << __E__;
__SS_THROW__;
}
}
return reg;
} //end GetTXEventWindowMarkerCountLinkRegister()


// TX Data Request Packet Count
uint32_t DTCLib::DTC_Registers::ReadTXDataRequestPacketCount(DTC_Link_ID const& link, std::optional<uint32_t> val)
{
Expand Down Expand Up @@ -8554,39 +8613,39 @@ DTCLib::RegisterFormatter DTCLib::DTC_Registers::FormatTXDataRequestPacketCountL
form.vals.push_back(o.str());
return form;
}
DTCLib::RegisterFormatter DTCLib::DTC_Registers::FormatCFOTXClockMarkerCountLink6()
{
auto form = CreateFormatter(DTC_Register_CFOTXClockMarkerCount_Link6);
form.description = "CFO TX Event Window Marker Counter Link 6";
std::stringstream o;
o << std::dec << ReadCFOTXClockMarkerCountLink6(form.value);
form.vals.push_back(o.str());
return form;
} //end FormatCFOTXClockMarkerCountLink6()

uint32_t DTCLib::DTC_Registers::ReadCFOTXClockMarkerCountLink6(std::optional<uint32_t> val)
{
return val.has_value() ? *val : ReadRegister_(DTC_Register_CFOTXClockMarkerCount_Link6);
} //end ReadCFOTXClockMarkerCountLink6()

// TX Heartbeat Packet Count
uint32_t DTCLib::DTC_Registers::ReadTXHeartbeatPacketCount(DTC_Link_ID const& link, std::optional<uint32_t> val)
{
DTC_Register reg;
switch (link)
{
case DTC_Link_0:
reg = DTC_Register_TXHeartbeatPacketCount_Link0;
break;
case DTC_Link_1:
reg = DTC_Register_TXHeartbeatPacketCount_Link1;
break;
case DTC_Link_2:
reg = DTC_Register_TXHeartbeatPacketCount_Link2;
break;
case DTC_Link_3:
reg = DTC_Register_TXHeartbeatPacketCount_Link3;
break;
case DTC_Link_4:
reg = DTC_Register_TXHeartbeatPacketCount_Link4;
break;
case DTC_Link_5:
reg = DTC_Register_TXHeartbeatPacketCount_Link5;
break;
default: {
__SS__ << "Illegal link index provided: " << link << __E__;
__SS_THROW__;
}
}
return val.has_value() ? *val : ReadRegister_(reg);
}
void DTCLib::DTC_Registers::ClearTXHeartbeatPacketCount(DTC_Link_ID const& link)
return val.has_value() ? *val : ReadRegister_(GetTXHeartbeatPacketCountLinkRegister(link));
} //end ReadTXHeartbeatPacketCount()
DTCLib::RegisterFormatter DTCLib::DTC_Registers::FormatTXHeartbeatPacketCountLink(DTC_Link_ID const& link)
{
auto form = CreateFormatter(GetTXHeartbeatPacketCountLinkRegister(link));
form.description = "Heartbeat Packet TX Counter Link " +
std::to_string((GetTXHeartbeatPacketCountLinkRegister(link) -
GetTXHeartbeatPacketCountLinkRegister(DTC_Link_0))/4 );
std::stringstream o;
o << std::dec << ReadTXHeartbeatPacketCount(DTC_Link_0, form.value);
form.vals.push_back(o.str());
return form;
} //end FormatTXHeartbeatPacketCountLink()

DTCLib::DTC_Register DTCLib::DTC_Registers::GetTXHeartbeatPacketCountLinkRegister(DTC_Link_ID const& link)
{
DTC_Register reg;
switch (link)
Expand All @@ -8609,67 +8668,16 @@ void DTCLib::DTC_Registers::ClearTXHeartbeatPacketCount(DTC_Link_ID const& link)
case DTC_Link_5:
reg = DTC_Register_TXHeartbeatPacketCount_Link5;
break;
case DTC_Link_CFO:
reg = DTC_Register_CFOTXHeartbeatPacketCount_Link5;
break;
default: {
__SS__ << "Illegal link index provided: " << link << __E__;
__SS_THROW__;
}
}
WriteRegister_(0, reg);
}
DTCLib::RegisterFormatter DTCLib::DTC_Registers::FormatTXHeartbeatPacketCountLink0()
{
auto form = CreateFormatter(DTC_Register_TXHeartbeatPacketCount_Link0);
form.description = "Heartbeat Packet TX Counter Link 0";
std::stringstream o;
o << std::dec << ReadTXHeartbeatPacketCount(DTC_Link_0, form.value);
form.vals.push_back(o.str());
return form;
}
DTCLib::RegisterFormatter DTCLib::DTC_Registers::FormatTXHeartbeatPacketCountLink1()
{
auto form = CreateFormatter(DTC_Register_TXHeartbeatPacketCount_Link1);
form.description = "Heartbeat Packet TX Counter Link 1";
std::stringstream o;
o << std::dec << ReadTXHeartbeatPacketCount(DTC_Link_1, form.value);
form.vals.push_back(o.str());
return form;
}
DTCLib::RegisterFormatter DTCLib::DTC_Registers::FormatTXHeartbeatPacketCountLink2()
{
auto form = CreateFormatter(DTC_Register_TXHeartbeatPacketCount_Link2);
form.description = "Heartbeat Packet TX Counter Link 2";
std::stringstream o;
o << std::dec << ReadTXHeartbeatPacketCount(DTC_Link_2, form.value);
form.vals.push_back(o.str());
return form;
}
DTCLib::RegisterFormatter DTCLib::DTC_Registers::FormatTXHeartbeatPacketCountLink3()
{
auto form = CreateFormatter(DTC_Register_TXHeartbeatPacketCount_Link3);
form.description = "Heartbeat Packet TX Counter Link 3";
std::stringstream o;
o << std::dec << ReadTXHeartbeatPacketCount(DTC_Link_3, form.value);
form.vals.push_back(o.str());
return form;
}
DTCLib::RegisterFormatter DTCLib::DTC_Registers::FormatTXHeartbeatPacketCountLink4()
{
auto form = CreateFormatter(DTC_Register_TXHeartbeatPacketCount_Link4);
form.description = "Heartbeat Packet TX Counter Link 4";
std::stringstream o;
o << std::dec << ReadTXHeartbeatPacketCount(DTC_Link_4, form.value);
form.vals.push_back(o.str());
return form;
}
DTCLib::RegisterFormatter DTCLib::DTC_Registers::FormatTXHeartbeatPacketCountLink5()
{
auto form = CreateFormatter(DTC_Register_TXHeartbeatPacketCount_Link5);
form.description = "Heartbeat Packet TX Counter Link 5";
std::stringstream o;
o << std::dec << ReadTXHeartbeatPacketCount(DTC_Link_5, form.value);
form.vals.push_back(o.str());
return form;
}
return reg;
} //end GetTXHeartbeatPacketCountLinkRegister()

// RX Data Header Packet Count
uint32_t DTCLib::DTC_Registers::ReadRXDataHeaderPacketCount(DTC_Link_ID const& link, std::optional<uint32_t> val)
Expand Down
73 changes: 51 additions & 22 deletions dtcInterfaceLib/DTC_Registers.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ enum DTC_Register : uint16_t
DTC_Register_TXDataRequestPacketCount_Link3 = 0x963C,
DTC_Register_TXDataRequestPacketCount_Link4 = 0x9640,
DTC_Register_TXDataRequestPacketCount_Link5 = 0x9644,
DTC_Register_CFOTXClockMarkerCount_Link6 = 0x9648,
// 0x9648 Reserved
// 0x964C Reserved
DTC_Register_TXHeartbeatPacketCount_Link0 = 0x9650,
Expand All @@ -285,6 +286,7 @@ enum DTC_Register : uint16_t
DTC_Register_TXHeartbeatPacketCount_Link3 = 0x965C,
DTC_Register_TXHeartbeatPacketCount_Link4 = 0x9660,
DTC_Register_TXHeartbeatPacketCount_Link5 = 0x9664,
DTC_Register_CFOTXHeartbeatPacketCount_Link5 = 0x9668,
// 0x9668 Reserved
// 0x966C Reserved
DTC_Register_RXDataHeaderPacketCount_Link0 = 0x9670,
Expand Down Expand Up @@ -324,6 +326,15 @@ enum DTC_Register : uint16_t

DTC_Register_RXDataDiagnosticFIFO_LinkCFO = 0x9700,
DTC_Register_TXDataDiagnosticFIFO_LinkCFO = 0x9708,

DTC_Register_TXEventWindowMarkerCount_Link0 = 0xA400,
DTC_Register_TXEventWindowMarkerCount_Link1 = 0xA404,
DTC_Register_TXEventWindowMarkerCount_Link2 = 0xA408,
DTC_Register_TXEventWindowMarkerCount_Link3 = 0xA40C,
DTC_Register_TXEventWindowMarkerCount_Link4 = 0xA410,
DTC_Register_TXEventWindowMarkerCount_Link5 = 0xA414,
DTC_Register_CFOTXEventWindowMarkerCount_Link6 = 0xA418,

DTC_Register_Invalid,
// };
}; // end DTC_Register enum
Expand Down Expand Up @@ -1193,16 +1204,18 @@ class DTC_Registers : public CFOandDTC_Registers
RegisterFormatter FormatTXDataRequestPacketCountLink3();
RegisterFormatter FormatTXDataRequestPacketCountLink4();
RegisterFormatter FormatTXDataRequestPacketCountLink5();
RegisterFormatter FormatCFOTXClockMarkerCountLink6();
uint32_t ReadCFOTXClockMarkerCountLink6(std::optional<uint32_t> val = std::nullopt);

// TX Heartbeat Packet Count
uint32_t ReadTXHeartbeatPacketCount(DTC_Link_ID const& link, std::optional<uint32_t> val = std::nullopt);
void ClearTXHeartbeatPacketCount(DTC_Link_ID const& link);
RegisterFormatter FormatTXHeartbeatPacketCountLink0();
RegisterFormatter FormatTXHeartbeatPacketCountLink1();
RegisterFormatter FormatTXHeartbeatPacketCountLink2();
RegisterFormatter FormatTXHeartbeatPacketCountLink3();
RegisterFormatter FormatTXHeartbeatPacketCountLink4();
RegisterFormatter FormatTXHeartbeatPacketCountLink5();
uint32_t ReadTXHeartbeatPacketCount(DTC_Link_ID const& link, std::optional<uint32_t> val = std::nullopt);
RegisterFormatter FormatTXHeartbeatPacketCountLink(DTC_Link_ID const& link);
DTC_Register GetTXHeartbeatPacketCountLinkRegister(DTC_Link_ID const& link);

// TX Data Request Packet Count
uint32_t ReadTXEventWindowMarkerCountLinkRegister(DTC_Link_ID const& link, std::optional<uint32_t> val = std::nullopt);
RegisterFormatter FormatTXEventWindowMarkerCountLink(DTC_Link_ID const& link);
DTC_Register GetTXEventWindowMarkerCountLinkRegister(DTC_Link_ID const& link);

// RX Data Header Packet Count
uint32_t ReadRXDataHeaderPacketCount(DTC_Link_ID const& link, std::optional<uint32_t> val = std::nullopt);
Expand Down Expand Up @@ -1278,6 +1291,7 @@ class DTC_Registers : public CFOandDTC_Registers
[this] { return this->FormatSERDESPLLLocked(); },
[this] { return this->FormatROCEmulationEnable(); },
[this] { return this->FormatLinkEnable(); },
[this] { return this->FormatCFOLinkError(); },
[this] { return this->FormatCFO40MHzClockMarkerEnables(); },
[this] { return this->FormatRXCDRLockStatus(); },
[this] { return this->FormatSERDESResetDone(); },
Expand Down Expand Up @@ -1502,6 +1516,7 @@ class DTC_Registers : public CFOandDTC_Registers
};

const std::vector<std::function<RegisterFormatter()>> formattedSERDESErrorFunctions_{
[this] { return this->FormatCFOLinkError(); },
[this] { return this->FormatSERDESCharacterNotInTableErrorCountLink0(); },
[this] { return this->FormatSERDESCharacterNotInTableErrorCountLink1(); },
[this] { return this->FormatSERDESCharacterNotInTableErrorCountLink2(); },
Expand Down Expand Up @@ -1537,32 +1552,46 @@ class DTC_Registers : public CFOandDTC_Registers
};

const std::vector<std::function<RegisterFormatter()>> formattedPacketCounterFunctions_{
[this] { return this->FormatMissedCFOPacketCountLink0(); },
[this] { return this->FormatMissedCFOPacketCountLink1(); },
[this] { return this->FormatMissedCFOPacketCountLink2(); },
[this] { return this->FormatMissedCFOPacketCountLink3(); },
[this] { return this->FormatMissedCFOPacketCountLink4(); },
[this] { return this->FormatMissedCFOPacketCountLink5(); },
[this] { return this->FormatLocalFragmentDropCount(); },
[this] { return this->FormatOutputBufferFragmentDumpCount(); },
// [this] { return this->FormatMissedCFOPacketCountLink0(); },
// [this] { return this->FormatMissedCFOPacketCountLink1(); },
// [this] { return this->FormatMissedCFOPacketCountLink2(); },
// [this] { return this->FormatMissedCFOPacketCountLink3(); },
// [this] { return this->FormatMissedCFOPacketCountLink4(); },
// [this] { return this->FormatMissedCFOPacketCountLink5(); },
// [this] { return this->FormatLocalFragmentDropCount(); },
// [this] { return this->FormatOutputBufferFragmentDumpCount(); },
[this] { return this->FormatTXEventWindowMarkerCountLink(DTC_Link_0); },
[this] { return this->FormatTXEventWindowMarkerCountLink(DTC_Link_1); },
[this] { return this->FormatTXEventWindowMarkerCountLink(DTC_Link_2); },
[this] { return this->FormatTXEventWindowMarkerCountLink(DTC_Link_3); },
[this] { return this->FormatTXEventWindowMarkerCountLink(DTC_Link_4); },
[this] { return this->FormatTXEventWindowMarkerCountLink(DTC_Link_5); },
[this] { return this->FormatTXEventWindowMarkerCountLink(DTC_Link_CFO); },

[this] { return this->FormatTXDataRequestPacketCountLink0(); },
[this] { return this->FormatTXDataRequestPacketCountLink1(); },
[this] { return this->FormatTXDataRequestPacketCountLink2(); },
[this] { return this->FormatTXDataRequestPacketCountLink3(); },
[this] { return this->FormatTXDataRequestPacketCountLink4(); },
[this] { return this->FormatTXDataRequestPacketCountLink5(); },
[this] { return this->FormatTXHeartbeatPacketCountLink0(); },
[this] { return this->FormatTXHeartbeatPacketCountLink1(); },
[this] { return this->FormatTXHeartbeatPacketCountLink2(); },
[this] { return this->FormatTXHeartbeatPacketCountLink3(); },
[this] { return this->FormatTXHeartbeatPacketCountLink4(); },
[this] { return this->FormatTXHeartbeatPacketCountLink5(); },
[this] { return this->FormatCFOTXClockMarkerCountLink6(); },
[this] { return this->FormatCFOLinkError(); },

[this] { return this->FormatTXHeartbeatPacketCountLink(DTC_Link_0); },
[this] { return this->FormatTXHeartbeatPacketCountLink(DTC_Link_1); },
[this] { return this->FormatTXHeartbeatPacketCountLink(DTC_Link_2); },
[this] { return this->FormatTXHeartbeatPacketCountLink(DTC_Link_3); },
[this] { return this->FormatTXHeartbeatPacketCountLink(DTC_Link_4); },
[this] { return this->FormatTXHeartbeatPacketCountLink(DTC_Link_5); },
[this] { return this->FormatTXHeartbeatPacketCountLink(DTC_Link_CFO); },

[this] { return this->FormatRXDataHeaderPacketCountLink0(); },
[this] { return this->FormatRXDataHeaderPacketCountLink1(); },
[this] { return this->FormatRXDataHeaderPacketCountLink2(); },
[this] { return this->FormatRXDataHeaderPacketCountLink3(); },
[this] { return this->FormatRXDataHeaderPacketCountLink4(); },
[this] { return this->FormatRXDataHeaderPacketCountLink5(); },

[this] { return this->FormatRXDataPacketCountLink0(); },
[this] { return this->FormatRXDataPacketCountLink1(); },
[this] { return this->FormatRXDataPacketCountLink2(); },
Expand Down

0 comments on commit 36111f9

Please sign in to comment.