@@ -702,6 +702,7 @@ PortsOrch::PortsOrch(DBConnector *db, DBConnector *stateDb, vector<table_name_wi
702702 /* Initialize port and vlan table */
703703 m_portTable = unique_ptr<Table>(new Table (db, APP_PORT_TABLE_NAME));
704704 m_sendToIngressPortTable = unique_ptr<Table>(new Table (db, APP_SEND_TO_INGRESS_PORT_TABLE_NAME));
705+ m_systemPortTable = unique_ptr<Table>(new Table (db, APP_SYSTEM_PORT_TABLE_NAME));
705706
706707 /* Initialize gearbox */
707708 m_gearboxTable = unique_ptr<Table>(new Table (db, " _GEARBOX_TABLE" ));
@@ -3973,6 +3974,7 @@ void PortsOrch::registerPort(Port &p)
39733974
39743975 /* Create associated Gearbox lane mapping */
39753976 initGearboxPort (p);
3977+ updateSystemPort (p);
39763978
39773979 /* Add port to port list */
39783980 m_portList[alias] = p;
@@ -10017,7 +10019,9 @@ bool PortsOrch::getSystemPorts()
1001710019 attr.value .sysportconfig .attached_core_index ,
1001810020 attr.value .sysportconfig .attached_core_port_index );
1001910021
10020- m_systemPortOidMap[sp_key] = system_port_list[i];
10022+ systemPortMapInfo system_port_info;
10023+ system_port_info.system_port_id = system_port_list[i];
10024+ m_systemPortOidMap[sp_key] = system_port_info;
1002110025 }
1002210026 }
1002310027
@@ -10103,7 +10107,8 @@ bool PortsOrch::addSystemPorts()
1010310107 sai_status_t status;
1010410108
1010510109 // Retrive system port config info and enable
10106- system_port_oid = m_systemPortOidMap[sp_key];
10110+ system_port_oid = m_systemPortOidMap[sp_key].system_port_id ;
10111+
1010710112
1010810113 attr.id = SAI_SYSTEM_PORT_ATTR_TYPE;
1010910114 attrs.push_back (attr);
@@ -10166,6 +10171,10 @@ bool PortsOrch::addSystemPorts()
1016610171 port.m_system_port_info .speed = attrs[1 ].value .sysportconfig .speed ;
1016710172 port.m_system_port_info .num_voq = attrs[1 ].value .sysportconfig .num_voq ;
1016810173
10174+ // Update the system Port Info to the m_systemPortOidMap to be used later when the Port Speed is changed dynamically
10175+ m_systemPortOidMap[sp_key].system_port_info = port.m_system_port_info ;
10176+ m_systemPortOidMap[sp_key].info_valid = true ;
10177+
1016910178 initializeVoqs ( port );
1017010179 setPort (port.m_alias , port);
1017110180 /* Add system port name map to counter table */
@@ -10194,6 +10203,73 @@ bool PortsOrch::addSystemPorts()
1019410203 return true ;
1019510204}
1019610205
10206+ void PortsOrch::updateSystemPort (Port &port)
10207+ {
10208+ if (!m_initDone)
10209+ {
10210+ // addSystemPorts will update the system port
10211+ return ;
10212+ }
10213+
10214+ if ((gMySwitchType == " voq" ) && (port.m_type == Port::PHY))
10215+ {
10216+ auto system_port_alias = gMyHostName + " |" + gMyAsicName + " |" + port.m_alias ;
10217+ vector<FieldValueTuple> spFv;
10218+
10219+ m_systemPortTable->get (system_port_alias, spFv);
10220+
10221+ // Retrieve system port configurations from APP DB
10222+ int32_t switch_id = -1 ;
10223+ int32_t core_index = -1 ;
10224+ int32_t core_port_index = -1 ;
10225+
10226+ for ( auto &fv : spFv )
10227+ {
10228+ if (fv.first == " switch_id" )
10229+ {
10230+ switch_id = stoi (fv.second );
10231+ continue ;
10232+ }
10233+ if (fv.first == " core_index" )
10234+ {
10235+ core_index = stoi (fv.second );
10236+ continue ;
10237+ }
10238+ if (fv.first == " core_port_index" )
10239+ {
10240+ core_port_index = stoi (fv.second );
10241+ continue ;
10242+ }
10243+ if (switch_id < 0 || core_index < 0 || core_port_index < 0 )
10244+ {
10245+ continue ;
10246+ }
10247+ tuple<int , int , int > sp_key (switch_id, core_index, core_port_index);
10248+
10249+ if (m_systemPortOidMap.find (sp_key) != m_systemPortOidMap.end ())
10250+ {
10251+ auto system_port = m_systemPortOidMap[sp_key];
10252+ // Check if the system_port_info is already populated in m_systemPortOidMap.
10253+ if (system_port.info_valid )
10254+ {
10255+ port.m_system_port_oid = system_port.system_port_id ;
10256+ port.m_system_port_info = system_port.system_port_info ;
10257+ port.m_system_port_info .local_port_oid = port.m_port_id ;
10258+ // initializeVoqs(port);
10259+ SWSS_LOG_NOTICE (" Updated system port for %s with system_port_alias:%s switch_id:%d, core_index:%d, core_port_index:%d" ,
10260+ port.m_alias .c_str (), system_port.system_port_info .alias .c_str (), system_port.system_port_info .switch_id ,
10261+ system_port.system_port_info .core_index , system_port.system_port_info .core_port_index );
10262+ }
10263+ }
10264+ }
10265+ if (port.m_system_port_info .alias .empty ())
10266+ {
10267+ SWSS_LOG_ERROR (" SYSTEM PORT Information is not updated for %s" , port.m_alias .c_str ());
10268+ }
10269+ }
10270+ }
10271+
10272+
1019710273bool PortsOrch::getInbandPort (Port &port)
1019810274{
1019910275 if (m_portList.find (m_inbandPortName) == m_portList.end ())
0 commit comments