Skip to content

Commit 90df31d

Browse files
[fec] added logic that put port down before applying fec onfiguration (sonic-net#1399)
Signed-off-by: Vadym Hlushko <[email protected]>
1 parent 0790a5f commit 90df31d

File tree

1 file changed

+35
-7
lines changed

1 file changed

+35
-7
lines changed

orchagent/portsorch.cpp

+35-7
Original file line numberDiff line numberDiff line change
@@ -2358,17 +2358,45 @@ void PortsOrch::doPortTask(Consumer &consumer)
23582358
/* reset fec mode upon mode change */
23592359
if (p.m_fec_mode != fec_mode_map[fec_mode])
23602360
{
2361-
p.m_fec_mode = fec_mode_map[fec_mode];
2362-
if (setPortFec(p, p.m_fec_mode))
2361+
if (p.m_admin_state_up)
23632362
{
2364-
m_portList[alias] = p;
2365-
SWSS_LOG_NOTICE("Set port %s fec to %s", alias.c_str(), fec_mode.c_str());
2363+
/* Bring port down before applying fec mode*/
2364+
if (!setPortAdminStatus(p, false))
2365+
{
2366+
SWSS_LOG_ERROR("Failed to set port %s admin status DOWN to set fec mode", alias.c_str());
2367+
it++;
2368+
continue;
2369+
}
2370+
2371+
p.m_admin_state_up = false;
2372+
p.m_fec_mode = fec_mode_map[fec_mode];
2373+
2374+
if (setPortFec(p, p.m_fec_mode))
2375+
{
2376+
m_portList[alias] = p;
2377+
SWSS_LOG_NOTICE("Set port %s fec to %s", alias.c_str(), fec_mode.c_str());
2378+
}
2379+
else
2380+
{
2381+
SWSS_LOG_ERROR("Failed to set port %s fec to %s", alias.c_str(), fec_mode.c_str());
2382+
it++;
2383+
continue;
2384+
}
23662385
}
23672386
else
23682387
{
2369-
SWSS_LOG_ERROR("Failed to set port %s fec to %s", alias.c_str(), fec_mode.c_str());
2370-
it++;
2371-
continue;
2388+
/* Port is already down, setting fec mode*/
2389+
if (setPortFec(p, p.m_fec_mode))
2390+
{
2391+
m_portList[alias] = p;
2392+
SWSS_LOG_NOTICE("Set port %s fec to %s", alias.c_str(), fec_mode.c_str());
2393+
}
2394+
else
2395+
{
2396+
SWSS_LOG_ERROR("Failed to set port %s fec to %s", alias.c_str(), fec_mode.c_str());
2397+
it++;
2398+
continue;
2399+
}
23722400
}
23732401
}
23742402
}

0 commit comments

Comments
 (0)