Skip to content

Commit

Permalink
[syncd] Code clean (sonic-net#720)
Browse files Browse the repository at this point in the history
  • Loading branch information
kcudnik authored Nov 26, 2020
1 parent 56f5a21 commit f37413a
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 29 deletions.
13 changes: 5 additions & 8 deletions syncd/AsicView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -610,8 +610,7 @@ void AsicView::asicSetAttribute(

std::string key = currentObj->m_str_object_type + ":" + currentObj->m_str_object_id;

std::shared_ptr<swss::KeyOpFieldsValuesTuple> kco =
std::make_shared<swss::KeyOpFieldsValuesTuple>(key, "set", entry);
auto kco = std::make_shared<swss::KeyOpFieldsValuesTuple>(key, "set", entry);

sai_object_id_t vid = (currentObj->isOidObject()) ? currentObj->getVid() : SAI_NULL_OBJECT_ID;

Expand Down Expand Up @@ -732,8 +731,7 @@ void AsicView::asicCreateObject(

std::string key = currentObj->m_str_object_type + ":" + currentObj->m_str_object_id;

std::shared_ptr<swss::KeyOpFieldsValuesTuple> kco =
std::make_shared<swss::KeyOpFieldsValuesTuple>(key, "create", entry);
auto kco = std::make_shared<swss::KeyOpFieldsValuesTuple>(key, "create", entry);

sai_object_id_t vid = (currentObj->isOidObject()) ? currentObj->getVid() : SAI_NULL_OBJECT_ID;

Expand Down Expand Up @@ -856,8 +854,7 @@ void AsicView::asicRemoveObject(

std::string key = currentObj->m_str_object_type + ":" + currentObj->m_str_object_id;

std::shared_ptr<swss::KeyOpFieldsValuesTuple> kco =
std::make_shared<swss::KeyOpFieldsValuesTuple>(key, "remove", entry);
auto kco = std::make_shared<swss::KeyOpFieldsValuesTuple>(key, "remove", entry);

sai_object_id_t vid = (currentObj->isOidObject()) ? currentObj->getVid() : SAI_NULL_OBJECT_ID;

Expand Down Expand Up @@ -968,8 +965,8 @@ std::vector<AsicOperation> AsicView::asicGetWithOptimizedRemoveOperations() cons

auto ot = VidManager::objectTypeQuery(op.m_vid);

SWSS_LOG_INFO("move 0x%" PRIx64 " all way up (not in map): %s to index: %zu",
op.m_vid,
SWSS_LOG_INFO("move %s all way up (not in map): %s to index: %zu",
sai_serialize_object_id(op.m_vid).c_str(),
sai_serialize_object_type(ot).c_str(),
index);

Expand Down
9 changes: 4 additions & 5 deletions syncd/SaiObj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ using namespace syncd;

SaiObj::SaiObj():
m_createdObject(false),
m_object_status(SAI_OBJECT_STATUS_NOT_PROCESSED)
m_objectStatus(SAI_OBJECT_STATUS_NOT_PROCESSED)
{
SWSS_LOG_ENTER();

// empty
}


bool SaiObj::isOidObject() const
{
SWSS_LOG_ENTER();
Expand Down Expand Up @@ -64,18 +63,18 @@ std::shared_ptr<const SaiAttr> SaiObj::tryGetSaiAttr(
}

void SaiObj::setObjectStatus(
_In_ sai_object_status_t object_status)
_In_ sai_object_status_t objectStatus)
{
SWSS_LOG_ENTER();

m_object_status = object_status;
m_objectStatus = objectStatus;
}

sai_object_status_t SaiObj::getObjectStatus() const
{
SWSS_LOG_ENTER();

return m_object_status;
return m_objectStatus;
}

sai_object_type_t SaiObj::getObjectType() const
Expand Down
6 changes: 3 additions & 3 deletions syncd/SaiObj.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ namespace syncd
/**
* @brief Sets object status
*
* @param[in] object_status New object status
* @param[in] objectStatus New object status
*/
void setObjectStatus(
_In_ sai_object_status_t object_status);
_In_ sai_object_status_t objectStatus);

/**
* @brief Gets current object status
Expand Down Expand Up @@ -135,7 +135,7 @@ namespace syncd

private:

sai_object_status_t m_object_status;
sai_object_status_t m_objectStatus;

std::unordered_map<sai_attr_id_t, std::shared_ptr<SaiAttr>> m_attrs;
};
Expand Down
16 changes: 7 additions & 9 deletions syncd/Workaround.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ using namespace syncd;
* Some attributes are not supported on SET API on different platforms.
* For example SAI_SWITCH_ATTR_SRC_MAC_ADDRESS.
*
* @param[in] objecttype Object type.
* @param[in] attrid Attribute Id.
* @param[in] objectType Object type.
* @param[in] attrId Attribute Id.
* @param[in] status Status from SET API.
*
* @return True if error from SET API can be ignored, false otherwise.
*/
bool Workaround::isSetAttributeWorkaround(
_In_ sai_object_type_t objecttype,
_In_ sai_attr_id_t attrid,
_In_ sai_object_type_t objectType,
_In_ sai_attr_id_t attrId,
_In_ sai_status_t status)
{
SWSS_LOG_ENTER();
Expand All @@ -30,17 +30,15 @@ bool Workaround::isSetAttributeWorkaround(
return false;
}

if (objecttype == SAI_OBJECT_TYPE_SWITCH &&
attrid == SAI_SWITCH_ATTR_SRC_MAC_ADDRESS)
if (objectType == SAI_OBJECT_TYPE_SWITCH &&
attrId == SAI_SWITCH_ATTR_SRC_MAC_ADDRESS)
{
SWSS_LOG_WARN("setting %s failed: %s, not all platforms support this attribute",
sai_metadata_get_attr_metadata(objecttype, attrid)->attridname,
sai_metadata_get_attr_metadata(objectType, attrId)->attridname,
sai_serialize_status(status).c_str());

return true;
}

return false;
}


8 changes: 4 additions & 4 deletions syncd/Workaround.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ namespace syncd
* Some attributes are not supported on SET API on different platforms.
* For example SAI_SWITCH_ATTR_SRC_MAC_ADDRESS.
*
* @param[in] objecttype Object type.
* @param[in] attrid Attribute Id.
* @param[in] objectType Object type.
* @param[in] attrId Attribute Id.
* @param[in] status Status from SET API.
*
* @return True if error from SET API can be ignored, false otherwise.
*/
static bool isSetAttributeWorkaround(
_In_ sai_object_type_t objecttype,
_In_ sai_attr_id_t attrid,
_In_ sai_object_type_t objectType,
_In_ sai_attr_id_t attrId,
_In_ sai_status_t status);
};
}

0 comments on commit f37413a

Please sign in to comment.