Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[portsorch] don't set serdes attributes when there's no change #33

Closed
wants to merge 1 commit into from
Closed
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
16 changes: 2 additions & 14 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3757,12 +3757,6 @@ void PortsOrch::doPortTask(Consumer &consumer)
m_portList[p.m_alias] = p;
updatePortStatePoll(p, PORT_STATE_POLL_LT, pCfg.link_training.value);

// Restore pre-emphasis when LT is transitioned from ON to OFF
if (!p.m_link_training && serdes_attr.empty())
{
serdes_attr = p.m_preemphasis;
}

SWSS_LOG_NOTICE(
"Set port %s link training to %s",
p.m_alias.c_str(), m_portHlpr.getLinkTrainingStr(pCfg).c_str()
Expand Down Expand Up @@ -4170,15 +4164,9 @@ void PortsOrch::doPortTask(Consumer &consumer)
}
}

if (!serdes_attr.empty())
if (!serdes_attrs.empty() && p.m_preemphasis != serdes_attr)
{
if (p.m_link_training)
{
SWSS_LOG_NOTICE("Save port %s preemphasis for LT", p.m_alias.c_str());
p.m_preemphasis = serdes_attr;
m_portList[p.m_alias] = p;
}
else
if (!p.m_link_training)
{
if (p.m_admin_state_up)
{
Expand Down
29 changes: 29 additions & 0 deletions tests/mock_tests/portsorch_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,35 @@ namespace portsorch_test
ASSERT_EQ(_sai_set_admin_state_down_count, ++current_sai_api_call_count);
ASSERT_EQ(_sai_set_admin_state_up_count, current_sai_api_call_count);

// Configure non-serdes attribute that does not trigger admin state change
std::deque<KeyOpFieldsValuesTuple> kfvMtu = {{
"Ethernet0",
SET_COMMAND, {
{ "mtu", "1234" },
}
}};

// Refill consumer
consumer->addToSync(kfvMtu);

_hook_sai_port_api();
current_sai_api_call_count = _sai_set_admin_state_down_count;

// Apply configuration
static_cast<Orch*>(gPortsOrch)->doTask();

_unhook_sai_port_api();

ASSERT_TRUE(gPortsOrch->getPort("Ethernet0", p));
ASSERT_TRUE(p.m_admin_state_up);

// Verify mtu is set
ASSERT_EQ(p.m_mtu, 1234);

// Verify no admin-disable then admin-enable
ASSERT_EQ(_sai_set_admin_state_down_count, current_sai_api_call_count);
ASSERT_EQ(_sai_set_admin_state_up_count, current_sai_api_call_count);

// Dump pending tasks
std::vector<std::string> taskList;
gPortsOrch->dumpPendingTasks(taskList);
Expand Down