Skip to content

Commit 322d4c2

Browse files
author
vedganes
committedAug 9, 2020
[swss]voq changes
1 parent ea30f2f commit 322d4c2

21 files changed

+1326
-23
lines changed
 

‎cfgmgr/intfmgr.cpp

+76
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,13 @@ void IntfMgr::doTask(Consumer &consumer)
613613
{
614614
SWSS_LOG_ENTER();
615615

616+
string table_name = consumer.getTableName();
617+
if(table_name == CFG_VOQ_INBAND_INTERFACE_TABLE_NAME)
618+
{
619+
doCfgVoqInbandInterfaceTask(consumer);
620+
return;
621+
}
622+
616623
auto it = consumer.m_toSync.begin();
617624
while (it != consumer.m_toSync.end())
618625
{
@@ -646,3 +653,72 @@ void IntfMgr::doTask(Consumer &consumer)
646653
it = consumer.m_toSync.erase(it);
647654
}
648655
}
656+
657+
void IntfMgr::doCfgVoqInbandInterfaceTask(Consumer &consumer)
658+
{
659+
SWSS_LOG_ENTER();
660+
661+
string inband_type="";
662+
663+
auto it = consumer.m_toSync.begin();
664+
while (it != consumer.m_toSync.end())
665+
{
666+
KeyOpFieldsValuesTuple t = it->second;
667+
668+
vector<string> keys = tokenize(kfvKey(t), config_db_key_delimiter);
669+
const vector<FieldValueTuple>& data = kfvFieldsValues(t);
670+
string op = kfvOp(t);
671+
string alias(keys[0]);
672+
673+
if (keys.size() == 1)
674+
{
675+
for (auto idx : data)
676+
{
677+
const auto &field = fvField(idx);
678+
const auto &value = fvValue(idx);
679+
680+
if (field == "inband_type")
681+
{
682+
inband_type = value;
683+
}
684+
685+
}
686+
687+
if(inband_type == "port")
688+
{
689+
if(op == SET_COMMAND)
690+
{
691+
//For "port" type inband interface no further processing is needed.
692+
m_appIntfTableProducer.set(alias, data);
693+
m_stateIntfTable.hset(alias, "vrf", "");
694+
}
695+
else if(op == DEL_COMMAND)
696+
{
697+
if (!doIntfGeneralTask(keys, data, op))
698+
{
699+
it++;
700+
continue;
701+
}
702+
}
703+
}
704+
else
705+
{
706+
SWSS_LOG_ERROR("%s type Inband interface not supported! i/f: %s", inband_type.c_str(), kfvKey(t).c_str());
707+
}
708+
}
709+
else if (keys.size() == 2)
710+
{
711+
if (!doIntfAddrTask(keys, data, op))
712+
{
713+
it++;
714+
continue;
715+
}
716+
}
717+
else
718+
{
719+
SWSS_LOG_ERROR("Invalid key %s", kfvKey(t).c_str());
720+
}
721+
722+
it = consumer.m_toSync.erase(it);
723+
}
724+
}

‎cfgmgr/intfmgr.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class IntfMgr : public Orch
3030
bool doIntfGeneralTask(const std::vector<std::string>& keys, std::vector<FieldValueTuple> data, const std::string& op);
3131
bool doIntfAddrTask(const std::vector<std::string>& keys, const std::vector<FieldValueTuple>& data, const std::string& op);
3232
void doTask(Consumer &consumer);
33-
33+
void doCfgVoqInbandInterfaceTask(Consumer &consumer);
3434
bool isIntfStateOk(const std::string &alias);
3535
bool isIntfCreated(const std::string &alias);
3636
bool isIntfChangeVrf(const std::string &alias, const std::string &vrfName);

‎cfgmgr/intfmgrd.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ int main(int argc, char **argv)
4747
CFG_VLAN_INTF_TABLE_NAME,
4848
CFG_LOOPBACK_INTERFACE_TABLE_NAME,
4949
CFG_VLAN_SUB_INTF_TABLE_NAME,
50+
CFG_VOQ_INBAND_INTERFACE_TABLE_NAME,
5051
};
5152

5253
DBConnector cfgDb("CONFIG_DB", 0);

