blob: 5da7a65c3ca21a0cd0269923adbf5731d26cfa0b [file] [log] [blame]
Carmelo Cascone16de6db2017-08-22 00:27:57 +02001#ifndef __PACKET_IO__
2#define __PACKET_IO__
3#include "headers.p4"
4#include "parser.p4"
5
6action _packet_out() {
7 modify_field(EGR_PORT_FIELD, packet_out_hdr.egress_port);
8 remove_header(packet_out_hdr);
9}
10
11table ingress_pkt {
12 actions {
13 _packet_out;
14 }
15 default_action: _packet_out();
16}
17
18control ingress_pkt_io {
19 if (valid(packet_out_hdr)) {
20 apply(ingress_pkt);
21 }
22}
23
24action add_packet_in_hdr() {
25 add_header(packet_in_hdr);
26 modify_field(packet_in_hdr.ingress_port, IGR_PORT_FIELD);
27}
28
29table egress_pkt {
30 actions {
31 add_packet_in_hdr;
32 }
33 default_action: add_packet_in_hdr();
34}
35
36control egress_pkt_io {
37 #ifdef __TOFINO_BUILD__
38 if (ig_intr_md_for_tm.copy_to_cpu == 1) {
39 #else
40 if (IGR_PORT_FIELD == CPU_PORT) {
41 #endif
42 apply(egress_pkt);
43 }
44}
45
46#endif