blob: 5da7a65c3ca21a0cd0269923adbf5731d26cfa0b [file] [log] [blame]
#ifndef __PACKET_IO__
#define __PACKET_IO__
#include "headers.p4"
#include "parser.p4"
action _packet_out() {
modify_field(EGR_PORT_FIELD, packet_out_hdr.egress_port);
remove_header(packet_out_hdr);
}
table ingress_pkt {
actions {
_packet_out;
}
default_action: _packet_out();
}
control ingress_pkt_io {
if (valid(packet_out_hdr)) {
apply(ingress_pkt);
}
}
action add_packet_in_hdr() {
add_header(packet_in_hdr);
modify_field(packet_in_hdr.ingress_port, IGR_PORT_FIELD);
}
table egress_pkt {
actions {
add_packet_in_hdr;
}
default_action: add_packet_in_hdr();
}
control egress_pkt_io {
#ifdef __TOFINO_BUILD__
if (ig_intr_md_for_tm.copy_to_cpu == 1) {
#else
if (IGR_PORT_FIELD == CPU_PORT) {
#endif
apply(egress_pkt);
}
}
#endif