Skip to content

Commit

Permalink
[libsai] dummy implementation for ACL_TABLE (#657)
Browse files Browse the repository at this point in the history
1. Fix #655 , by adding dummy implementation for
SAI_OBJECT_TYPE_ACL_TABLE
2. Fix #656, by bypassing creation of route entry with prefix length 0
  • Loading branch information
jimmyzhai authored Jan 17, 2025
1 parent 3677225 commit f5b4b70
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 5 deletions.
38 changes: 38 additions & 0 deletions dash-pipeline/SAI/src/sai_dash_acl.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include "saiimpl.h"

DASH_GENERIC_QUAD(ACL_TABLE,acl_table);

sai_acl_api_t dash_sai_acl_api_impl = {

DASH_GENERIC_QUAD_API(acl_table)

.create_acl_entry = 0,
.remove_acl_entry = 0,
.set_acl_entry_attribute = 0,
.get_acl_entry_attribute = 0,

.create_acl_counter = 0,
.remove_acl_counter = 0,
.set_acl_counter_attribute = 0,
.get_acl_counter_attribute = 0,

.create_acl_range = 0,
.remove_acl_range = 0,
.set_acl_range_attribute = 0,
.get_acl_range_attribute = 0,

.create_acl_table_group = 0,
.remove_acl_table_group = 0,
.set_acl_table_group_attribute = 0,
.get_acl_table_group_attribute = 0,

.create_acl_table_group_member = 0,
.remove_acl_table_group_member = 0,
.set_acl_table_group_member_attribute = 0,
.get_acl_table_group_member_attribute = 0,

.create_acl_table_chain_group = 0,
.remove_acl_table_chain_group = 0,
.set_acl_table_chain_group_attribute = 0,
.get_acl_table_chain_group_attribute = 0,
};
2 changes: 1 addition & 1 deletion dash-pipeline/SAI/templates/impls/p4_table_util.cpp.j2
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
{
// https://github.com/p4lang/PI/blob/24e0a3c08c964e36d235973556b90e0ae922b894/proto/frontend/src/device_mgr.cpp#L2242-L2246
DASH_LOG_WARN("Invalid reprsentation of 'don't care' LPM match, omit match field instead of using a prefix length of 0");
return SAI_STATUS_SUCCESS;
return SAI_STATUS_NOT_SUPPORTED;
}
{% endif %}
auto mf_lpm = mf->mutable_lpm();
Expand Down
24 changes: 20 additions & 4 deletions dash-pipeline/SAI/templates/impls/sai_api_func_quad.cpp.j2
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ static sai_status_t dash_sai_create_{{ api.name }}(
std::shared_ptr<p4::v1::TableEntry> matchActionEntry = std::make_shared<p4::v1::TableEntry>();
matchActionEntry->set_table_id({{meta_table}}.id);

table_{{api.name}}_add_keys({{ api.name }}, matchActionEntry);
if (table_{{api.name}}_add_keys({{ api.name }}, matchActionEntry) == SAI_STATUS_NOT_SUPPORTED)
{
DASH_LOG_WARN("match field in {{ api.name }} not supported, API does nothing!");
return SAI_STATUS_SUCCESS; // bypass, temporary workaround for issue #656
}
return dashSai->create({{meta_table}}, obj_type, matchActionEntry, attr_count, attr_list);
{% endif %}
}
Expand All @@ -42,7 +46,11 @@ static sai_status_t dash_sai_remove_{{ api.name }}(
std::shared_ptr<p4::v1::TableEntry> matchActionEntry = std::make_shared<p4::v1::TableEntry>();
matchActionEntry->set_table_id({{meta_table}}.id);

table_{{api.name}}_add_keys({{ api.name }}, matchActionEntry);
if (table_{{api.name}}_add_keys({{ api.name }}, matchActionEntry) == SAI_STATUS_NOT_SUPPORTED)
{
DASH_LOG_WARN("match field in {{ api.name }} not supported, API does nothing!");
return SAI_STATUS_SUCCESS; // bypass, temporary workaround for issue #656
}
return dashSai->remove({{meta_table}}, matchActionEntry);
{% endif %}
}
Expand All @@ -57,7 +65,11 @@ static sai_status_t dash_sai_set_{{ api.name }}_attribute(
std::shared_ptr<p4::v1::TableEntry> matchActionEntry = std::make_shared<p4::v1::TableEntry>();
matchActionEntry->set_table_id({{meta_table}}.id);

table_{{api.name}}_add_keys({{ api.name }}, matchActionEntry);
if (table_{{api.name}}_add_keys({{ api.name }}, matchActionEntry) == SAI_STATUS_NOT_SUPPORTED)
{
DASH_LOG_WARN("match field in {{ api.name }} not supported, API does nothing!");
return SAI_STATUS_SUCCESS; // bypass, temporary workaround for issue #656
}
return dashSai->set({{meta_table}}, matchActionEntry, attr);
{% endif %}
}
Expand All @@ -73,7 +85,11 @@ static sai_status_t dash_sai_get_{{ api.name }}_attribute(
std::shared_ptr<p4::v1::TableEntry> matchActionEntry = std::make_shared<p4::v1::TableEntry>();
matchActionEntry->set_table_id({{meta_table}}.id);

table_{{api.name}}_add_keys({{ api.name }}, matchActionEntry);
if (table_{{api.name}}_add_keys({{ api.name }}, matchActionEntry) == SAI_STATUS_NOT_SUPPORTED)
{
DASH_LOG_WARN("match field in {{ api.name }} not supported, API does nothing!");
return SAI_STATUS_SUCCESS; // bypass, temporary workaround for issue #656
}
return dashSai->get({{meta_table}}, matchActionEntry, attr_count, attr_list);
{% endif %}
}
Expand Down
1 change: 1 addition & 0 deletions dash-pipeline/SAI/templates/saifixedapis.cpp.j2
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ sai_status_t sai_api_query(
API(SWITCH,switch);
API(BUFFER,buffer);
API(DTEL,dtel);
API(ACL,acl);

{% for api in api_names %}
case SAI_API_{{ api | upper }}:
Expand Down
1 change: 1 addition & 0 deletions dash-pipeline/SAI/templates/saiimpl.h.j2
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ DASH_PRIVATE extern sai_router_interface_api_t dash_sai_router_interface_
DASH_PRIVATE extern sai_switch_api_t dash_sai_switch_api_impl;
DASH_PRIVATE extern sai_dtel_api_t dash_sai_dtel_api_impl;
DASH_PRIVATE extern sai_buffer_api_t dash_sai_buffer_api_impl;
DASH_PRIVATE extern sai_acl_api_t dash_sai_acl_api_impl;

{% for api in api_names %}
DASH_PRIVATE extern sai_{{ api }}_api_t dash_sai_{{ api }}_api_impl;
Expand Down

0 comments on commit f5b4b70

Please sign in to comment.