From 5c2bc0bedb6365745c80e501687941f1f35e4009 Mon Sep 17 00:00:00 2001 From: Junhua Zhai Date: Thu, 19 Dec 2024 16:04:07 +0000 Subject: [PATCH] Set attr PRIORITY to p4 table, if existing --- dash-pipeline/SAI/src/dashsai.cpp | 6 ++++-- dash-pipeline/SAI/src/p4meta.cpp | 15 +++++++++++++++ dash-pipeline/SAI/src/p4meta.h | 5 +++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/dash-pipeline/SAI/src/dashsai.cpp b/dash-pipeline/SAI/src/dashsai.cpp index 374d55099..ec7d15159 100644 --- a/dash-pipeline/SAI/src/dashsai.cpp +++ b/dash-pipeline/SAI/src/dashsai.cpp @@ -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); } } @@ -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); } } diff --git a/dash-pipeline/SAI/src/p4meta.cpp b/dash-pipeline/SAI/src/p4meta.cpp index 7c9b068e3..42023a1a6 100644 --- a/dash-pipeline/SAI/src/p4meta.cpp +++ b/dash-pipeline/SAI/src/p4meta.cpp @@ -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 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 get_match_pair_from_p4_table_entry( _In_ const P4MetaKey *meta_key, _In_ std::shared_ptr matchActionEntry) diff --git a/dash-pipeline/SAI/src/p4meta.h b/dash-pipeline/SAI/src/p4meta.h index 0617aaf44..ec673cddc 100644 --- a/dash-pipeline/SAI/src/p4meta.h +++ b/dash-pipeline/SAI/src/p4meta.h @@ -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 matchActionEntry); + std::pair get_match_pair_from_p4_table_entry( _In_ const P4MetaKey *meta_key, _In_ std::shared_ptr matchActionEntry);