Skip to content

Commit

Permalink
[vslib] add ACL action capabilities support (sonic-net#481)
Browse files Browse the repository at this point in the history
* [vslib] add ACL action capabilities support
* [meta] add support for SAI_ATTR_VALUE_TYPE_ACL_CAPABILITY set operation

This is needed for SWSS integration testing
e.g: use setReadOnlyAttr from VS test suite to modify
SAI_SWITCH_ATTR_ACL_STAGE_INGRESS/EGRESS to test orchagent
flows

Signed-off-by: Stepan Blyschak <[email protected]>
  • Loading branch information
stepanblyschak authored and stcheng committed Jul 2, 2019
1 parent 1690b8a commit 085fb56
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
5 changes: 5 additions & 0 deletions meta/sai_meta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2113,6 +2113,10 @@ sai_status_t meta_generic_validation_set(
break;
}

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

default:

META_LOG_THROW(md, "serialization type is not supported yet FIXME");
Expand Down Expand Up @@ -3195,6 +3199,7 @@ void meta_generic_validation_post_set(
case SAI_ATTR_VALUE_TYPE_UINT32_RANGE:
case SAI_ATTR_VALUE_TYPE_INT32_RANGE:
case SAI_ATTR_VALUE_TYPE_ACL_RESOURCE_LIST:
case SAI_ATTR_VALUE_TYPE_ACL_CAPABILITY:
// no special action required
break;

Expand Down
40 changes: 40 additions & 0 deletions vslib/src/sai_vs_switch_BCM56850.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ static std::shared_ptr<SwitchState> ss;
static std::vector<sai_object_id_t> port_list;
static std::vector<sai_object_id_t> bridge_port_list_port_based;

static std::vector<sai_acl_action_type_t> ingress_acl_action_list;
static std::vector<sai_acl_action_type_t> egress_acl_action_list;

static sai_object_id_t default_vlan_id;

static sai_status_t set_switch_mac_address()
Expand Down Expand Up @@ -815,6 +818,37 @@ static sai_status_t create_acl_entry_min_prio()
return vs_generic_set(SAI_OBJECT_TYPE_SWITCH, ss->getSwitchId(), &attr);
}

static sai_status_t create_acl_capabilities()
{
SWSS_LOG_ENTER();

SWSS_LOG_INFO("create acl capabilities");

sai_attribute_t attr;

for (int action_type = SAI_ACL_ENTRY_ATTR_ACTION_START; action_type <= SAI_ACL_ENTRY_ATTR_ACTION_END; action_type++)
{
ingress_acl_action_list.push_back(static_cast<sai_acl_action_type_t>(action_type - SAI_ACL_ENTRY_ATTR_ACTION_START));
egress_acl_action_list.push_back(static_cast<sai_acl_action_type_t>(action_type - SAI_ACL_ENTRY_ATTR_ACTION_START));
}

attr.id = SAI_SWITCH_ATTR_MAX_ACL_ACTION_COUNT;
attr.value.u32 = static_cast<uint32_t>(std::max(ingress_acl_action_list.size(), egress_acl_action_list.size()));
CHECK_STATUS(vs_generic_set(SAI_OBJECT_TYPE_SWITCH, ss->getSwitchId(), &attr));

attr.id = SAI_SWITCH_ATTR_ACL_STAGE_INGRESS;
attr.value.aclcapability.action_list.list = reinterpret_cast<int32_t*>(ingress_acl_action_list.data());
attr.value.aclcapability.action_list.count = static_cast<uint32_t>(ingress_acl_action_list.size());

CHECK_STATUS(vs_generic_set(SAI_OBJECT_TYPE_SWITCH, ss->getSwitchId(), &attr));

attr.id = SAI_SWITCH_ATTR_ACL_STAGE_EGRESS;
attr.value.aclcapability.action_list.list = reinterpret_cast<int32_t*>(egress_acl_action_list.data());
attr.value.aclcapability.action_list.count = static_cast<uint32_t>(egress_acl_action_list.size());

return vs_generic_set(SAI_OBJECT_TYPE_SWITCH, ss->getSwitchId(), &attr);
}

static sai_status_t set_number_of_ecmp_groups()
{
SWSS_LOG_ENTER();
Expand Down Expand Up @@ -846,6 +880,7 @@ static sai_status_t initialize_default_objects()
CHECK_STATUS(create_bridge_ports());
CHECK_STATUS(create_vlan_members());
CHECK_STATUS(create_acl_entry_min_prio());
CHECK_STATUS(create_acl_capabilities());
CHECK_STATUS(create_ingress_priority_groups());
CHECK_STATUS(create_qos_queues());
CHECK_STATUS(set_maximum_number_of_childs_per_scheduler_group());
Expand Down Expand Up @@ -1215,6 +1250,11 @@ sai_status_t refresh_read_only_BCM56850(
case SAI_SWITCH_ATTR_ACL_ENTRY_MAXIMUM_PRIORITY:
return SAI_STATUS_SUCCESS;

case SAI_SWITCH_ATTR_MAX_ACL_ACTION_COUNT:
case SAI_SWITCH_ATTR_ACL_STAGE_INGRESS:
case SAI_SWITCH_ATTR_ACL_STAGE_EGRESS:
return SAI_STATUS_SUCCESS;

case SAI_SWITCH_ATTR_NUMBER_OF_ECMP_GROUPS:
return SAI_STATUS_SUCCESS;

Expand Down
40 changes: 40 additions & 0 deletions vslib/src/sai_vs_switch_MLNX2700.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ static std::shared_ptr<SwitchState> ss;
static std::vector<sai_object_id_t> port_list;
static std::vector<sai_object_id_t> bridge_port_list_port_based;

static std::vector<sai_acl_action_type_t> ingress_acl_action_list;
static std::vector<sai_acl_action_type_t> egress_acl_action_list;

static sai_object_id_t default_vlan_id;
static sai_object_id_t default_bridge_port_1q_router;
static sai_object_id_t cpu_port_id;
Expand Down Expand Up @@ -775,6 +778,37 @@ static sai_status_t create_acl_entry_min_prio()
return vs_generic_set(SAI_OBJECT_TYPE_SWITCH, ss->getSwitchId(), &attr);
}

static sai_status_t create_acl_capabilities()
{
SWSS_LOG_ENTER();

SWSS_LOG_INFO("create acl capabilities");

sai_attribute_t attr;

for (int action_type = SAI_ACL_ENTRY_ATTR_ACTION_START; action_type <= SAI_ACL_ENTRY_ATTR_ACTION_END; action_type++)
{
ingress_acl_action_list.push_back(static_cast<sai_acl_action_type_t>(action_type - SAI_ACL_ENTRY_ATTR_ACTION_START));
egress_acl_action_list.push_back(static_cast<sai_acl_action_type_t>(action_type - SAI_ACL_ENTRY_ATTR_ACTION_START));
}

attr.id = SAI_SWITCH_ATTR_MAX_ACL_ACTION_COUNT;
attr.value.u32 = static_cast<uint32_t>(std::max(ingress_acl_action_list.size(), egress_acl_action_list.size()));
CHECK_STATUS(vs_generic_set(SAI_OBJECT_TYPE_SWITCH, ss->getSwitchId(), &attr));

attr.id = SAI_SWITCH_ATTR_ACL_STAGE_INGRESS;
attr.value.aclcapability.action_list.list = reinterpret_cast<int32_t*>(ingress_acl_action_list.data());
attr.value.aclcapability.action_list.count = static_cast<uint32_t>(ingress_acl_action_list.size());

CHECK_STATUS(vs_generic_set(SAI_OBJECT_TYPE_SWITCH, ss->getSwitchId(), &attr));

attr.id = SAI_SWITCH_ATTR_ACL_STAGE_EGRESS;
attr.value.aclcapability.action_list.list = reinterpret_cast<int32_t*>(egress_acl_action_list.data());
attr.value.aclcapability.action_list.count = static_cast<uint32_t>(egress_acl_action_list.size());

return vs_generic_set(SAI_OBJECT_TYPE_SWITCH, ss->getSwitchId(), &attr);
}

static sai_status_t initialize_default_objects()
{
SWSS_LOG_ENTER();
Expand All @@ -792,6 +826,7 @@ static sai_status_t initialize_default_objects()
CHECK_STATUS(create_bridge_ports());
CHECK_STATUS(create_vlan_members());
CHECK_STATUS(create_acl_entry_min_prio());
CHECK_STATUS(create_acl_capabilities());
CHECK_STATUS(create_ingress_priority_groups());
CHECK_STATUS(create_qos_queues());
CHECK_STATUS(set_maximum_number_of_childs_per_scheduler_group());
Expand Down Expand Up @@ -1142,6 +1177,11 @@ sai_status_t refresh_read_only_MLNX2700(
case SAI_SWITCH_ATTR_ACL_ENTRY_MAXIMUM_PRIORITY:
return SAI_STATUS_SUCCESS;

case SAI_SWITCH_ATTR_MAX_ACL_ACTION_COUNT:
case SAI_SWITCH_ATTR_ACL_STAGE_INGRESS:
case SAI_SWITCH_ATTR_ACL_STAGE_EGRESS:
return SAI_STATUS_SUCCESS;

/*
* We don't need to recalculate port list, since now we assume
* that port list will not change.
Expand Down

0 comments on commit 085fb56

Please sign in to comment.