‎orchagent/intfsorch.cpp

+130-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "bufferorch.h"
1717
#include "directory.h"
1818
#include "vnetorch.h"
19+
#include "subscriberstatetable.h"
1920

2021
extern sai_object_id_t gVirtualRouterId;
2122
extern Directory<Orch*> gDirectory;
@@ -32,6 +33,7 @@ extern RouteOrch *gRouteOrch;
3233
extern CrmOrch *gCrmOrch;
3334
extern BufferOrch *gBufferOrch;
3435
extern bool gIsNatSupported;
36+
extern NeighOrch *gNeighOrch;
3537

3638
const int intfsorch_pri = 35;
3739

@@ -52,8 +54,9 @@ static const vector<sai_router_interface_stat_t> rifStatIds =
5254
SAI_ROUTER_INTERFACE_STAT_OUT_ERROR_OCTETS,
5355
};
5456

55-
IntfsOrch::IntfsOrch(DBConnector *db, string tableName, VRFOrch *vrf_orch) :
56-
Orch(db, tableName, intfsorch_pri), m_vrfOrch(vrf_orch)
57+
IntfsOrch::IntfsOrch(DBConnector *db, string tableName, VRFOrch *vrf_orch, DBConnector *voqDb) :
58+
Orch(db, tableName, intfsorch_pri), m_vrfOrch(vrf_orch),
59+
m_tableVoqSystemInterfaceTable(voqDb, VOQ_SYSTEM_INTERFACE_TABLE_NAME)
5760
{
5861
SWSS_LOG_ENTER();
5962

@@ -96,6 +99,11 @@ IntfsOrch::IntfsOrch(DBConnector *db, string tableName, VRFOrch *vrf_orch) :
9699
{
97100
SWSS_LOG_WARN("RIF flex counter group plugins was not set successfully: %s", e.what());
98101
}
102+
103+
//Add subscriber to process VOQ system interface
104+
tableName = VOQ_SYSTEM_INTERFACE_TABLE_NAME;
105+
Orch::addExecutor(new Consumer(new SubscriberStateTable(voqDb, tableName, TableConsumable::DEFAULT_POP_BATCH_SIZE, 0), this, tableName));
106+
99107
}
100108

