Skip to content

Commit

Permalink
add support for SAI_ATTR_VALUE_TYPE_ACL_CAPABILITY (sonic-net#460)
Browse files Browse the repository at this point in the history
Signed-off-by: Stepan Blyschak <stepanb@mellanox.com>
  • Loading branch information
stepanblyschak authored and lguohan committed Jun 4, 2019
1 parent d445b0e commit 37b9dff
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
4 changes: 4 additions & 0 deletions meta/sai_meta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3466,6 +3466,10 @@ void meta_generic_validation_post_get(
meta_generic_validation_post_get_objlist(meta_key, md, switch_id, value.aclaction.parameter.objlist.count, value.aclaction.parameter.objlist.list);
break;

case SAI_ATTR_VALUE_TYPE_ACL_CAPABILITY:
VALIDATION_LIST_GET(md, value.aclcapability.action_list);
break;

// ACL END

case SAI_ATTR_VALUE_TYPE_UINT8_LIST:
Expand Down
32 changes: 32 additions & 0 deletions meta/saiserialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,11 @@ sai_status_t transfer_attribute(
RETURN_ON_ERROR(transfer_list(src_attr.value.aclaction.parameter.objlist, dst_attr.value.aclaction.parameter.objlist, countOnly));
break;

case SAI_ATTR_VALUE_TYPE_ACL_CAPABILITY:
transfer_primitive(src_attr.value.aclcapability.is_action_list_mandatory, dst_attr.value.aclcapability.is_action_list_mandatory);
RETURN_ON_ERROR(transfer_list(src_attr.value.aclcapability.action_list, dst_attr.value.aclcapability.action_list, countOnly));
break;

default:
return SAI_STATUS_NOT_IMPLEMENTED;
}
Expand Down Expand Up @@ -2343,6 +2348,26 @@ void sai_deserialize_acl_action(
}
}

void sai_deserialize_acl_capability(
_In_ const std::string& s,
_Out_ sai_acl_capability_t& cap)
{
SWSS_LOG_ENTER();

auto pos = s.find(":");

if (pos == std::string::npos)
{
SWSS_LOG_THROW("Invalid acl capability %s", s);
}

auto mandatory_on_create_str = s.substr(0, pos);
auto list = s.substr(pos + 1);

sai_deserialize_bool(mandatory_on_create_str, cap.is_action_list_mandatory);
sai_deserialize_enum_list(list, &sai_metadata_enum_sai_acl_action_type_t, cap.action_list, false);
}

void sai_deserialize_attr_value(
_In_ const std::string& s,
_In_ const sai_attr_metadata_t& meta,
Expand Down Expand Up @@ -2478,6 +2503,9 @@ void sai_deserialize_attr_value(
case SAI_ATTR_VALUE_TYPE_ACL_ACTION_DATA_OBJECT_LIST:
return sai_deserialize_acl_action(s, meta, attr.value.aclaction, countOnly);

case SAI_ATTR_VALUE_TYPE_ACL_CAPABILITY:
return sai_deserialize_acl_capability(s, attr.value.aclcapability);

default:
SWSS_LOG_THROW("deserialize type %d is not supportd yet FIXME", meta.attrvaluetype);
}
Expand Down Expand Up @@ -2898,6 +2926,10 @@ void sai_deserialize_free_attribute_value(
sai_free_list(attr.value.aclaction.parameter.objlist);
break;

case SAI_ATTR_VALUE_TYPE_ACL_CAPABILITY:
sai_free_list(attr.value.aclcapability.action_list);
break;

default:
SWSS_LOG_THROW("unsupported type %d on deserialize free, FIXME", type);
}
Expand Down

0 comments on commit 37b9dff

Please sign in to comment.