Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of System ports initialization, Interface & Neighbor Synchronization... #1431

Merged
merged 30 commits into from Jan 17, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
30c8a0c
[voq] Redis instance for global app db
Sep 10, 2020
bfb6f2f
[voq] System port init and orchestration
Sep 10, 2020
ee967d9
[voq] Router interface for system ports, global app db sync
Sep 10, 2020
45942e7
[voq] Inband interface config
Sep 10, 2020
10771a8
[voq] System port neighbors
Sep 10, 2020
2ca2a00
[swss] Review comments fixes
Sep 29, 2020
8e235e6
[swss]Code review comments fix 2
Oct 1, 2020
52fe3e1
Merge branch 'master' into chassis-voq-pr1
vganesan-nokia Oct 1, 2020
1b6d62f
Merge branch 'master' into chassis-voq-pr1
vganesan-nokia Oct 11, 2020
8704004
[swss] voq code review comment fix 3
Oct 12, 2020
8b68af4
[swss] voq code review comments fixes 4
Oct 13, 2020
52972b6
[swss] Voq code review comments fixes 5
Oct 22, 2020
b6fe4e6
Merge branch 'master' into chassis-voq-pr1
vganesan-nokia Nov 3, 2020
34e9f68
[swss]VS tests for VOQ system ports
Nov 9, 2020
a42d3f5
[vstest]Voq switch test - removed chassis_db.json
Nov 20, 2020
8922f46
[vstest]VOQ switch system ports test
Nov 21, 2020
d9df781
[swss]VOQ Code review comments fix 6
Nov 21, 2020
39b1858
Merge branch 'master' into chassis-voq-pr1
vganesan-nokia Nov 30, 2020
21b7cd6
Merge branch 'master' into chassis-voq-pr1
vganesan-nokia Dec 2, 2020
233a1be
[swss]vs test for voq neighbor
Dec 3, 2020
e9fc950
[swss]vs test for voq nbr review comments fix 1
Dec 8, 2020
ae86130
[swss]vs test for voq nbr review comments fix 2
Dec 9, 2020
2d090d5
Merge branch 'master' into chassis-voq-pr1
vganesan-nokia Dec 18, 2020
d93ea79
[systemport]VOQ system port code review comments fix - 7
Dec 22, 2020
40fb3fc
[systemport] VS test chgs in code review comments fix - 7 reverted
Dec 22, 2020
a5c2533
Merge branch 'master' into chassis-voq-pr1
vganesan-nokia Dec 23, 2020
96d5a71
[systemport] Rebase to master, neighorch conflict fix
Dec 23, 2020
5878628
Merge remote-tracking branch 'vganesan-nokia/master' into chassis-voq…
Jan 12, 2021
0ab5d95
Merge remote-tracking branch 'origin/master' into chassis-voq-pr1
Jan 15, 2021
08b256b
[voq] azure-pipeline armhf build error fix
Jan 15, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
149 changes: 149 additions & 0 deletions orchagent/main.cpp
Expand Up @@ -62,6 +62,11 @@ extern bool gIsNatSupported;
ofstream gRecordOfs;
string gRecordFile;

string gMySwitchType = "";
int32_t gVoqMySwitchId = -1;
int32_t gVoqMaxCores = 0;
uint32_t gCfgSystemPorts = 0;

void usage()
{
cout << "usage: orchagent [-h] [-r record_type] [-d record_location] [-b batch_size] [-m MAC] [-i INST_ID] [-s]" << endl;
Expand Down Expand Up @@ -140,6 +145,121 @@ void init_gearbox_phys(DBConnector *applDb)
delete tmpGearboxTable;
}

