blob: 90916ba26d0db7b490d43d146205064f8399a64f [file] [log] [blame]
Yi Tseng21629932017-06-06 11:17:43 -07001#ifndef PORT_COUNTERS
2#define PORT_COUNTERS
3#include "defines.p4"
4
5control 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