From 43c5000dd321d2c8db4eedb90f38af72b4e97b88 Mon Sep 17 00:00:00 2001 From: Rupesh Chiluka Date: Wed, 30 Oct 2024 14:03:29 +0530 Subject: [PATCH] Added send_to_port extern --- targets/pna_nic/pna_nic.cpp | 5 ++++- targets/pna_nic/primitives.cpp | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/targets/pna_nic/pna_nic.cpp b/targets/pna_nic/pna_nic.cpp index d50510e6..76aaa396 100644 --- a/targets/pna_nic/pna_nic.cpp +++ b/targets/pna_nic/pna_nic.cpp @@ -99,6 +99,9 @@ PnaNic::receive_(port_t port_num, const char *buffer, int len) { // metadata to known values as given as input to the parser phv->reset_metadata(); + phv->get_field("pna_main_parser_input_metadata.recirculated").set(0); + phv->get_field("pna_main_parser_input_metadata.input_port").set(port_num); + // using packet register 0 to store length, this register will be updated for // each add_header / remove_header primitive call packet->set_register(PACKET_LENGTH_REG_IDX, len); @@ -154,7 +157,7 @@ PnaNic::transmit_thread() { BMLOG_DEBUG_PKT(*packet, "Transmitting packet of size {} out of port {}", packet->get_data_size(), packet->get_egress_port()); - my_transmit_fn(1, packet->get_packet_id(), + my_transmit_fn(packet->get_egress_port(), packet->get_packet_id(), packet->data(), packet->get_data_size()); } } diff --git a/targets/pna_nic/primitives.cpp b/targets/pna_nic/primitives.cpp index 24707f3b..6bd4ff5a 100644 --- a/targets/pna_nic/primitives.cpp +++ b/targets/pna_nic/primitives.cpp @@ -70,6 +70,15 @@ class remove_header : public ActionPrimitive
{ REGISTER_PRIMITIVE(remove_header); +// extern function: send_to_port +class send_to_port : public ActionPrimitive { + void operator ()(const Data &dest_port) { + get_packet().set_egress_port(dest_port.get()); + } +}; + +REGISTER_PRIMITIVE(send_to_port); + } // namespace bm::pna } // namespace pna