blob: 06cba4fb5eeada4d5ee2aa588f19f5334d8fcf6c [file] [log] [blame]
Carmelo Cascone4f011022017-06-05 01:41:02 -04001counter ingress_port_counter {
2 type : packets; // bmv2 always counts both bytes and packets
3 instance_count : MAX_PORTS;
4 min_width : 32;
5}
6
7counter egress_port_counter {
8 type: packets;
9 instance_count : MAX_PORTS;
10 min_width : 32;
11}
12
13table port_count_table {
14 actions {
15 count_packet;
16 }
17}
18
19action count_packet() {
20 count(ingress_port_counter, standard_metadata.ingress_port);
21 count(egress_port_counter, standard_metadata.egress_spec);
22}
23
24control 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}