-
Notifications
You must be signed in to change notification settings - Fork 448
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix FlattenLogMsg not properly working on nested structures (#5036)
* Fix FlattenLogMsg not properly working on nested structure argument Signed-off-by: Jiri Havranek <[email protected]> * Update reference output of issue2201-bmv2.p4 test file Signed-off-by: Jiri Havranek <[email protected]> * Fix structs with error type not being dumped by ToP4 Signed-off-by: Jiri Havranek <[email protected]> * Fix clang format complaints Signed-off-by: Jiri Havranek <[email protected]> * Remove v1model include; add log_msg function Signed-off-by: Jiri Havranek <[email protected]> * Rewrite ToP4 error type fix Signed-off-by: Jiri Havranek <[email protected]> * Rewrite ToP4 error type fix again Signed-off-by: Jiri Havranek <[email protected]> --------- Signed-off-by: Jiri Havranek <[email protected]>
- Loading branch information
Showing
12 changed files
with
244 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
Copyright 2024 Intel Corporation | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
extern void log_msg(string msg); | ||
extern void log_msg<T>(string msg, in T data); | ||
|
||
header h0_t { | ||
bit<32> f0; | ||
bit<32> f1; | ||
} | ||
|
||
struct struct_data_t { | ||
bit<3> f0; | ||
bit<5> f1; | ||
bit<8> f2; | ||
} | ||
|
||
struct data_t { | ||
h0_t hdr; | ||
struct_data_t data; | ||
bit<32> field; | ||
} | ||
|
||
parser SimpleParser(inout data_t d); | ||
package SimpleArch(SimpleParser p); | ||
|
||
parser ParserImpl(inout data_t d) | ||
{ | ||
state start { | ||
log_msg("Flattened hierarchical data: {}", {d}); | ||
transition accept; | ||
} | ||
} | ||
|
||
SimpleArch(ParserImpl()) main; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
extern void log_msg(string msg); | ||
extern void log_msg<T>(string msg, in T data); | ||
header h0_t { | ||
bit<32> f0; | ||
bit<32> f1; | ||
} | ||
|
||
struct struct_data_t { | ||
bit<3> f0; | ||
bit<5> f1; | ||
bit<8> f2; | ||
} | ||
|
||
struct data_t { | ||
h0_t hdr; | ||
struct_data_t data; | ||
bit<32> field; | ||
} | ||
|
||
parser SimpleParser(inout data_t d); | ||
package SimpleArch(SimpleParser p); | ||
parser ParserImpl(inout data_t d) { | ||
state start { | ||
log_msg<tuple<data_t>>("Flattened hierarchical data: {}", { d }); | ||
transition accept; | ||
} | ||
} | ||
|
||
SimpleArch(ParserImpl()) main; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
extern void log_msg(string msg); | ||
extern void log_msg<T>(string msg, in T data); | ||
header h0_t { | ||
bit<32> f0; | ||
bit<32> f1; | ||
} | ||
|
||
struct struct_data_t { | ||
bit<3> f0; | ||
bit<5> f1; | ||
bit<8> f2; | ||
} | ||
|
||
struct data_t { | ||
h0_t hdr; | ||
struct_data_t data; | ||
bit<32> field; | ||
} | ||
|
||
parser SimpleParser(inout data_t d); | ||
package SimpleArch(SimpleParser p); | ||
parser ParserImpl(inout data_t d) { | ||
state start { | ||
log_msg<tuple<data_t>>("Flattened hierarchical data: {}", { d }); | ||
transition accept; | ||
} | ||
} | ||
|
||
SimpleArch(ParserImpl()) main; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
extern void log_msg(string msg); | ||
extern void log_msg<T>(string msg, in T data); | ||
header h0_t { | ||
bit<32> f0; | ||
bit<32> f1; | ||
} | ||
|
||
struct struct_data_t { | ||
bit<3> f0; | ||
bit<5> f1; | ||
bit<8> f2; | ||
} | ||
|
||
struct data_t { | ||
h0_t hdr; | ||
struct_data_t data; | ||
bit<32> field; | ||
} | ||
|
||
parser SimpleParser(inout data_t d); | ||
package SimpleArch(SimpleParser p); | ||
struct tuple_0 { | ||
bit<32> f0; | ||
bit<32> f1; | ||
bit<3> f2; | ||
bit<5> f3; | ||
bit<8> f4; | ||
bit<32> f5; | ||
} | ||
|
||
parser ParserImpl(inout data_t d) { | ||
state start { | ||
log_msg<tuple_0>("Flattened hierarchical data: (hdr:(f0:{},f1:{}),data:(f0:{},f1:{},f2:{}),field:{})", (tuple_0){f0 = d.hdr.f0,f1 = d.hdr.f1,f2 = d.data.f0,f3 = d.data.f1,f4 = d.data.f2,f5 = d.field}); | ||
transition accept; | ||
} | ||
} | ||
|
||
SimpleArch(ParserImpl()) main; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
extern void log_msg(string msg); | ||
extern void log_msg<T>(string msg, in T data); | ||
header h0_t { | ||
bit<32> f0; | ||
bit<32> f1; | ||
} | ||
|
||
struct struct_data_t { | ||
bit<3> f0; | ||
bit<5> f1; | ||
bit<8> f2; | ||
} | ||
|
||
struct data_t { | ||
h0_t hdr; | ||
struct_data_t data; | ||
bit<32> field; | ||
} | ||
|
||
parser SimpleParser(inout data_t d); | ||
package SimpleArch(SimpleParser p); | ||
parser ParserImpl(inout data_t d) { | ||
state start { | ||
log_msg("Flattened hierarchical data: {}", { d }); | ||
transition accept; | ||
} | ||
} | ||
|
||
SimpleArch(ParserImpl()) main; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# proto-file: p4/v1/p4runtime.proto | ||
# proto-message: p4.v1.WriteRequest | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# proto-file: p4/config/v1/p4info.proto | ||
# proto-message: p4.config.v1.P4Info | ||
|
||
pkg_info { | ||
arch: "v1model" | ||
} |