blob: 93d2b4d028a61da3e25aac402422440f2a03e7e2 [file] [log] [blame]
Yi Tseng21629932017-06-06 11:17:43 -07001#ifndef PORT_COUNTERS
2#define PORT_COUNTERS
3#include "defines.p4"
4
Carmelo Cascone837e6452017-07-19 20:35:22 -04005control PortCountersControl(inout headers_t hdr, inout metadata_t meta, inout standard_metadata_t standard_metadata) {
Yi Tseng21629932017-06-06 11:17:43 -07006 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