Fixed packet I/O in p4-14 programs
Tested on BMv2 and working
Change-Id: I834d7b5a8627181c6888500545e1bdbfe9af8dc1
diff --git a/tools/test/p4src/p4-14/include/parser.p4 b/tools/test/p4src/p4-14/include/parser.p4
index 73dcdfd..0223297 100644
--- a/tools/test/p4src/p4-14/include/parser.p4
+++ b/tools/test/p4src/p4-14/include/parser.p4
@@ -11,11 +11,12 @@
header udp_t udp;
parser start {
- // FIXME: Cheat the compiler to generate the deparser of packet in
- // This is just a hack, we assume first 8 bit of etherType won't be 0
- return select( current(96, 8) ) {
- NULL_ETH_TYPE : parse_pkt_in;
- default : default_parser;
+ // Hack to force deparsing of packet_in hdr.
+ // We assume it's impossible to receive a pkt with the first 8 bits of etherType 0.
+ // p4c-tofino complains when switching over 16 bits, i.e. the full etherType
+ return select(current(96, 8)) {
+ 0 : parse_pkt_in;
+ default : default_parser;
}
}