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

Fix mask calculation for concat operator in bmv2/dpdk expression lowering #3911

Merged
merged 1 commit into from
Mar 6, 2023
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
2 changes: 1 addition & 1 deletion backends/bmv2/common/lower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ const IR::Node *LowerExpressions::postorder(IR::Concat *expression) {
auto cast1 = new IR::Cast(expression->right->srcInfo, resulttype, expression->right);
auto sizefb0 = new IR::Constant(new IR::Type_InfInt(), sizeofb);
auto sh = new IR::Shl(cast0->srcInfo, cast0, sizefb0);
big_int m = Util::maskFromSlice(sizeofb, 0);
big_int m = Util::maskFromSlice(sizeofb - 1, 0);
auto mask = new IR::Constant(expression->right->srcInfo, resulttype, m, 16);
auto and0 = new IR::BAnd(expression->right->srcInfo, cast1, mask);
auto result = new IR::BOr(expression->srcInfo, sh, and0);
Expand Down
1 change: 1 addition & 0 deletions testdata/p4_16_samples/psa-dpdk-binary-operations.p4
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ control MyIC(
a.dstAddr = (bit<48>)b.meta;
a.srcAddr = (bit<48>)b.meta1;
a.etherType = b.meta2;
b.meta = b.meta2 ++ b.meta7;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ control MyIC(inout ethernet_t a, inout metadata b, in psa_ingress_input_metadata
a.dstAddr = (bit<48>)b.meta;
a.srcAddr = (bit<48>)b.meta1;
a.etherType = b.meta2;
b.meta = b.meta2 ++ b.meta7;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ control MyIC(inout ethernet_t a, inout metadata b, in psa_ingress_input_metadata
a.dstAddr = (bit<48>)b.meta;
a.srcAddr = (bit<48>)b.meta1;
a.etherType = b.meta2;
b.meta = b.meta2 ++ b.meta7;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ control MyIC(inout ethernet_t a, inout metadata b, in psa_ingress_input_metadata
a.dstAddr = (bit<48>)b.meta;
a.srcAddr = (bit<48>)b.meta1;
a.etherType = b.meta2;
b.meta = b.meta2 ++ (16w0xf0 + b.meta2);
}
@hidden table tbl_psadpdkbinaryoperations79 {
actions = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ control MyIC(inout ethernet_t a, inout metadata b, in psa_ingress_input_metadata
a.dstAddr = (bit<48>)b.meta;
a.srcAddr = (bit<48>)b.meta1;
a.etherType = b.meta2;
b.meta = b.meta2 ++ b.meta7;
}
}

Expand Down
11 changes: 11 additions & 0 deletions testdata/p4_16_samples_outputs/psa-dpdk-binary-operations.p4.spec
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ struct metadata {
bit<32> local_metadata_meta6
bit<16> local_metadata_meta7
bit<16> Ingress_tmp
bit<32> Ingress_tmp_1
bit<16> Ingress_tmp_2
bit<32> Ingress_tmp_4
}
metadata instanceof metadata

Expand Down Expand Up @@ -80,6 +83,14 @@ apply {
mov h.dstAddr m.local_metadata_meta
mov h.srcAddr m.local_metadata_meta1
mov h.etherType m.local_metadata_meta2
mov m.Ingress_tmp_1 m.local_metadata_meta2
shl m.Ingress_tmp_1 0x10
mov m.Ingress_tmp_2 0xF0
add m.Ingress_tmp_2 m.local_metadata_meta2
mov m.Ingress_tmp_4 m.Ingress_tmp_2
and m.Ingress_tmp_4 0xFFFF
mov m.local_metadata_meta m.Ingress_tmp_1
or m.local_metadata_meta m.Ingress_tmp_4
jmpneq LABEL_DROP m.psa_ingress_output_metadata_drop 0x0
tx m.psa_ingress_output_metadata_egress_port
LABEL_DROP : drop
Expand Down