Skip to content

Commit

Permalink
Support default queues and priority groups (sonic-net#79)
Browse files Browse the repository at this point in the history
* Support default queues and priority groups

* Change printf type

* Return empty list if not priority groups or queues

* Unify default objects
  • Loading branch information
kcudnik authored Oct 7, 2016
1 parent 6dfda77 commit 15e865f
Show file tree
Hide file tree
Showing 4 changed files with 294 additions and 82 deletions.
4 changes: 3 additions & 1 deletion syncd/syncd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1248,10 +1248,12 @@ bool isVeryFirstRun()

int main(int argc, char **argv)
{
swss::Logger::getInstance().setMinPrio(swss::Logger::SWSS_NOTICE);
swss::Logger::getInstance().setMinPrio(swss::Logger::SWSS_DEBUG);

SWSS_LOG_ENTER();

swss::Logger::getInstance().setMinPrio(swss::Logger::SWSS_NOTICE);

auto options = handleCmdLine(argc, argv);

handleProfileMap(options.profileMapFile);
Expand Down
8 changes: 8 additions & 0 deletions syncd/syncd.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,12 @@ std::unordered_map<sai_uint32_t, sai_object_id_t> redisGetLaneMap();

std::vector<sai_object_id_t> saiGetPortList();

typedef bool (*isDefaultFunction)(sai_object_id_t);

bool isDefaultQueueId(sai_object_id_t queueId);
bool isDefaultPriorityGroupId(sai_object_id_t pgId);
bool isDefaultVirtualRouterId(sai_object_id_t id);
bool isDefaultTrapGroupId(sai_object_id_t id);
bool isDefaultPortId(sai_object_id_t id);

#endif // __SYNCD_H__
108 changes: 49 additions & 59 deletions syncd/syncd_hard_reinit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,11 @@ void checkAllIds()
g_vidToRidMap.erase(it);
}

if (g_vidToRidMap.size() != 0)
size_t size = g_vidToRidMap.size();

if (size != 0)
{
SWSS_LOG_ERROR("vid to rid map is not empty after translation");
SWSS_LOG_ERROR("vid to rid map is not empty (%zu) after translation", size);

for (auto &kv: g_vidToRidMap)
{
Expand Down Expand Up @@ -207,6 +209,8 @@ void hardReinit()
{
SWSS_LOG_ENTER();

SWSS_LOG_TIMER("hard reinit");

saiRemoveDefaultVlanMembers();

// repopulate asic view from redis db after hard asic initialize
Expand Down Expand Up @@ -266,6 +270,33 @@ void hardReinit()
checkAllIds();
}

bool shouldSkipCreateion(
sai_object_id_t vid,
sai_object_id_t& rid,
bool& createObject,
isDefaultFunction fun)
{
auto it = g_vidToRidMap.find(vid);

if (it == g_vidToRidMap.end())
{
SWSS_LOG_ERROR("failed to find VID %llx in VIDTORID map", vid);

exit_and_notify(EXIT_FAILURE);
}

if (fun(it->second))
{
rid = it->second;

createObject = false;

return true;
}

return false;
}

sai_object_id_t processSingleVid(sai_object_id_t vid)
{
SWSS_LOG_ENTER();
Expand Down Expand Up @@ -299,79 +330,38 @@ sai_object_id_t processSingleVid(sai_object_id_t vid)

if (objectType == SAI_OBJECT_TYPE_VIRTUAL_ROUTER)
{
auto it = g_vidToRidMap.find(vid);

if (it == g_vidToRidMap.end())
if (shouldSkipCreateion(vid, rid, createObject, isDefaultVirtualRouterId))
{
SWSS_LOG_ERROR("failed to find VID %llx in VIDTORID map", vid);

exit_and_notify(EXIT_FAILURE);
SWSS_LOG_INFO("default virtual router will not be created, processed VID %llx to RID %llx", vid, rid);
}

sai_object_id_t virtualRouterRid = it->second;

sai_object_id_t defaultVirtualRouterId = redisGetDefaultVirtualRouterId();

if (virtualRouterRid == defaultVirtualRouterId)
}
else if (objectType == SAI_OBJECT_TYPE_QUEUE)
{
if (shouldSkipCreateion(vid, rid, createObject, isDefaultQueueId))
{
// this is default virtual router id
// we don't need to create it, just set attributes

rid = defaultVirtualRouterId;

createObject = false;

SWSS_LOG_INFO("default virtual router will not be created, processed VID %llx to RID %llx", vid, rid);
SWSS_LOG_DEBUG("default queue will not be created, processed VID %llx to RID %llx", vid, rid);
}

}
else if (objectType == SAI_OBJECT_TYPE_TRAP_GROUP)
else if (objectType == SAI_OBJECT_TYPE_PRIORITY_GROUP)
{
auto it = g_vidToRidMap.find(vid);

if (it == g_vidToRidMap.end())
if (shouldSkipCreateion(vid, rid, createObject, isDefaultPriorityGroupId))
{
SWSS_LOG_ERROR("failed to find VID %llx in VIDTORID map", vid);

exit_and_notify(EXIT_FAILURE);
SWSS_LOG_DEBUG("default priority group will not be created, processed VID %llx to RID %llx", vid, rid);
}

sai_object_id_t trapGroupRid = it->second;

sai_object_id_t defaultTrapGroupId = redisGetDefaultTrapGroupId();

if (trapGroupRid == defaultTrapGroupId)
}
else if (objectType == SAI_OBJECT_TYPE_TRAP_GROUP)
{
if (shouldSkipCreateion(vid, rid, createObject, isDefaultTrapGroupId))
{
// this is default trap group id
// we don't need to create it, just set attributes

rid = defaultTrapGroupId;

createObject = false;

SWSS_LOG_INFO("default trap group will not be created, processed VID %llx to RID %llx", vid, rid);
}

}
else if (objectType == SAI_OBJECT_TYPE_PORT)
{
// currently we assume that port id's don't change,
// so we can just treat previous rid as current rid

auto it = g_vidToRidMap.find(vid);

if (it == g_vidToRidMap.end())
if (shouldSkipCreateion(vid, rid, createObject, isDefaultPortId))
{
SWSS_LOG_ERROR("failed to find VID %llx in VIDTORID map", vid);

exit_and_notify(EXIT_FAILURE);
SWSS_LOG_INFO("port will not be created, processed VID %llx to RID %llx", vid, rid);
}

rid = it->second;

createObject = false;

SWSS_LOG_INFO("port will not be created, processed VID %llx to RID %llx", vid, rid);
}

auto oit = g_oids.find(strVid);
Expand Down
Loading

0 comments on commit 15e865f

Please sign in to comment.