Skip to content

Commit

Permalink
Set attr PRIORITY to p4 table, if existing
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmyzhai committed Dec 19, 2024
1 parent 28dabbe commit 5c2bc0b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
6 changes: 4 additions & 2 deletions dash-pipeline/SAI/src/dashsai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,8 @@ sai_status_t DashSai::create(
set_attr_to_p4_match(meta_key, &attr_list[i], matchActionEntry);
}
else {
// FIXME: check extra fields
// attr in extra fields
set_attr_to_p4_misc(meta_table, &attr_list[i], matchActionEntry);
}
}

Expand Down Expand Up @@ -1140,7 +1141,8 @@ sai_status_t DashSai::create(
set_attr_to_p4_action(meta_param, &attr_list[i], action);
}
else {
// FIXME: check extra fields
// attr in extra fields
set_attr_to_p4_misc(meta_table, &attr_list[i], matchActionEntry);
}
}

Expand Down
15 changes: 15 additions & 0 deletions dash-pipeline/SAI/src/p4meta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,21 @@ namespace dash
set_attr_value_to_p4(meta_param->field, meta_param->bitwidth, attr->value, param);
}

void set_attr_to_p4_misc(
_In_ const P4MetaTable &meta_table,
_In_ const sai_attribute_t *attr,
_Inout_ std::shared_ptr<p4::v1::TableEntry> matchActionEntry)
{
for (auto &extra_attr: meta_table.extra_fields) {
if (extra_attr.second == attr->id) {
if (extra_attr.first == "PRIORITY") {
matchActionEntry->set_priority(attr->value.u32);
break;
}
}
}
}

std::pair<p4::v1::FieldMatch*, p4::v1::FieldMatch*> get_match_pair_from_p4_table_entry(
_In_ const P4MetaKey *meta_key,
_In_ std::shared_ptr<p4::v1::TableEntry> matchActionEntry)
Expand Down
5 changes: 5 additions & 0 deletions dash-pipeline/SAI/src/p4meta.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,11 @@ namespace dash
_In_ const sai_attribute_t *attr,
_Out_ p4::v1::Action *action);

void set_attr_to_p4_misc(
_In_ const P4MetaTable &meta_table,
_In_ const sai_attribute_t *attr,
_Inout_ std::shared_ptr<p4::v1::TableEntry> matchActionEntry);

std::pair<p4::v1::FieldMatch*, p4::v1::FieldMatch*> get_match_pair_from_p4_table_entry(
_In_ const P4MetaKey *meta_key,
_In_ std::shared_ptr<p4::v1::TableEntry> matchActionEntry);
Expand Down

0 comments on commit 5c2bc0b

Please sign in to comment.