Carmelo Cascone | 16de6db | 2017-08-22 00:27:57 +0200 | [diff] [blame^] | 1 | #ifndef __PACKET_IO__ |
| 2 | #define __PACKET_IO__ |
| 3 | #include "headers.p4" |
| 4 | #include "parser.p4" |
| 5 | |
| 6 | action _packet_out() { |
| 7 | modify_field(EGR_PORT_FIELD, packet_out_hdr.egress_port); |
| 8 | remove_header(packet_out_hdr); |
| 9 | } |
| 10 | |
| 11 | table ingress_pkt { |
| 12 | actions { |
| 13 | _packet_out; |
| 14 | } |
| 15 | default_action: _packet_out(); |
| 16 | } |
| 17 | |
| 18 | control ingress_pkt_io { |
| 19 | if (valid(packet_out_hdr)) { |
| 20 | apply(ingress_pkt); |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | action add_packet_in_hdr() { |
| 25 | add_header(packet_in_hdr); |
| 26 | modify_field(packet_in_hdr.ingress_port, IGR_PORT_FIELD); |
| 27 | } |
| 28 | |
| 29 | table egress_pkt { |
| 30 | actions { |
| 31 | add_packet_in_hdr; |
| 32 | } |
| 33 | default_action: add_packet_in_hdr(); |
| 34 | } |
| 35 | |
| 36 | control 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 |