Skip to content

Commit 5d3b0ae

Browse files
Populate the Voq system Port information for the local port when the Port is removed and created when the Speed is changed dynamically via GCU
Signed-off-by: saksarav <[email protected]>
1 parent 0e1558e commit 5d3b0ae

File tree

3 files changed

+93
-3
lines changed

3 files changed

+93
-3
lines changed

orchagent/intfsorch.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1698,6 +1698,11 @@ void IntfsOrch::voqSyncAddIntf(string &alias)
16981698
return;
16991699
}
17001700

1701+
if(alias.empty())
1702+
{
1703+
SWSS_LOG_ERROR("System Port/LAG alias is empty for %s!", port.m_alias.c_str());
1704+
return;
1705+
}
17011706

17021707
string oper_status = port.m_oper_status == SAI_PORT_OPER_STATUS_UP ? "up" : "down";
17031708

orchagent/portsorch.cpp

Lines changed: 78 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
1019710273
bool PortsOrch::getInbandPort(Port &port)
1019810274
{
1019910275
if (m_portList.find(m_inbandPortName) == m_portList.end())

orchagent/portsorch.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,13 @@ struct queueInfo
117117
sai_uint8_t index;
118118
};
119119

120+
struct systemPortMapInfo
121+
{
122+
sai_object_id_t system_port_id;
123+
SystemPortInfo system_port_info;
124+
bool info_valid = false;
125+
};
126+
120127
template<typename T>
121128
struct PortCapability
122129
{
@@ -264,6 +271,7 @@ class PortsOrch : public Orch, public Subject
264271
unique_ptr<Table> m_counterLagTable;
265272
unique_ptr<Table> m_portTable;
266273
unique_ptr<Table> m_sendToIngressPortTable;
274+
unique_ptr<Table> m_systemPortTable;
267275
unique_ptr<Table> m_gearboxTable;
268276
unique_ptr<CounterNameMapUpdater> m_queueCounterNameMapUpdater;
269277
unique_ptr<Table> m_voqTable;
@@ -544,10 +552,11 @@ class PortsOrch : public Orch, public Subject
544552
map<string, Port::Role> m_recircPortRole;
545553

546554
//map key is tuple of <attached_switch_id, core_index, core_port_index>
547-
map<tuple<int, int, int>, sai_object_id_t> m_systemPortOidMap;
555+
map<tuple<int, int, int>, systemPortMapInfo> m_systemPortOidMap;
548556
sai_uint32_t m_systemPortCount;
549557
bool getSystemPorts();
550558
bool addSystemPorts();
559+
void updateSystemPort(Port &port);
551560
unique_ptr<Table> m_tableVoqSystemLagTable;
552561
unique_ptr<Table> m_tableVoqSystemLagMemberTable;
553562
void voqSyncAddLag(Port &lag);

0 commit comments

Comments
 (0)