Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions syncd/AsicView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ void AsicView::fromDump(
m_soInsegs[o->m_str_object_id] = o;
break;

case SAI_OBJECT_TYPE_MY_SID_ENTRY:
sai_deserialize_my_sid_entry(o->m_str_object_id, o->m_meta_key.objectkey.key.my_sid_entry);
m_soMySidEntries[o->m_str_object_id] = o;
break;

default:

if (o->m_info->isnonobjectid)
Expand Down Expand Up @@ -710,6 +715,10 @@ void AsicView::asicCreateObject(
m_soInsegs[currentObj->m_str_object_id] = currentObj;
break;

case SAI_OBJECT_TYPE_MY_SID_ENTRY:
m_soMySidEntries[currentObj->m_str_object_id] = currentObj;
break;

default:

SWSS_LOG_THROW("unsupported object type: %s",
Expand Down Expand Up @@ -858,6 +867,10 @@ void AsicView::asicRemoveObject(
m_soInsegs.erase(currentObj->m_str_object_id);
break;

case SAI_OBJECT_TYPE_MY_SID_ENTRY:
m_soMySidEntries.erase(currentObj->m_str_object_id);
break;

default:

SWSS_LOG_THROW("unsupported object type: %s",
Expand Down
1 change: 1 addition & 0 deletions syncd/AsicView.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ namespace syncd
StrObjectIdToSaiObjectHash m_soRoutes;
StrObjectIdToSaiObjectHash m_soNatEntries;
StrObjectIdToSaiObjectHash m_soInsegs;
StrObjectIdToSaiObjectHash m_soMySidEntries;
StrObjectIdToSaiObjectHash m_soOids;
StrObjectIdToSaiObjectHash m_soAll;

Expand Down
80 changes: 80 additions & 0 deletions syncd/BestCandidateFinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2274,6 +2274,83 @@ std::shared_ptr<SaiObj> BestCandidateFinder::findCurrentBestMatchForInsegEntry(
currentInsegObj->getObjectStatus());
}

/**
* @brief Find current best match for my sid entry.
*
* For my sid entry we don't need to iterate via all current my sid entries, we
* can do dictionary lookup, but we need to do smart trick, since temporary
* object was processed we just need to check whether VID in my_sid_entry struct
* is matched/final and it has RID assigned from current view. If RID exists, we
* can use that RID to get VID of current view, exchange in my_sid_entry struct
* and do dictionary lookup on serialized my_sid_entry.
*
* With this approach for many entries this is the quickest possible way. In
* case when RID doesn't exist, that means we have invalid my sid entry, so we
* must return null.
*
* @param temporaryObj Temporary object.
*
* @return Best match object if found or nullptr.
*/
std::shared_ptr<SaiObj> BestCandidateFinder::findCurrentBestMatchForMySidEntry(
_In_ const std::shared_ptr<const SaiObj> &temporaryObj)
{
SWSS_LOG_ENTER();

/*
* Make a copy here to not destroy object data, later
* on this data should be read only.
*/

sai_object_meta_key_t mk = temporaryObj->m_meta_key;

if (!exchangeTemporaryVidToCurrentVid(mk))
{
/*
* Not all oids inside struct object were translated, so there is no
* matching object in current view, we need to return null.
*/

return nullptr;
}

std::string str_my_sid_entry = sai_serialize_my_sid_entry(mk.objectkey.key.my_sid_entry);

/*
* Now when we have serialized my sid entry with temporary vr_id VID
* replaced to current vr_id VID we can do dictionary lookup for my sid entry.
*/
auto currentMySidIt = m_currentView.m_soMySidEntries.find(str_my_sid_entry);

if (currentMySidIt == m_currentView.m_soMySidEntries.end())
{
SWSS_LOG_DEBUG("unable to find my sid entry %s in current asic view", str_my_sid_entry.c_str());

return nullptr;
}

/*
* We found the same my sid entry in current view! Just one extra check
* of object status if it's not processed yet.
*/

auto currentMySidObj = currentMySidIt->second;

if (currentMySidObj->getObjectStatus() == SAI_OBJECT_STATUS_NOT_PROCESSED)
{
return currentMySidObj;
}

/*
* If we are here, that means this my sid entry was already processed, which
* can indicate a bug or somehow duplicated entries.
*/

SWSS_LOG_THROW("found my sid entry %s in current view, but it status is %d, FATAL",
str_my_sid_entry.c_str(),
currentMySidObj->getObjectStatus());
}

/**
* @brief Find current best match for FDB.
*
Expand Down Expand Up @@ -2517,6 +2594,9 @@ std::shared_ptr<SaiObj> BestCandidateFinder::findCurrentBestMatch(
case SAI_OBJECT_TYPE_INSEG_ENTRY:
return findCurrentBestMatchForInsegEntry(temporaryObj);

case SAI_OBJECT_TYPE_MY_SID_ENTRY:
return findCurrentBestMatchForMySidEntry(temporaryObj);

/*
* We can have special case for switch since we know there should
* be only one switch.
Expand Down
3 changes: 3 additions & 0 deletions syncd/BestCandidateFinder.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ namespace syncd
std::shared_ptr<SaiObj> findCurrentBestMatchForInsegEntry(
_In_ const std::shared_ptr<const SaiObj> &temporaryObj);

std::shared_ptr<SaiObj> findCurrentBestMatchForMySidEntry(
_In_ const std::shared_ptr<const SaiObj> &temporaryObj);

private:

bool exchangeTemporaryVidToCurrentVid(
Expand Down
4 changes: 4 additions & 0 deletions syncd/ComparisonLogic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,10 @@ void ComparisonLogic::createNewObjectFromTemporaryObject(
currentObj->m_str_object_id = sai_serialize_inseg_entry(currentObj->m_meta_key.objectkey.key.inseg_entry);
break;

case SAI_OBJECT_TYPE_MY_SID_ENTRY:
currentObj->m_str_object_id = sai_serialize_my_sid_entry(currentObj->m_meta_key.objectkey.key.my_sid_entry);
break;

default:

SWSS_LOG_THROW("unexpected non object id type: %s",
Expand Down
1 change: 1 addition & 0 deletions tests/aspell.en.pws
Original file line number Diff line number Diff line change
Expand Up @@ -534,3 +534,4 @@ truthy
glibc
getopt
optind
sid
1 change: 1 addition & 0 deletions unittest/syncd/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ tests_SOURCES = main.cpp \
MockHelper.cpp \
MockableSaiSwitchInterface.cpp \
TestBestCandidateFinder.cpp \
TestMySidWarmboot.cpp \
TestAttrVersionChecker.cpp \
TestCommandLineOptions.cpp \
TestConcurrentQueue.cpp \
Expand Down
Loading
Loading