Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7694,6 +7694,18 @@ void PortsOrch::refreshPortStatus()
{
updateDbPortOperSpeed(port, 0);
}
sai_port_fec_mode_t fec_mode;
string fec_str = "N/A";
if (oper_fec_sup && getPortOperFec(port, fec_mode))
{
if (!m_portHlpr.fecToStr(fec_str, fec_mode))
{
SWSS_LOG_ERROR("Error unknown fec mode %d while querying port %s fec mode",
static_cast<std::int32_t>(fec_mode), port.m_alias.c_str());
fec_str = "N/A";
}
}
updateDbPortOperFec(port,fec_str);
}
}
}
Expand Down
33 changes: 33 additions & 0 deletions tests/mock_tests/portsorch_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ namespace portsorch_test
attr_list[0].value.s32 = _sai_port_fec_mode;
status = SAI_STATUS_SUCCESS;
}
else if (attr_count== 1 && attr_list[0].id == SAI_PORT_ATTR_OPER_STATUS)
{
attr_list[0].value.u32 = (uint32_t)SAI_PORT_OPER_STATUS_UP;
status = SAI_STATUS_SUCCESS;
}
else
{
status = pold_sai_port_api->get_port_attribute(port_id, attr_count, attr_list);
Expand Down Expand Up @@ -1166,6 +1171,7 @@ namespace portsorch_test
{
_hook_sai_port_api();
Table portTable = Table(m_app_db.get(), APP_PORT_TABLE_NAME);
Table statePortTable = Table(m_state_db.get(), STATE_PORT_TABLE_NAME);
std::deque<KeyOpFieldsValuesTuple> entries;

not_support_fetching_fec = false;
Expand Down Expand Up @@ -1215,6 +1221,33 @@ namespace portsorch_test

ASSERT_EQ(fec_mode, SAI_PORT_FEC_MODE_RS);

gPortsOrch->refreshPortStatus();
std::vector<FieldValueTuple> values;
statePortTable.get("Ethernet0", values);
bool fec_found = false;
for (auto &valueTuple : values)
{
if (fvField(valueTuple) == "fec")
{
fec_found = true;
ASSERT_TRUE(fvValue(valueTuple) == "rs");
}
}
ASSERT_TRUE(fec_found == true);

/*Mock an invalid fec mode with high value*/
_sai_port_fec_mode = 100;
gPortsOrch->refreshPortStatus();
statePortTable.get("Ethernet0", values);
fec_found = false;
for (auto &valueTuple : values)
{
if (fvField(valueTuple) == "fec")
{
fec_found = true;
ASSERT_TRUE(fvValue(valueTuple) == "N/A");
}
}
mock_port_fec_modes = old_mock_port_fec_modes;
_unhook_sai_port_api();
}
Expand Down