bool getSystemPortConfigList(vector<sai_system_port_config_t> &sysportcfglist)
{
DBConnector cfgDb("CONFIG_DB", 0);
DBConnector appDb("APPL_DB", 0);
minionatwork marked this conversation as resolved.
Show resolved Hide resolved

Table cfgDeviceMetaDataTable(&cfgDb, CFG_DEVICE_METADATA_TABLE_NAME);
Table cfgSystemPortTable(&cfgDb, CFG_SYSTEM_PORT_TABLE_NAME);
Table appSystemPortTable(&appDb, APP_SYSTEM_PORT_TABLE_NAME);

//At this point of time (i.e, at the time of orchagent start), the CONFIG_DB is completely fully
minionatwork marked this conversation as resolved.
Show resolved Hide resolved
//populated with the contents of config_db.json.

string value;
//Get the swith type.
if(!cfgDeviceMetaDataTable.hget("localhost", "switch_type", value))
minionatwork marked this conversation as resolved.
Show resolved Hide resolved
minionatwork marked this conversation as resolved.
Show resolved Hide resolved
{
//Switch type is not configured. Consider it default = "switch" (regular switch)
value = "switch";
}

if(value != "voq" && value != "fabric" && value != "switch")
{
cout << "Invalid switch type " << value.c_str() << " configured";
return false;
}
gMySwitchType = value;

if(gMySwitchType != "voq")
{
//Non VOQ switch. Nothing to read
return true;
}

if(!cfgDeviceMetaDataTable.hget("localhost", "switch_id", value))
{
//VOQ switch id is not configured.
cout << "VOQ switch id is not configured";
return false;
}

if(value.size())
gVoqMySwitchId = stoi(value);

if(gVoqMySwitchId < 0)
{
cout << "Invalid VOQ switch id " << gVoqMySwitchId << " configured";
return false;
}

if(!cfgDeviceMetaDataTable.hget("localhost", "max_cores", value))
{
//VOQ max cores is not configured.
cout << "VOQ max cores is not configured";
return false;
}

if(value.size())
gVoqMaxCores = stoi(value);

if(gVoqMaxCores == 0)
{
cout << "Invalid VOQ max cores " << gVoqMaxCores << " configured";
return false;
}

vector<string> spKeys;
cfgSystemPortTable.getKeys(spKeys);

//Retrieve system port configurations
vector<FieldValueTuple> spFv;
sai_system_port_config_t sysport;
for ( auto &k : spKeys )
minionatwork marked this conversation as resolved.
Show resolved Hide resolved
{
cfgSystemPortTable.get(k, spFv);

for ( auto &fv : spFv )
{
if(fv.first == "switch_id")
{
sysport.attached_switch_id = stoi(fv.second);
continue;
}
if(fv.first == "core_index")
{
sysport.attached_core_index = stoi(fv.second);
continue;
}
if(fv.first == "core_port_index")
{
sysport.attached_core_port_index = stoi(fv.second);
continue;
}
if(fv.first == "speed")
{
sysport.speed = stoi(fv.second);
continue;
}
if(fv.first == "system_port_id")
{
sysport.port_id = stoi(fv.second);
continue;
}
minionatwork marked this conversation as resolved.
Show resolved Hide resolved
}
//Add to system port config list
sysportcfglist.push_back(sysport);

//Also push to APP DB
appSystemPortTable.set(k, spFv);
}

SWSS_LOG_NOTICE("Created System Port config list for %d system ports", (int32_t) sysportcfglist.size());

return true;
}

int main(int argc, char **argv)
{
swss::Logger::linkToDbNative("orchagent");
Expand Down Expand Up @@ -286,6 +406,35 @@ int main(int argc, char **argv)
attrs.push_back(attr);
}

//Get info required for VOQ system
vector<sai_system_port_config_t> sysportconfiglist;
if(getSystemPortConfigList(sysportconfiglist))
minionatwork marked this conversation as resolved.
Show resolved Hide resolved
{
if (gMySwitchType == "voq")
minionatwork marked this conversation as resolved.
Show resolved Hide resolved
{
attr.id = SAI_SWITCH_ATTR_TYPE;
attr.value.u32 = SAI_SWITCH_TYPE_VOQ;
attrs.push_back(attr);

attr.id = SAI_SWITCH_ATTR_SWITCH_ID;
attr.value.u32 = gVoqMySwitchId;
attrs.push_back(attr);

attr.id = SAI_SWITCH_ATTR_MAX_SYSTEM_CORES;
attr.value.u32 = gVoqMaxCores;
attrs.push_back(attr);

gCfgSystemPorts = (uint32_t) sysportconfiglist.size();
if(gCfgSystemPorts)
{
attr.id = SAI_SWITCH_ATTR_SYSTEM_PORT_CONFIG_LIST;
attr.value.sysportconfiglist.count = gCfgSystemPorts;
attr.value.sysportconfiglist.list = sysportconfiglist.data();
attrs.push_back(attr);
}
}
}

status = sai_switch_api->create_switch(&gSwitchId, (uint32_t)attrs.size(), attrs.data());
if (status != SAI_STATUS_SUCCESS)
{
Expand Down
18 changes: 18 additions & 0 deletions orchagent/port.h
Expand Up @@ -36,6 +36,19 @@ struct VlanInfo
sai_vlan_id_t vlan_id = 0;
};

struct SystemPortInfo
{
std::string alias = "";
sai_system_port_type_t type;
sai_object_id_t local_port_oid = 0;
uint32_t port_id = 0;
uint32_t switch_id = 0;
uint32_t core_index = 0;
uint32_t core_port_index = 0;
uint32_t speed = 400000;
uint32_t num_voq = 8;
};

class Port
{
public:
Expand All @@ -47,6 +60,7 @@ class Port
VLAN,
LAG,
SUBPORT,
SYSTEM,
UNKNOWN
} ;

Expand Down Expand Up @@ -114,6 +128,10 @@ class Port

std::unordered_set<sai_object_id_t> m_ingress_acl_tables_uset;
std::unordered_set<sai_object_id_t> m_egress_acl_tables_uset;

sai_object_id_t m_system_port_oid = 0;
SystemPortInfo m_system_port_info;

};

}
Expand Down