Skip to content

Commit

Permalink
Fix the minor comments of @r12f in PR 651
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmyzhai committed Dec 24, 2024
1 parent d28f67d commit 862866b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions dash-pipeline/SAI/src/dashsai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1211,7 +1211,7 @@ sai_status_t DashSai::set(
pi_p4_id_t action_id = action->action_id();
auto meta_param = meta_table.get_meta_action_param(action_id, attr->id);
if (meta_param) {
auto pair_param = get_action_param_pair_from_p4_table_entry(meta_param, matchActionEntry);
auto pair_param = get_action_param_with_is_v6_flag_from_p4_table_entry(meta_param, matchActionEntry);
if (pair_param.second) {
set_attr_ipaddr_family_to_p4(attr->value, pair_param.second);
}
Expand All @@ -1238,7 +1238,7 @@ sai_status_t DashSai::set(
}

assert(pair_key.first);
if (meta_key->match_type == "ternary" && string_has_suffix(meta_key->name, "_MASK")) {
if (meta_key->match_type == "ternary" && string_ends_with(meta_key->name, "_MASK")) {
set_attr_value_mask_to_p4_ternary(meta_key->field, meta_key->bitwidth, attr->value,
pair_key.first->mutable_ternary());
}
Expand Down Expand Up @@ -1275,7 +1275,7 @@ sai_status_t DashSai::set(
pi_p4_id_t action_id = action->action_id();
auto meta_param = meta_table.get_meta_action_param(action_id, attr->id);
if (meta_param) {
auto pair_param = get_action_param_pair_from_p4_table_entry(meta_param, matchActionEntry);
auto pair_param = get_action_param_with_is_v6_flag_from_p4_table_entry(meta_param, matchActionEntry);
if (pair_param.second) {
set_attr_ipaddr_family_to_p4(attr->value, pair_param.second);
}
Expand Down Expand Up @@ -1313,7 +1313,7 @@ sai_status_t DashSai::get(
for (uint32_t i = 0; i < attr_count; i++) {
if (auto meta_param = meta_table.get_meta_action_param(action_id, attr_list[i].id)) {
// attr in table action params
auto pair_param = get_action_param_pair_from_p4_table_entry(meta_param, matchActionEntry);
auto pair_param = get_action_param_with_is_v6_flag_from_p4_table_entry(meta_param, matchActionEntry);
if (pair_param.second) {
get_attr_ipaddr_family_from_p4(pair_param.second, attr_list[i].value);
}
Expand All @@ -1329,7 +1329,7 @@ sai_status_t DashSai::get(
}

assert(pair_key.first);
if (meta_key->match_type == "ternary" && string_has_suffix(meta_key->name, "_MASK")) {
if (meta_key->match_type == "ternary" && string_ends_with(meta_key->name, "_MASK")) {
get_attr_value_mask_from_p4_ternary(meta_key->field, meta_key->bitwidth,
pair_key.first->mutable_ternary(), attr_list[i].value);
}
Expand Down Expand Up @@ -1364,7 +1364,7 @@ sai_status_t DashSai::get(
for (uint32_t i = 0; i < attr_count; i++) {
if (auto meta_param = meta_table.get_meta_action_param(action_id, attr_list[i].id)) {
// attr in table action params
auto pair_param = get_action_param_pair_from_p4_table_entry(meta_param, matchActionEntry);
auto pair_param = get_action_param_with_is_v6_flag_from_p4_table_entry(meta_param, matchActionEntry);
if (pair_param.second) {
get_attr_ipaddr_family_from_p4(pair_param.second, attr_list[i].value);
}
Expand Down
8 changes: 4 additions & 4 deletions dash-pipeline/SAI/src/p4meta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace dash
const P4MetaKey* P4MetaTable::get_meta_object_key() const
{
for (auto i=0u; i<keys.size(); i++) {
if (string_has_suffix(keys[i].name, "_OBJECT_KEY")) {
if (string_ends_with(keys[i].name, "_OBJECT_KEY")) {
return &keys[i];
}
}
Expand Down Expand Up @@ -297,7 +297,7 @@ namespace dash

auto mf = matchActionEntry->add_match();
mf->set_field_id(meta_key->id);
if (meta_key->match_type == "ternary" && string_has_suffix(meta_key->name, "_MASK")) {
if (meta_key->match_type == "ternary" && string_ends_with(meta_key->name, "_MASK")) {
set_attr_value_mask_to_p4_ternary(meta_key->field, meta_key->bitwidth, attr->value,
mf->mutable_ternary());
}
Expand Down Expand Up @@ -376,7 +376,7 @@ namespace dash
return pair_key;
}

std::pair<p4::v1::Action_Param*, p4::v1::Action_Param*> get_action_param_pair_from_p4_table_entry(
std::pair<p4::v1::Action_Param*, p4::v1::Action_Param*> get_action_param_with_is_v6_flag_from_p4_table_entry(
_In_ const P4MetaActionParam *meta_param,
_In_ std::shared_ptr<p4::v1::TableEntry> matchActionEntry)
{
Expand All @@ -396,7 +396,7 @@ namespace dash
return pair_param;
}

bool string_has_suffix(const std::string &str, const std::string &suffix)
bool string_ends_with(const std::string &str, const std::string &suffix)
{
if (str.length() < suffix.length())
return false;
Expand Down
4 changes: 2 additions & 2 deletions dash-pipeline/SAI/src/p4meta.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,9 @@ namespace dash
_In_ const P4MetaKey *meta_key,
_In_ std::shared_ptr<p4::v1::TableEntry> matchActionEntry);

std::pair<p4::v1::Action_Param*, p4::v1::Action_Param*> get_action_param_pair_from_p4_table_entry(
std::pair<p4::v1::Action_Param*, p4::v1::Action_Param*> get_action_param_with_is_v6_flag_from_p4_table_entry(
_In_ const P4MetaActionParam *meta_param,
_In_ std::shared_ptr<p4::v1::TableEntry> matchActionEntry);

bool string_has_suffix(const std::string &str, const std::string &suffix);
bool string_ends_with(const std::string &str, const std::string &suffix);
}

0 comments on commit 862866b

Please sign in to comment.