diff --git a/targets/pna_nic/pna_nic.cpp b/targets/pna_nic/pna_nic.cpp index 76aaa396..75e8c651 100644 --- a/targets/pna_nic/pna_nic.cpp +++ b/targets/pna_nic/pna_nic.cpp @@ -204,6 +204,21 @@ PnaNic::main_thread() { Deparser *deparser = this->get_deparser("main_deparser"); deparser->deparse(packet.get()); + + // recirculation + if ((port_t) packet->get_egress_port() == PNA_PORT_RECIRCULATE) { + BMLOG_DEBUG_PKT(*packet, "Recirculating packet"); + + phv->reset(); + phv->reset_header_stacks(); + phv->reset_metadata(); + + phv->get_field("pna_main_parser_input_metadata.recirculated") + .set(1); + input_buffer.push_front(std::move(packet)); + continue; + } + output_buffer.push_front(std::move(packet)); } } diff --git a/targets/pna_nic/pna_nic.h b/targets/pna_nic/pna_nic.h index c929f638..e1e17a74 100644 --- a/targets/pna_nic/pna_nic.h +++ b/targets/pna_nic/pna_nic.h @@ -79,6 +79,7 @@ class PnaNic : public Switch { private: static packet_id_t packet_id; + static constexpr port_t PNA_PORT_RECIRCULATE = 0xfffffffa; enum PktInstanceType { FROM_NET_PORT,