Skip to content

Commit

Permalink
Added send_to_port extern (#1272)
Browse files Browse the repository at this point in the history
Signed-off-by: Rupesh Chiluka <[email protected]>
  • Loading branch information
rupesh-chiluka-marvell authored Oct 30, 2024
1 parent 2db81fb commit 28b736c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 4 additions & 1 deletion targets/pna_nic/pna_nic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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());
}
}
Expand Down
9 changes: 9 additions & 0 deletions targets/pna_nic/primitives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@ class remove_header : public ActionPrimitive<Header &> {

REGISTER_PRIMITIVE(remove_header);

// extern function: send_to_port
class send_to_port : public ActionPrimitive<const Data &> {
void operator ()(const Data &dest_port) {
get_packet().set_egress_port(dest_port.get<uint32_t>());
}
};

REGISTER_PRIMITIVE(send_to_port);

} // namespace bm::pna

} // namespace pna
Expand Down

0 comments on commit 28b736c

Please sign in to comment.