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

[vslib] add ACL action capabilities support #481

Merged
merged 2 commits into from
Jul 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions meta/sai_meta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2112,6 +2112,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 @@ -3194,6 +3198,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 @@ -805,6 +808,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 @@ -836,6 +870,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 @@ -1160,6 +1195,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