101109
sai_object_id_t IntfsOrch::getRouterIntfsId(const string &alias)
@@ -430,6 +438,15 @@ bool IntfsOrch::setIntf(const string& alias, sai_object_id_t vrf_id, const IpPre
430438

431439
addIp2MeRoute(port.m_vr_id, *ip_prefix);
432440

441+
if(alias == gPortsOrch->m_inbandPortName)
442+
{
443+
gNeighOrch->addInbandNeighbor(alias, ip_prefix->getIp());
444+
445+
//There is no config to bring inband host if admin up. So bring the
446+
//admin up here after setting the Ip2me route for inband host if ip
447+
gPortsOrch->setSystemPortHostIfAdminUp(alias);
448+
}
449+
433450
if (port.m_type == Port::VLAN)
434451
{
435452
addDirectedBroadcast(port, *ip_prefix);
@@ -453,6 +470,11 @@ bool IntfsOrch::removeIntf(const string& alias, sai_object_id_t vrf_id, const Ip
453470
{
454471
removeIp2MeRoute(port.m_vr_id, *ip_prefix);
455472

473+
if(alias == gPortsOrch->m_inbandPortName)
474+
{
475+
gNeighOrch->delInbandNeighbor(alias, ip_prefix->getIp());
476+
}
477+
456478
if(port.m_type == Port::VLAN)
457479
{
458480
removeDirectedBroadcast(port, *ip_prefix);
@@ -497,6 +519,8 @@ void IntfsOrch::doTask(Consumer &consumer)
497519
return;
498520
}
499521

522+
string table_name = consumer.getTableName();
523+
500524
auto it = consumer.m_toSync.begin();
501525
while (it != consumer.m_toSync.end())
502526
{
@@ -521,6 +545,16 @@ void IntfsOrch::doTask(Consumer &consumer)
521545
ip_prefix_in_key = true;
522546
}
523547

548+
if(table_name == VOQ_SYSTEM_INTERFACE_TABLE_NAME)
549+
{
550+
if(!isRemoteSystemPortIntf(alias))
551+
{
552+
//Synced local interface. Skip
553+
it = consumer.m_toSync.erase(it);
554+
continue;
555+
}
556+
}
557+
524558
const vector<FieldValueTuple>& data = kfvFieldsValues(t);
525559
string vrf_name = "", vnet_name = "", nat_zone = "";
526560
MacAddress mac;
@@ -529,6 +563,7 @@ void IntfsOrch::doTask(Consumer &consumer)
529563
bool adminUp;
530564
uint32_t nat_zone_id = 0;
531565
string proxy_arp = "";
566+
string inband_type = "";
532567

533568
for (auto idx : data)
534569
{
@@ -608,6 +643,10 @@ void IntfsOrch::doTask(Consumer &consumer)
608643
{
609644
proxy_arp = value;
610645
}
646+
else if (field == "inband_type")
647+
{
648+
inband_type = value;
649+
}
611650
}
612651

613652
if (alias == "eth0" || alias == "docker0")
@@ -680,6 +719,11 @@ void IntfsOrch::doTask(Consumer &consumer)
680719
}
681720
}
682721

722+
if(inband_type == "port")
723+
{
724+
gPortsOrch->voqAddInbandHostIf(alias, port);
725+
}
726+
683727
if (m_vnetInfses.find(alias) != m_vnetInfses.end())
684728
{
685729
vnet_name = m_vnetInfses.at(alias);
@@ -892,6 +936,7 @@ bool IntfsOrch::addRouterIntfs(sai_object_id_t vrf_id, Port &port)
892936
{
893937
case Port::PHY:
894938
case Port::LAG:
939+
case Port::SYSTEM:
895940
attr.value.s32 = SAI_ROUTER_INTERFACE_TYPE_PORT;
896941
attrs.push_back(attr);
897942
break;
@@ -911,6 +956,7 @@ bool IntfsOrch::addRouterIntfs(sai_object_id_t vrf_id, Port &port)
911956
switch(port.m_type)
912957
{
913958
case Port::PHY:
959+
case Port::SYSTEM:
914960
attr.id = SAI_ROUTER_INTERFACE_ATTR_PORT_ID;
915961
attr.value.oid = port.m_port_id;
916962
attrs.push_back(attr);
@@ -975,6 +1021,9 @@ bool IntfsOrch::addRouterIntfs(sai_object_id_t vrf_id, Port &port)
9751021

9761022
SWSS_LOG_NOTICE("Create router interface %s MTU %u", port.m_alias.c_str(), port.m_mtu);
9771023

1024+
//Sync the interface to add to the SYSTEM_INTERFACE table of VOQ DB
1025+
voqSyncAddIntf(port.m_alias, port.m_rif_id);
1026+
9781027
return true;
9791028
}
9801029

@@ -1005,6 +1054,9 @@ bool IntfsOrch::removeRouterIntfs(Port &port)
10051054

10061055
SWSS_LOG_NOTICE("Remove router interface for port %s", port.m_alias.c_str());
10071056

1057+
//Sync the interface to del from the SYSTEM_INTERFACE table of VOQ DB
1058+
voqSyncDelIntf(port.m_alias);
1059+
10081060
return true;
10091061
}
10101062

@@ -1227,6 +1279,7 @@ void IntfsOrch::doTask(SelectableTimer &timer)
12271279
{
12281280
case Port::PHY:
12291281
case Port::LAG:
1282+
case Port::SYSTEM:
12301283
type = "SAI_ROUTER_INTERFACE_TYPE_PORT";
12311284
break;
12321285
case Port::VLAN:
@@ -1252,3 +1305,78 @@ void IntfsOrch::doTask(SelectableTimer &timer)
12521305
}
12531306
}
12541307
}
1308+
1309+
bool IntfsOrch::isRemoteSystemPortIntf(string alias)
1310+
{
1311+
Port port;
1312+
if(gPortsOrch->getPort(alias, port))
1313+
{
1314+
return(port.m_system_port_info.type == SAI_SYSTEM_PORT_TYPE_REMOTE);
1315+
}
1316+
//Given alias is system port alias of the local port
1317+
return false;
1318+
}
1319+
1320+
bool IntfsOrch::voqSyncAddIntf(string &alias, sai_object_id_t &rif_id)
1321+
{
1322+
//Sync only local interface. Confirm for the local interface and
1323+
//get the system port alias for key for syncing
1324+
Port port;
1325+
if(gPortsOrch->getPort(alias, port))
1326+
{
1327+
if(port.m_system_port_info.type == SAI_SYSTEM_PORT_TYPE_REMOTE)
1328+
{
1329+
return true;
1330+
}
1331+
}
1332+
alias = port.m_system_port_info.alias;
1333+
1334+
//Get router interface to make sure it exists
1335+
sai_attribute_t attr;
1336+
sai_status_t status;
1337+
1338+
attr.id = SAI_ROUTER_INTERFACE_ATTR_PORT_ID;
1339+
1340+
status = sai_router_intfs_api->get_router_interface_attribute(rif_id, 1, &attr);
1341+
if (status != SAI_STATUS_SUCCESS)
1342+
{
1343+
SWSS_LOG_ERROR("Failed to get rif for %s:0x%lx, rv:%d", alias.c_str(), rif_id, status);
1344+
return false;
1345+
}
1346+
1347+
//Get the Real ID of the RIF ID
1348+
string value;
1349+
const auto id = sai_serialize_object_id(rif_id);
1350+
1351+
if (m_vidToRidTable->hget("", id, value))
1352+
{
1353+
FieldValueTuple rifIdFv ("rif_id", value);
1354+
vector<FieldValueTuple> attrs;
1355+
attrs.push_back(rifIdFv);
1356+
1357+
m_tableVoqSystemInterfaceTable.set(alias, attrs);
1358+
return true;
1359+
}
1360+
SWSS_LOG_ERROR("Failed to get real ID from ASIC DB for RIF id 0x%lx of %s", rif_id, alias.c_str());
1361+
return false;
1362+
}
1363+
1364+
bool IntfsOrch::voqSyncDelIntf(string &alias)
1365+
{
1366+
//Sync only local interface. Confirm for the local interface and
1367+
//get the system port alias for key for syncing to global VOQ DB
1368+
Port port;
1369+
if(gPortsOrch->getPort(alias, port))
1370+
{
1371+
if(port.m_system_port_info.type == SAI_SYSTEM_PORT_TYPE_REMOTE)
1372+
{
1373+
return true;
1374+
}
1375+
}
1376+
alias = port.m_system_port_info.alias;
1377+
1378+
m_tableVoqSystemInterfaceTable.del(alias);
1379+
1380+
return true;
1381+
}
1382+

‎orchagent/intfsorch.h

+8-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ typedef map<string, IntfsEntry> IntfsTable;
3232
class IntfsOrch : public Orch
3333
{
3434
public:
35-
IntfsOrch(DBConnector *db, string tableName, VRFOrch *vrf_orch);
35+
IntfsOrch(DBConnector *db, string tableName, VRFOrch *vrf_orch, DBConnector *voqDb);
3636

3737
sai_object_id_t getRouterIntfsId(const string&);
3838
bool isPrefixSubnet(const IpPrefix&, const string&);
@@ -64,6 +64,8 @@ class IntfsOrch : public Orch
6464

6565
bool updateSyncdIntfPfx(const string &alias, const IpPrefix &ip_prefix, bool add = true);
6666

67+
bool isRemoteSystemPortIntf(string alias);
68+
6769
private:
6870

6971
SelectableTimer* m_updateMapsTimer = nullptr;
@@ -94,6 +96,11 @@ class IntfsOrch : public Orch
9496

9597
bool setIntfVlanFloodType(const Port &port, sai_vlan_flood_control_type_t vlan_flood_type);
9698
bool setIntfProxyArp(const string &alias, const string &proxy_arp);
99+
100+
Table m_tableVoqSystemInterfaceTable;
101+
bool voqSyncAddIntf(string &alias, sai_object_id_t &rif_id);
102+
bool voqSyncDelIntf(string &alias);
103+
97104
};
98105

99106
#endif /* SWSS_INTFSORCH_H */

0 commit comments

Comments
 (0)
Please sign in to comment.