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

Add FlexCounter for MACsec SA #684

Merged
merged 3 commits into from
Nov 2, 2020

Conversation

Pterosaur
Copy link
Contributor

This PR depends on schema modification: sonic-net/sonic-swss-common#403

Signed-off-by: Ze Gan ganze718@gmail.com

@lguohan
Copy link
Contributor

lguohan commented Oct 30, 2020

retest this please

1 similar comment
@Pterosaur
Copy link
Contributor Author

retest this please

@lguohan lguohan requested a review from kcudnik October 30, 2020 01:58
Signed-off-by: Ze Gan <ganze718@gmail.com>
@Pterosaur
Copy link
Contributor Author

Hi @kcudnik , I remember your suggestion about : add comment that this is empty intentionally.
But do you have any proposal for empty constructor or destructor,https://github.com/Azure/sonic-sairedis/pull/684/files#diff-6b568ec42486b69121856646d4bc61b4a9083d12227a5420a1b3b1da93ef24fbR112 ,?

@kcudnik
Copy link
Collaborator

kcudnik commented Oct 30, 2020

Hi @kcudnik , I remember your suggestion about : add comment that this is empty intentionally.
But do you have any proposal for empty constructor or destructor,https://github.com/Azure/sonic-sairedis/pull/684/files#diff-6b568ec42486b69121856646d4bc61b4a9083d12227a5420a1b3b1da93ef24fbR112 ,?

if you have empty constructor you can ether use "= default;" inside header file, or if you initialize some members in default constructor in initializer list then you can make internal as:
{
SWSS_LOG_ENTER();

// empty intentionally
}

FlexCounter::MACsecSAAttrIds::MACsecSAAttrIds(
_In_ sai_object_id_t macsecSA,
_In_ const std::vector<sai_macsec_sa_attr_t> &macsecSAIds):
m_macsecSAId(macsecSA), m_macsecSAAttrIds(macsecSAIds)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

initialize each member in separate line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, please review it.

syncd/FlexCounter.cpp Show resolved Hide resolved
syncd/FlexCounter.cpp Show resolved Hide resolved
syncd/FlexCounter.cpp Show resolved Hide resolved

if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_WARN("Failed to get attr of MACsec SA 0x%" PRIx64 ": %d", macsecSAVid, status);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use sai_serialize_object_id() and sai_serialize_status()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, please review it.

syncd/FlexCounter.cpp Show resolved Hide resolved

for (size_t i = 0; i != macsecSAAttrIds.size(); i++)
{
const std::string &attrName = sai_serialize_enum(macsecSAAttrIds[i], &sai_metadata_enum_sai_macsec_sa_attr_t);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't need to use serialize here, since "meta" object contains member meta->attridname which is exactly that after serialize, you can use that, then also you can drop iterator and use for auto loop

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, please review it.

{
const auto &macsecSAVid = kv.first;
const auto &macsecSARid = kv.second->m_macsecSAId;
const auto &macsecSAAttrIds = kv.second->m_macsecSAAttrIds;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is interesting, so actual id's are here as a numbers ? not as stats name strings ? i dont know how other counters are passed, but i was under impressions that those id's were passed from OA as actual stats strings and not as id number, but i maybe mistaken

values.emplace_back(attrName, sai_serialize_attr_value(*meta, macsecSAAttr[i]));
}
// Write counters to DB
std::string macsecSAVidStr = sai_serialize_object_id(macsecSAVid);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a note, every file uses concept of prefixing "strXXX" instead of "xxxStr", this file is exception since i didn't created this, but in other files please follow strXXX naming

@@ -2122,6 +2224,19 @@ void FlexCounter::addCounter(

setSwitchDebugCounterList(vid, rid, switchCounterIds);
}
else if (objectType == SAI_OBJECT_TYPE_MACSEC_SA && field == MACSEC_SA_ATTR_ID_LIST)
{
std::vector<sai_macsec_sa_attr_t> MACsecSAIds;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't prefix local variables with capital letters

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, please review it.

for (const auto &str : idStrings)
{
int32_t attr;
sai_deserialize_enum(str, &sai_metadata_enum_sai_macsec_sa_attr_t, attr);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, i actually look at rest, so every other attribute have dedicated sai_deserialize_xxx_attr function for this specific purpose, so i think you can also add this dedicated function to saiserialize.cpp as you had previously, just to follow convention, sorry for this, my mistake

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, please review it.

Signed-off-by: Ze Gan <ganze718@gmail.com>
syncd/FlexCounter.cpp Outdated Show resolved Hide resolved
Signed-off-by: Ze Gan <ganze718@gmail.com>
@kcudnik kcudnik merged commit 0b08f52 into sonic-net:master Nov 2, 2020
pettershao-ragilenetworks pushed a commit to pettershao-ragilenetworks/sonic-sairedis that referenced this pull request Nov 18, 2022
Add FlexCounter for MACsec SA
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants