@@ -512,6 +512,18 @@ PortsOrch::PortsOrch(DBConnector *db, DBConnector *stateDb, vector<table_name_wi
512512 }
513513 }
514514
515+ sai_attr_capability_t attr_cap;
516+ if (sai_query_attribute_capability (gSwitchId , SAI_OBJECT_TYPE_PORT,
517+ SAI_PORT_ATTR_AUTO_NEG_FEC_MODE_OVERRIDE,
518+ &attr_cap) != SAI_STATUS_SUCCESS)
519+ {
520+ SWSS_LOG_NOTICE (" Unable to query autoneg fec mode override" );
521+ }
522+ else if (attr_cap.set_implemented && attr_cap.create_implemented )
523+ {
524+ fec_override_sup = true ;
525+ }
526+
515527 /* Get default 1Q bridge and default VLAN */
516528 sai_status_t status;
517529 sai_attribute_t attr;
@@ -1502,6 +1514,28 @@ bool PortsOrch::setPortTpid(Port &port, sai_uint16_t tpid)
15021514 return true ;
15031515}
15041516
1517+ bool PortsOrch::setPortFecOverride (sai_object_id_t port_obj, bool fec_override)
1518+ {
1519+ sai_attribute_t attr;
1520+ sai_status_t status;
1521+
1522+ attr.id = SAI_PORT_ATTR_AUTO_NEG_FEC_MODE_OVERRIDE;
1523+ attr.value .booldata = fec_override;
1524+
1525+ status = sai_port_api->set_port_attribute (port_obj, &attr);
1526+ if (status != SAI_STATUS_SUCCESS)
1527+ {
1528+ SWSS_LOG_ERROR (" Failed to set fec override %d to port pid:%" PRIx64, attr.value .booldata , port_obj);
1529+ task_process_status handle_status = handleSaiSetStatus (SAI_API_PORT, status);
1530+ if (handle_status != task_success)
1531+ {
1532+ return parseHandleSaiStatusFailure (handle_status);
1533+ }
1534+ }
1535+ SWSS_LOG_INFO (" Set fec override %d to port pid:%" PRIx64, attr.value .booldata , port_obj);
1536+ return true ;
1537+ }
1538+
15051539bool PortsOrch::setPortFec (Port &port, sai_port_fec_mode_t fec_mode)
15061540{
15071541 SWSS_LOG_ENTER ();
@@ -1521,6 +1555,10 @@ bool PortsOrch::setPortFec(Port &port, sai_port_fec_mode_t fec_mode)
15211555 }
15221556 }
15231557
1558+ if (fec_override_sup && !setPortFecOverride (port.m_port_id , true ))
1559+ {
1560+ return false ;
1561+ }
15241562 setGearboxPortsAttr (port, SAI_PORT_ATTR_FEC_MODE, &fec_mode);
15251563
15261564 SWSS_LOG_NOTICE (" Set port %s FEC mode %d" , port.m_alias .c_str (), fec_mode);
@@ -2524,6 +2562,10 @@ bool PortsOrch::setGearboxPortAttr(const Port &port, dest_port_type_t port_type,
25242562 m_gearboxTable->hset (key, speed_attr, to_string (speed));
25252563 SWSS_LOG_NOTICE (" BOX: Updated APPL_DB key:%s %s %d" , key.c_str (), speed_attr.c_str (), speed);
25262564 }
2565+ else if (id == SAI_PORT_ATTR_FEC_MODE && fec_override_sup && !setPortFecOverride (dest_port_id, true ))
2566+ {
2567+ return false ;
2568+ }
25272569 }
25282570 else
25292571 {
0 commit comments