Skip to content

Commit

Permalink
Preserve ingress_port when re-parsing I2E clones. (#1175)
Browse files Browse the repository at this point in the history
This is a partial fix for #795
  • Loading branch information
smolkaj authored Jan 21, 2023
1 parent 7c86b70 commit 6ec3ef8
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions targets/simple_switch/simple_switch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,9 +558,16 @@ SimpleSwitch::ingress_thread() {
RegisterAccess::clear_all(packet_copy.get());
packet_copy->set_register(RegisterAccess::PACKET_LENGTH_REG_IDX,
ingress_packet_size);
// we need to parse again
// the alternative would be to pay the (huge) price of PHV copy for
// every ingress packet
// We need to parse again.
// The alternative would be to pay the (huge) price of PHV copy for
// every ingress packet.
// Since parsers can branch on the ingress port, we need to preserve it
// to ensure re-parsing gives the same result as the original parse.
// TODO(https://github.com/p4lang/behavioral-model/issues/795): other
// standard metadata should be preserved as well.
packet_copy->get_phv()
->get_field("standard_metadata.ingress_port")
.set(ingress_port);
parser->parse(packet_copy.get());
copy_field_list_and_set_type(packet, packet_copy,
PKT_INSTANCE_TYPE_INGRESS_CLONE,
Expand Down

0 comments on commit 6ec3ef8

Please sign in to comment.