@@ -2358,17 +2358,45 @@ void PortsOrch::doPortTask(Consumer &consumer)
2358
2358
/* reset fec mode upon mode change */
2359
2359
if (p.m_fec_mode != fec_mode_map[fec_mode])
2360
2360
{
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 )
2363
2362
{
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
+ }
2366
2385
}
2367
2386
else
2368
2387
{
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
+ }
2372
2400
}
2373
2401
}
2374
2402
}
0 commit comments