-
Notifications
You must be signed in to change notification settings - Fork 273
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 libsai RedisInterface for link event damping. #1331
Open
Ashish1805
wants to merge
1
commit into
sonic-net:master
Choose a base branch
from
Ashish1805:ledamping_sairedis
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -493,6 +493,83 @@ sai_status_t RedisRemoteSaiInterface::setRedisExtensionAttribute( | |
return SAI_STATUS_FAILURE; | ||
} | ||
|
||
sai_status_t RedisRemoteSaiInterface::setLinkEventDampingConfig( | ||
_In_ sai_object_type_t objectType, | ||
_In_ sai_object_id_t objectId, | ||
_In_ const std::vector<swss::FieldValueTuple> &values) | ||
{ | ||
SWSS_LOG_ENTER(); | ||
|
||
std::string key = sai_serialize_object_type(objectType) + ":" + sai_serialize_object_id(objectId); | ||
|
||
m_communicationChannel->set(key, values, REDIS_ASIC_STATE_COMMAND_DAMPING_CONFIG_SET); | ||
|
||
if (m_syncMode) | ||
{ | ||
swss::KeyOpFieldsValuesTuple kco; | ||
auto status = m_communicationChannel->wait(REDIS_ASIC_STATE_COMMAND_DAMPING_CONFIG_SET, kco); | ||
|
||
m_recorder->recordGenericSetResponse(status); | ||
|
||
return status; | ||
} | ||
|
||
return SAI_STATUS_SUCCESS; | ||
} | ||
|
||
sai_status_t RedisRemoteSaiInterface::setRedisPortExtensionAttribute( | ||
_In_ sai_object_type_t objectType, | ||
_In_ sai_object_id_t objectId, | ||
_In_ const sai_attribute_t *attr) | ||
{ | ||
SWSS_LOG_ENTER(); | ||
|
||
if (attr == nullptr) | ||
{ | ||
SWSS_LOG_ERROR("attr pointer is null"); | ||
|
||
return SAI_STATUS_INVALID_PARAMETER; | ||
} | ||
|
||
std::string str_attr_id = sai_serialize_redis_port_attr_id( | ||
static_cast<sai_redis_port_attr_t>(attr->id)); | ||
|
||
switch (attr->id) | ||
{ | ||
case SAI_REDIS_PORT_ATTR_LINK_EVENT_DAMPING_ALGORITHM: | ||
{ | ||
std::string str_attr_value = sai_serialize_redis_link_event_damping_algorithm( | ||
static_cast<sai_redis_link_event_damping_algorithm_t>(attr->value.s32)); | ||
|
||
return setLinkEventDampingConfig( | ||
objectType, objectId, {swss::FieldValueTuple(str_attr_id, str_attr_value)}); | ||
} | ||
case SAI_REDIS_PORT_ATTR_LINK_EVENT_DAMPING_ALGO_AIED_CONFIG: | ||
{ | ||
sai_redis_link_event_damping_algo_aied_config_t *config = | ||
(sai_redis_link_event_damping_algo_aied_config_t *)attr->value.ptr; | ||
|
||
if (config == NULL) | ||
{ | ||
SWSS_LOG_ERROR("invalid link damping config attr value NULL"); | ||
|
||
return SAI_STATUS_INVALID_PARAMETER; | ||
} | ||
|
||
std::string str_attr_value = sai_serialize_redis_link_event_damping_aied_config(*config); | ||
|
||
return setLinkEventDampingConfig( | ||
objectType, objectId, {swss::FieldValueTuple(str_attr_id, str_attr_value)}); | ||
} | ||
default: | ||
break; | ||
} | ||
|
||
SWSS_LOG_ERROR("unknown redis port extension attribute: %d", attr->id); | ||
|
||
return SAI_STATUS_INVALID_PARAMETER; | ||
} | ||
|
||
bool RedisRemoteSaiInterface::isSaiS8ListValidString( | ||
_In_ const sai_s8_list_t &s8list) | ||
{ | ||
|
@@ -625,6 +702,11 @@ sai_status_t RedisRemoteSaiInterface::set( | |
return setRedisExtensionAttribute(objectType, objectId, attr); | ||
} | ||
|
||
if (RedisRemoteSaiInterface::isRedisPortAttribute(objectType, attr)) | ||
{ | ||
return setRedisPortExtensionAttribute(objectType, objectId, attr); | ||
} | ||
|
||
auto status = set( | ||
objectType, | ||
sai_serialize_object_id(objectId), | ||
|
@@ -1792,6 +1874,20 @@ bool RedisRemoteSaiInterface::isRedisAttribute( | |
return true; | ||
} | ||
|
||
bool RedisRemoteSaiInterface::isRedisPortAttribute( | ||
_In_ sai_object_id_t objectType, | ||
_In_ const sai_attribute_t* attr) | ||
{ | ||
SWSS_LOG_ENTER(); | ||
|
||
if ((objectType != SAI_OBJECT_TYPE_PORT) || (attr == nullptr) || (attr->id < SAI_PORT_ATTR_CUSTOM_RANGE_START)) | ||
{ | ||
return false; | ||
} | ||
|
||
return true; | ||
Comment on lines
+1883
to
+1888
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can turn this to 1 single line by reversing condition |
||
} | ||
|
||
void RedisRemoteSaiInterface::handleNotification( | ||
_In_ const std::string &name, | ||
_In_ const std::string &serializedNotification, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make this api always synchronous, async mode is just for create/remove/set operations all other apis should be synchronous