Yi Tseng | 2162993 | 2017-06-06 11:17:43 -0700 | [diff] [blame] | 1 | #ifndef PORT_COUNTERS |
| 2 | #define PORT_COUNTERS |
| 3 | #include "defines.p4" |
| 4 | |
| 5 | control PortCountersControl(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { |
| 6 | counter(MAX_PORTS, CounterType.packets) egress_port_counter; |
| 7 | counter(MAX_PORTS, CounterType.packets) ingress_port_counter; |
| 8 | |
| 9 | apply { |
| 10 | if (standard_metadata.egress_spec < MAX_PORTS) { |
| 11 | ingress_port_counter.count((bit<32>)standard_metadata.ingress_port); |
| 12 | egress_port_counter.count((bit<32>)standard_metadata.egress_spec); |
| 13 | } |
| 14 | } |
| 15 | } |
| 16 | #endif |