Add functions to serialize and deserialize strict flags and use these functions for port_error_status#1817
Conversation
|
/azp run |
5ab8628 to
c8d1f70
Compare
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
| SWSS_LOG_ENTER(); | ||
|
|
||
| sai_deserialize_enum(s, &sai_metadata_enum_sai_port_error_status_t, (int32_t&)status); | ||
| sai_deserialize_flags(s, &sai_metadata_enum_sai_port_error_status_t, (int32_t&)status); |
There was a problem hiding this comment.
please bring serialize enum here, and move sai_desrialize_flags to deserialize_enum and check if flags strict is set
| SWSS_LOG_ENTER(); | ||
|
|
||
| return sai_serialize_enum(status, &sai_metadata_enum_sai_port_error_status_t); | ||
| return sai_serialize_flags(status, &sai_metadata_enum_sai_port_error_status_t); |
There was a problem hiding this comment.
same here as comment in deserialize
| return sai_serialize_number(value); | ||
| } | ||
|
|
||
| std::string sai_serialize_flags( |
There was a problem hiding this comment.
you will need unittests for both those methods
|
@saksarav-nokia hey, i took a look at your implementaion and it seems too complex for me, i made a proposal for serialization method for you: kcudnik@7ecbac8b i assumed that meta->valuesnames[0] in each struct enum is always zero, but this will not be the case untill SAI submodule will be updated, so this extra check would need to be added in this serialieze, and i made fix here to support both case scenarios: kcudnik@3dc4b1c i also added deserialize here:kcudnik@6749a44d its more flexible since it can support 0x token inside string not only at the end, but it don't support ignored values, and i didn't actually tested id xD you can do that :) its also flawed, if you give it empty string you will get 0 as return also if you give it strings with all pipes "|||" it will also return zero, it can be ether bug or feature :) for example "FOO||BAR" will be correctly deserialized, but serialize will not produce such string, and any missing value which is not in enum will be silently ignored which we probalby want to add warning or throw |
Thanks @kcudnik . Do you want me to create a PR and i can close mine. Or do you want me to take your changes, test it and update this PR with the new changes?. Anyway i am pulling your changes, update the unit test for deserialize and testing it. So let me know |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
@kcudnik , i took your changes and fixed minor issues and also added LOG_WARNING in deserialize. also added unit test for deserialize. Tested in the BCM platform based chassis switch. |
5e880ad to
99d354b
Compare
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
| _In_ const int32_t value, | ||
| _In_ const sai_enum_metadata_t* meta); | ||
| _In_ const sai_enum_metadata_t* meta, | ||
| _In_ bool flagCheck = true); |
There was a problem hiding this comment.
why this flag is added it should not be used at all, current implementation should be backward compatible
| _In_ const int32_t value, | ||
| _In_ const sai_enum_metadata_t* meta) | ||
| _In_ const sai_enum_metadata_t* meta, | ||
| bool flagCheck) |
There was a problem hiding this comment.
plese remove that flag check, the entire purpose to serialize strict flags here in this enum is to not have this flag
There was a problem hiding this comment.
I was about to message you in the comment regarding that change . The reason i added that flag is that the sai_stat_st_capability_t -> sai_stat_capability_t has sai_stat_id and uint32_t stat_modes. So when sai_serialize_stats_st_capability_list or sai_serialize_stat_st_capability is called with meta of type sai_stats_mode_t as by the unit_test, sai_serialize_stat_capability was serializing it incorrectly and unit test was failing. If you don't want a flag, i can fix the unit tests serialize_stat_st_capability_list . So sai_serialize_stats_st_capability_list should not be called with sai_metadata_enum_sai_stats_mode_t
There was a problem hiding this comment.
yea so this is special case since it's uint32_t field, maybe it should be converetd in SAI to enum,, but currently i see that stat_mode field is serialized as array, so i think it would be ahrd to make it backward compatible with new serialization, maybe just leave satt_mode as is ?
also i just noticed, that having pipe (|) in serializing enum as string, could mess some issues with recording/reading recording file, just wondering on that, didnt hit that caase yet, but then saiplayer parsing would beed to be updated
There was a problem hiding this comment.
ok. let me take the sairedis.rec with these changes and paly it in saiplayer and test it.
06ddd6f to
dff4f0c
Compare
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
90ec43b to
904a266
Compare
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azpw run |
|
Retrying failed(or canceled) jobs... |
|
Retrying failed(or canceled) stages in build 1076076: ✅Stage BuildAsan:
|
| continue; | ||
| } | ||
|
|
||
| for (i = 0; i < meta->valuescount; ++i) |
There was a problem hiding this comment.
declare size_t in this ilie in forloop this is not C
There was a problem hiding this comment.
@kcudnik , I had it in the for loop first, but when i added the check and SYS_LOG_WARN message after the for loop, i had to use the variable "i" and hence moved it out.
if (i == meta->valuescount)
{
// v is empty or doesn't match any enum
SWSS_LOG_WARN("%s in %s has invalid enum for %s", v.c_str(), s.c_str(), meta->name);
}
There was a problem hiding this comment.
@kcudnik , Could you please check my response.
There was a problem hiding this comment.
ok then declare it at lease close to for
There was a problem hiding this comment.
ok. Thanks. I addressed your comment. Pls check
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
… functions for port_error_status Signed-off-by: saksarav <sakthivadivu.saravanaraj@nokia.com>
Signed-off-by: saksarav <sakthivadivu.saravanaraj@nokia.com>
Signed-off-by: saksarav <sakthivadivu.saravanaraj@nokia.com>
… the correct meta Signed-off-by: saksarav <sakthivadivu.saravanaraj@nokia.com>
Signed-off-by: saksarav <sakthivadivu.saravanaraj@nokia.com>
e45645c to
025f0f8
Compare
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Fixes the issue reported in sonic-net/sonic-buildimage#24895
This PR depends on opencomputeproject/SAI#2264