Skip to content

Commit 691bd30

Browse files
[voq/systemlag] Voq system lag functionality (sonic-net#1605)
* [voq/systemlag] VOQ System lag functionality Signed-off-by: vedganes <[email protected]> Changes for voq system lag implementation (1) Portsorch changes for allocating unique lag id from chassis ap pdb and sending the id in system port aggregator id attribute while creating lag local LAG (2) Portsorch changes to synd local LAG and local LAG members to chassis app db. The sync-ing includes the allocated unique system lag id (3) Portsorch changes to process remote system lag from chassis app db and create lag entry in local asic db with received system lag id (4) Interface orch changes to identify local or remote interfaces (for both port and lag) (5) Orchdaemon changes in orchagent intialization to get hostname and asic_name attributes from DEVICE_METATDATA. These are used for unique system lag name derivation * [vog/systemlag] VS test for system lag
1 parent fa983d2 commit 691bd30

16 files changed

+780
-36
lines changed

orchagent/Makefile.am

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ dist_swss_DATA = \
1515
port_rates.lua \
1616
watermark_queue.lua \
1717
watermark_pg.lua \
18-
watermark_bufferpool.lua
18+
watermark_bufferpool.lua \
19+
lagids.lua
1920

2021
bin_PROGRAMS = orchagent routeresync orchagent_restart_check
2122

@@ -62,7 +63,8 @@ orchagent_SOURCES = \
6263
debugcounterorch.cpp \
6364
natorch.cpp \
6465
muxorch.cpp \
65-
macsecorch.cpp
66+
macsecorch.cpp \
67+
lagid.cpp
6668

6769
orchagent_SOURCES += flex_counter/flex_counter_manager.cpp flex_counter/flex_counter_stat_manager.cpp
6870
orchagent_SOURCES += debug_counter/debug_counter.cpp debug_counter/drop_counter.cpp

orchagent/intfsorch.cpp

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ extern BufferOrch *gBufferOrch;
3535
extern bool gIsNatSupported;
3636
extern NeighOrch *gNeighOrch;
3737
extern string gMySwitchType;
38+
extern int32_t gVoqMySwitchId;
3839

3940
const int intfsorch_pri = 35;
4041

@@ -1410,9 +1411,14 @@ bool IntfsOrch::isRemoteSystemPortIntf(string alias)
14101411
Port port;
14111412
if(gPortsOrch->getPort(alias, port))
14121413
{
1414+
if (port.m_type == Port::LAG)
1415+
{
1416+
return(port.m_system_lag_info.switch_id != gVoqMySwitchId);
1417+
}
1418+
14131419
return(port.m_system_port_info.type == SAI_SYSTEM_PORT_TYPE_REMOTE);
14141420
}
1415-
//Given alias is system port alias of the local port
1421+
//Given alias is system port alias of the local port/LAG
14161422
return false;
14171423
}
14181424

