@@ -2003,17 +2003,45 @@ void PortsOrch::doPortTask(Consumer &consumer)
2003
2003
/* reset fec mode upon mode change */
2004
2004
if (p.m_fec_mode != fec_mode_map[fec_mode])
2005
2005
{
2006
- p.m_fec_mode = fec_mode_map[fec_mode];
2007
- if (setPortFec (p.m_port_id , p.m_fec_mode ))
2006
+ if (p.m_admin_state_up )
2008
2007
{
2009
- m_portList[alias] = p;
2010
- SWSS_LOG_NOTICE (" Set port %s fec to %s" , alias.c_str (), fec_mode.c_str ());
2008
+ /* Bring port down before applying fec mode*/
2009
+ if (!setPortAdminStatus (p, false ))
2010
+ {
2011
+ SWSS_LOG_ERROR (" Failed to set port %s admin status DOWN to set fec mode" , alias.c_str ());
2012
+ it++;
2013
+ continue ;
2014
+ }
2015
+
2016
+ p.m_admin_state_up = false ;
2017
+ p.m_fec_mode = fec_mode_map[fec_mode];
2018
+
2019
+ if (setPortFec (p, p.m_fec_mode ))
2020
+ {
2021
+ m_portList[alias] = p;
2022
+ SWSS_LOG_NOTICE (" Set port %s fec to %s" , alias.c_str (), fec_mode.c_str ());
2023
+ }
2024
+ else
2025
+ {
2026
+ SWSS_LOG_ERROR (" Failed to set port %s fec to %s" , alias.c_str (), fec_mode.c_str ());
2027
+ it++;
2028
+ continue ;
2029
+ }
2011
2030
}
2012
2031
else
2013
2032
{
2014
- SWSS_LOG_ERROR (" Failed to set port %s fec to %s" , alias.c_str (), fec_mode.c_str ());
2015
- it++;
2016
- continue ;
2033
+ /* Port is already down, setting fec mode*/
2034
+ if (setPortFec (p, p.m_fec_mode ))
2035
+ {
2036
+ m_portList[alias] = p;
2037
+ SWSS_LOG_NOTICE (" Set port %s fec to %s" , alias.c_str (), fec_mode.c_str ());
2038
+ }
2039
+ else
2040
+ {
2041
+ SWSS_LOG_ERROR (" Failed to set port %s fec to %s" , alias.c_str (), fec_mode.c_str ());
2042
+ it++;
2043
+ continue ;
2044
+ }
2017
2045
}
2018
2046
}
2019
2047
}
0 commit comments