Carmelo Cascone | 4f01102 | 2017-06-05 01:41:02 -0400 | [diff] [blame] | 1 | counter ingress_port_counter { |
| 2 | type : packets; // bmv2 always counts both bytes and packets |
| 3 | instance_count : MAX_PORTS; |
| 4 | min_width : 32; |
| 5 | } |
| 6 | |
| 7 | counter egress_port_counter { |
| 8 | type: packets; |
| 9 | instance_count : MAX_PORTS; |
| 10 | min_width : 32; |
| 11 | } |
| 12 | |
| 13 | table port_count_table { |
| 14 | actions { |
| 15 | count_packet; |
| 16 | } |
| 17 | } |
| 18 | |
| 19 | action count_packet() { |
| 20 | count(ingress_port_counter, standard_metadata.ingress_port); |
| 21 | count(egress_port_counter, standard_metadata.egress_spec); |
| 22 | } |
| 23 | |
| 24 | control process_port_counters { |
| 25 | // Avoid counting logical ports, such as drop and cpu |
| 26 | if (standard_metadata.egress_spec < MAX_PORTS) { |
| 27 | apply(port_count_table); |
| 28 | } |
| 29 | } |