@@ -1423,11 +1429,22 @@ void IntfsOrch::voqSyncAddIntf(string &alias)
14231429
Port port;
14241430
if(gPortsOrch->getPort(alias, port))
14251431
{
1426-
if(port.m_system_port_info.type == SAI_SYSTEM_PORT_TYPE_REMOTE)
1432+
if (port.m_type == Port::LAG)
14271433
{
1428-
return;
1434+
if (port.m_system_lag_info.switch_id != gVoqMySwitchId)
1435+
{
1436+
return;
1437+
}
1438+
alias = port.m_system_lag_info.alias;
1439+
}
1440+
else
1441+
{
1442+
if(port.m_system_port_info.type == SAI_SYSTEM_PORT_TYPE_REMOTE)
1443+
{
1444+
return;
1445+
}
1446+
alias = port.m_system_port_info.alias;
14291447
}
1430-
alias = port.m_system_port_info.alias;
14311448
}
14321449
else
14331450
{
@@ -1449,11 +1466,22 @@ void IntfsOrch::voqSyncDelIntf(string &alias)
14491466
Port port;
14501467
if(gPortsOrch->getPort(alias, port))
14511468
{
1452-
if(port.m_system_port_info.type == SAI_SYSTEM_PORT_TYPE_REMOTE)
1469+
if (port.m_type == Port::LAG)
14531470
{
1454-
return;
1471+
if (port.m_system_lag_info.switch_id != gVoqMySwitchId)
1472+
{
1473+
return;
1474+
}
1475+
alias = port.m_system_lag_info.alias;
1476+
}
1477+
else
1478+
{
1479+
if(port.m_system_port_info.type == SAI_SYSTEM_PORT_TYPE_REMOTE)
1480+
{
1481+
return;
1482+
}
1483+
alias = port.m_system_port_info.alias;
14551484
}
1456-
alias = port.m_system_port_info.alias;
14571485
}
14581486
else
14591487
{

orchagent/main.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ string gMySwitchType = "";
6767
int32_t gVoqMySwitchId = -1;
6868
int32_t gVoqMaxCores = 0;
6969
uint32_t gCfgSystemPorts = 0;
70+
string gMyHostName = "";
71+
string gMyAsicName = "";
7072

7173
void usage()
7274
{
@@ -212,6 +214,34 @@ bool getSystemPortConfigList(DBConnector *cfgDb, DBConnector *appDb, vector<sai_
212214
return false;
213215
}
214216

217+
if (!cfgDeviceMetaDataTable.hget("localhost", "hostname", value))
218+
{
219+
// hostname is not configured.
220+
SWSS_LOG_ERROR("Host name is not configured");
221+
return false;
222+
}
223+
gMyHostName = value;
224+
225+
if (!gMyHostName.size())
226+
{
227+
SWSS_LOG_ERROR("Invalid host name %s configured", gMyHostName.c_str());
228+
return false;
229+
}
230+
231+
if (!cfgDeviceMetaDataTable.hget("localhost", "asic_name", value))
232+
{
233+
// asic_name is not configured.
234+
SWSS_LOG_ERROR("Asic name is not configured");
235+
return false;
236+
}
237+
gMyAsicName = value;
238+
239+
if (!gMyAsicName.size())
240+
{
241+
SWSS_LOG_ERROR("Invalid asic name %s configured", gMyAsicName.c_str());
242+
return false;
243+
}
244+
215245
vector<string> spKeys;
216246
cfgSystemPortTable.getKeys(spKeys);
217247

orchagent/neighorch.cpp

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ extern RouteOrch *gRouteOrch;
1818
extern FgNhgOrch *gFgNhgOrch;
1919
extern Directory<Orch*> gDirectory;
2020
extern string gMySwitchType;
21+
extern int32_t gVoqMySwitchId;
2122

2223
const int neighorch_pri = 30;
2324

@@ -1116,7 +1117,6 @@ void NeighOrch::doVoqSystemNeighTask(Consumer &consumer)
11161117
}
11171118
else
11181119
{
1119-
SWSS_LOG_ERROR("Failed to add voq neighbor %s to SAI", kfvKey(t).c_str());
11201120
it++;
11211121
}
11221122
}
@@ -1141,7 +1141,6 @@ void NeighOrch::doVoqSystemNeighTask(Consumer &consumer)
11411141
}
11421142
else
11431143
{
1144-
SWSS_LOG_ERROR("Failed to remove voq neighbor %s from SAI", kfvKey(t).c_str());
11451144
it++;
11461145
}
11471146
}
@@ -1232,11 +1231,22 @@ void NeighOrch::voqSyncAddNeigh(string &alias, IpAddress &ip_address, const MacA
12321231
Port port;
12331232
if(gPortsOrch->getPort(alias, port))
12341233
{
1235-
if(port.m_system_port_info.type == SAI_SYSTEM_PORT_TYPE_REMOTE)
1234+
if (port.m_type == Port::LAG)
12361235
{
1237-
return;
1236+
if (port.m_system_lag_info.switch_id != gVoqMySwitchId)
1237+
{
1238+
return;
1239+
}
1240+
alias = port.m_system_lag_info.alias;
1241+
}
1242+
else
1243+
{
1244+
if(port.m_system_port_info.type == SAI_SYSTEM_PORT_TYPE_REMOTE)
1245+
{
1246+
return;
1247+
}
1248+
alias = port.m_system_port_info.alias;
12381249
}
1239-
alias = port.m_system_port_info.alias;
12401250
}
12411251
else
12421252
{
@@ -1278,11 +1288,22 @@ void NeighOrch::voqSyncDelNeigh(string &alias, IpAddress &ip_address)
12781288
Port port;
12791289
if(gPortsOrch->getPort(alias, port))
12801290
{
1281-
if(port.m_system_port_info.type == SAI_SYSTEM_PORT_TYPE_REMOTE)
1291+
if (port.m_type == Port::LAG)
12821292
{
1283-
return;
1293+
if (port.m_system_lag_info.switch_id != gVoqMySwitchId)
1294+
{
1295+
return;
1296+
}
1297+
alias = port.m_system_lag_info.alias;
1298+
}
1299+
else
1300+
{
1301+
if(port.m_system_port_info.type == SAI_SYSTEM_PORT_TYPE_REMOTE)
1302+
{
1303+
return;
1304+
}
1305+
alias = port.m_system_port_info.alias;
12841306
}
1285-
alias = port.m_system_port_info.alias;
12861307
}
12871308
else
12881309
{

orchagent/orchdaemon.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ bool OrchDaemon::init()
102102
};
103103

104104
gCrmOrch = new CrmOrch(m_configDb, CFG_CRM_TABLE_NAME);
105-
gPortsOrch = new PortsOrch(m_applDb, ports_tables);
105+
gPortsOrch = new PortsOrch(m_applDb, ports_tables, m_chassisAppDb);
106106
TableConnector stateDbFdb(m_stateDb, STATE_FDB_TABLE_NAME);
107107
gFdbOrch = new FdbOrch(m_applDb, app_fdb_tables, stateDbFdb, gPortsOrch);
108108

orchagent/port.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ struct SystemPortInfo
5151
uint32_t num_voq = 8;
5252
};
5353

54+
struct SystemLagInfo
55+
{
56+
std::string alias = "";
57+
int32_t switch_id = -1;
58+
int32_t spa_id = 0;
59+
};
60+
5461
class Port
5562
{
5663
public:
@@ -142,6 +149,7 @@ class Port
142149

143150
sai_object_id_t m_system_port_oid = 0;
144151
SystemPortInfo m_system_port_info;
152+
SystemLagInfo m_system_lag_info;
145153

146154
};
147155

0 commit comments

Comments
 (0)