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

Add width to parameters of entries in template file. #4557

Merged
merged 2 commits into from
Mar 25, 2024
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
15 changes: 15 additions & 0 deletions backends/tc/backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,21 @@ void ConvertToBackendIR::updateConstEntries(const IR::P4Table *t, IR::TCTable *t
big_int kValue = keySetElement->to<IR::Constant>()->value;
int kBase = keySetElement->to<IR::Constant>()->base;
std::stringstream value;
switch (kBase) {
case 2:
value << "0b";
break;
case 8:
value << "0o";
break;
case 16:
value << "0x";
break;
case 10:
break;
default:
BUG("Unexpected base %1%", kBase);
}
std::deque<char> buf;
do {
const int digit = static_cast<int>(static_cast<big_int>(kValue % kBase));
Expand Down
2 changes: 1 addition & 1 deletion backends/tc/tc.def
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,9 @@ class TCTable {
tcTable += "\n$TC p4template create table/" + pipelineName
+ "/" + controlName + "/" + tableName
+ " entry" + entry->toString();
tcTable += " permissions 0x1024";
komaljai marked this conversation as resolved.
Show resolved Hide resolved
tcTable += " action " + pipelineName
+ "/" + controlName + "/" + entry->getActionName();
tcTable += " permissions 0x1024";
}
}
return tcTable;
Expand Down
10 changes: 5 additions & 5 deletions testdata/p4tc_samples_outputs/calculator.template
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ $TC p4template create table/calculator/MainControlImpl/calculate \
act name calculator/MainControlImpl/operation_xor \
act name calculator/MainControlImpl/operation_drop
$TC p4template update table/calculator/MainControlImpl/calculate default_miss_action permissions 0x1024 action calculator/MainControlImpl/operation_drop
$TC p4template create table/calculator/MainControlImpl/calculate entry op 2b action calculator/MainControlImpl/operation_add permissions 0x1024
$TC p4template create table/calculator/MainControlImpl/calculate entry op 2d action calculator/MainControlImpl/operation_sub permissions 0x1024
$TC p4template create table/calculator/MainControlImpl/calculate entry op 26 action calculator/MainControlImpl/operation_and permissions 0x1024
$TC p4template create table/calculator/MainControlImpl/calculate entry op 7c action calculator/MainControlImpl/operation_or permissions 0x1024
$TC p4template create table/calculator/MainControlImpl/calculate entry op 5e action calculator/MainControlImpl/operation_xor permissions 0x1024
$TC p4template create table/calculator/MainControlImpl/calculate entry op 0x2b permissions 0x1024 action calculator/MainControlImpl/operation_add
$TC p4template create table/calculator/MainControlImpl/calculate entry op 0x2d permissions 0x1024 action calculator/MainControlImpl/operation_sub
$TC p4template create table/calculator/MainControlImpl/calculate entry op 0x26 permissions 0x1024 action calculator/MainControlImpl/operation_and
$TC p4template create table/calculator/MainControlImpl/calculate entry op 0x7c permissions 0x1024 action calculator/MainControlImpl/operation_or
$TC p4template create table/calculator/MainControlImpl/calculate entry op 0x5e permissions 0x1024 action calculator/MainControlImpl/operation_xor
$TC p4template update pipeline/calculator state ready
10 changes: 5 additions & 5 deletions testdata/p4tc_samples_outputs/const_entries_range_mask.template
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ $TC p4template create table/const_entries_range_mask/MainControlImpl/t_range \
table_acts act name const_entries_range_mask/MainControlImpl/a \
act name const_entries_range_mask/MainControlImpl/a_with_control_params
$TC p4template update table/const_entries_range_mask/MainControlImpl/t_range default_miss_action action const_entries_range_mask/MainControlImpl/a
$TC p4template create table/const_entries_range_mask/MainControlImpl/t_range entry h.h.r 1 action const_entries_range_mask/MainControlImpl/a_with_control_params permissions 0x1024
$TC p4template create table/const_entries_range_mask/MainControlImpl/t_range entry h.h.r 6 action const_entries_range_mask/MainControlImpl/a_with_control_params permissions 0x1024
$TC p4template create table/const_entries_range_mask/MainControlImpl/t_range entry h.h.r 15 action const_entries_range_mask/MainControlImpl/a_with_control_params permissions 0x1024
$TC p4template create table/const_entries_range_mask/MainControlImpl/t_range entry h.h.r 8w1..8w8 action const_entries_range_mask/MainControlImpl/a_with_control_params permissions 0x1024
$TC p4template create table/const_entries_range_mask/MainControlImpl/t_range entry h.h.r 8w1&&&8w2 action const_entries_range_mask/MainControlImpl/a_with_control_params permissions 0x1024
$TC p4template create table/const_entries_range_mask/MainControlImpl/t_range entry h.h.r 1 permissions 0x1024 action const_entries_range_mask/MainControlImpl/a_with_control_params
$TC p4template create table/const_entries_range_mask/MainControlImpl/t_range entry h.h.r 6 permissions 0x1024 action const_entries_range_mask/MainControlImpl/a_with_control_params
$TC p4template create table/const_entries_range_mask/MainControlImpl/t_range entry h.h.r 15 permissions 0x1024 action const_entries_range_mask/MainControlImpl/a_with_control_params
$TC p4template create table/const_entries_range_mask/MainControlImpl/t_range entry h.h.r 8w1..8w8 permissions 0x1024 action const_entries_range_mask/MainControlImpl/a_with_control_params
$TC p4template create table/const_entries_range_mask/MainControlImpl/t_range entry h.h.r 8w1&&&8w2 permissions 0x1024 action const_entries_range_mask/MainControlImpl/a_with_control_params
$TC p4template update pipeline/const_entries_range_mask state ready
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ $TC p4template create table/multiple_tables_example_01/MainControlImpl/set_all_o
act name multiple_tables_example_01/MainControlImpl/sendtoport \
act name multiple_tables_example_01/MainControlImpl/drop
$TC p4template update table/multiple_tables_example_01/MainControlImpl/set_all_options default_miss_action permissions 0x1024 action multiple_tables_example_01/MainControlImpl/drop
$TC p4template create table/multiple_tables_example_01/MainControlImpl/set_all_options entry hdr.ipv4.srcAddr 1000 hdr.tcp.srcPort 10 hdr.ipv4.fragOffset 10 hdr.ipv4.flags 1 action multiple_tables_example_01/MainControlImpl/tcp_syn_packet permissions 0x1024
$TC p4template create table/multiple_tables_example_01/MainControlImpl/set_all_options entry hdr.ipv4.srcAddr 2000 hdr.tcp.srcPort 20 hdr.ipv4.fragOffset 20 hdr.ipv4.flags 2 action multiple_tables_example_01/MainControlImpl/tcp_fin_or_rst_packet permissions 0x1024
$TC p4template create table/multiple_tables_example_01/MainControlImpl/set_all_options entry hdr.ipv4.srcAddr 3000 hdr.tcp.srcPort 30 hdr.ipv4.fragOffset 30 hdr.ipv4.flags 3 action multiple_tables_example_01/MainControlImpl/tcp_fin_or_rst_packet permissions 0x1024
$TC p4template create table/multiple_tables_example_01/MainControlImpl/set_all_options entry hdr.ipv4.srcAddr 4000 hdr.tcp.srcPort 40 hdr.ipv4.fragOffset 40 hdr.ipv4.flags 4 action multiple_tables_example_01/MainControlImpl/default_route_drop permissions 0x1024
$TC p4template create table/multiple_tables_example_01/MainControlImpl/set_all_options entry hdr.ipv4.srcAddr 5000 hdr.tcp.srcPort 50 hdr.ipv4.fragOffset 50 hdr.ipv4.flags 5 action multiple_tables_example_01/MainControlImpl/next_hop permissions 0x1024
$TC p4template create table/multiple_tables_example_01/MainControlImpl/set_all_options entry hdr.ipv4.srcAddr 6000 hdr.tcp.srcPort 60 hdr.ipv4.fragOffset 60 hdr.ipv4.flags 6 action multiple_tables_example_01/MainControlImpl/sendtoport permissions 0x1024
$TC p4template create table/multiple_tables_example_01/MainControlImpl/set_all_options entry hdr.ipv4.srcAddr 0x1000 hdr.tcp.srcPort 0x10 hdr.ipv4.fragOffset 10 hdr.ipv4.flags 1 permissions 0x1024 action multiple_tables_example_01/MainControlImpl/tcp_syn_packet
$TC p4template create table/multiple_tables_example_01/MainControlImpl/set_all_options entry hdr.ipv4.srcAddr 0x2000 hdr.tcp.srcPort 0x20 hdr.ipv4.fragOffset 20 hdr.ipv4.flags 2 permissions 0x1024 action multiple_tables_example_01/MainControlImpl/tcp_fin_or_rst_packet
$TC p4template create table/multiple_tables_example_01/MainControlImpl/set_all_options entry hdr.ipv4.srcAddr 0x3000 hdr.tcp.srcPort 0x30 hdr.ipv4.fragOffset 30 hdr.ipv4.flags 3 permissions 0x1024 action multiple_tables_example_01/MainControlImpl/tcp_fin_or_rst_packet
$TC p4template create table/multiple_tables_example_01/MainControlImpl/set_all_options entry hdr.ipv4.srcAddr 0x4000 hdr.tcp.srcPort 0x40 hdr.ipv4.fragOffset 40 hdr.ipv4.flags 4 permissions 0x1024 action multiple_tables_example_01/MainControlImpl/default_route_drop
$TC p4template create table/multiple_tables_example_01/MainControlImpl/set_all_options entry hdr.ipv4.srcAddr 0x5000 hdr.tcp.srcPort 0x50 hdr.ipv4.fragOffset 50 hdr.ipv4.flags 5 permissions 0x1024 action multiple_tables_example_01/MainControlImpl/next_hop
$TC p4template create table/multiple_tables_example_01/MainControlImpl/set_all_options entry hdr.ipv4.srcAddr 0x6000 hdr.tcp.srcPort 0x60 hdr.ipv4.fragOffset 60 hdr.ipv4.flags 6 permissions 0x1024 action multiple_tables_example_01/MainControlImpl/sendtoport
$TC p4template update pipeline/multiple_tables_example_01 state ready
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ $TC p4template create table/multiple_tables_example_02/MainControlImpl/set_all_o
act name multiple_tables_example_02/MainControlImpl/sendtoport \
act name multiple_tables_example_02/MainControlImpl/drop
$TC p4template update table/multiple_tables_example_02/MainControlImpl/set_all_options default_miss_action permissions 0x1024 action multiple_tables_example_02/MainControlImpl/drop
$TC p4template create table/multiple_tables_example_02/MainControlImpl/set_all_options entry hdr.ipv4.srcAddr 1000 hdr.tcp.srcPort 10 hdr.ipv4.fragOffset 10 hdr.ipv4.flags 1 action multiple_tables_example_02/MainControlImpl/tcp_syn_packet permissions 0x1024
$TC p4template create table/multiple_tables_example_02/MainControlImpl/set_all_options entry hdr.ipv4.srcAddr 2000 hdr.tcp.srcPort 20 hdr.ipv4.fragOffset 20 hdr.ipv4.flags 2 action multiple_tables_example_02/MainControlImpl/tcp_fin_or_rst_packet permissions 0x1024
$TC p4template create table/multiple_tables_example_02/MainControlImpl/set_all_options entry hdr.ipv4.srcAddr 3000 hdr.tcp.srcPort 30 hdr.ipv4.fragOffset 30 hdr.ipv4.flags 3 action multiple_tables_example_02/MainControlImpl/tcp_fin_or_rst_packet permissions 0x1024
$TC p4template create table/multiple_tables_example_02/MainControlImpl/set_all_options entry hdr.ipv4.srcAddr 4000 hdr.tcp.srcPort 40 hdr.ipv4.fragOffset 40 hdr.ipv4.flags 4 action multiple_tables_example_02/MainControlImpl/default_route_drop permissions 0x1024
$TC p4template create table/multiple_tables_example_02/MainControlImpl/set_all_options entry hdr.ipv4.srcAddr 5000 hdr.tcp.srcPort 50 hdr.ipv4.fragOffset 50 hdr.ipv4.flags 5 action multiple_tables_example_02/MainControlImpl/next_hop permissions 0x1024
$TC p4template create table/multiple_tables_example_02/MainControlImpl/set_all_options entry hdr.ipv4.srcAddr 6000 hdr.tcp.srcPort 60 hdr.ipv4.fragOffset 60 hdr.ipv4.flags 6 action multiple_tables_example_02/MainControlImpl/sendtoport permissions 0x1024
$TC p4template create table/multiple_tables_example_02/MainControlImpl/set_all_options entry hdr.ipv4.srcAddr 0x1000 hdr.tcp.srcPort 0x10 hdr.ipv4.fragOffset 10 hdr.ipv4.flags 1 permissions 0x1024 action multiple_tables_example_02/MainControlImpl/tcp_syn_packet
$TC p4template create table/multiple_tables_example_02/MainControlImpl/set_all_options entry hdr.ipv4.srcAddr 0x2000 hdr.tcp.srcPort 0x20 hdr.ipv4.fragOffset 20 hdr.ipv4.flags 2 permissions 0x1024 action multiple_tables_example_02/MainControlImpl/tcp_fin_or_rst_packet
$TC p4template create table/multiple_tables_example_02/MainControlImpl/set_all_options entry hdr.ipv4.srcAddr 0x3000 hdr.tcp.srcPort 0x30 hdr.ipv4.fragOffset 30 hdr.ipv4.flags 3 permissions 0x1024 action multiple_tables_example_02/MainControlImpl/tcp_fin_or_rst_packet
$TC p4template create table/multiple_tables_example_02/MainControlImpl/set_all_options entry hdr.ipv4.srcAddr 0x4000 hdr.tcp.srcPort 0x40 hdr.ipv4.fragOffset 40 hdr.ipv4.flags 4 permissions 0x1024 action multiple_tables_example_02/MainControlImpl/default_route_drop
$TC p4template create table/multiple_tables_example_02/MainControlImpl/set_all_options entry hdr.ipv4.srcAddr 0x5000 hdr.tcp.srcPort 0x50 hdr.ipv4.fragOffset 50 hdr.ipv4.flags 5 permissions 0x1024 action multiple_tables_example_02/MainControlImpl/next_hop
$TC p4template create table/multiple_tables_example_02/MainControlImpl/set_all_options entry hdr.ipv4.srcAddr 0x6000 hdr.tcp.srcPort 0x60 hdr.ipv4.fragOffset 60 hdr.ipv4.flags 6 permissions 0x1024 action multiple_tables_example_02/MainControlImpl/sendtoport
$TC p4template update pipeline/multiple_tables_example_02 state ready
Loading