blob: 44a2b0edb31128a42d09e92c45a7bb8413a92f68 [file] [log] [blame]
#ifndef __PORT_COUNTERS_P4__
#define __PORT_COUNTERS_P4__
#include "defines.p4"
counter ingress_port_counter {
type : packets; // bmv2 always counts both bytes and packets
instance_count : MAX_PORTS;
min_width : 32;
}
counter egress_port_counter {
type: packets;
instance_count : MAX_PORTS;
min_width : 32;
}
action count_ingress() {
count(ingress_port_counter, IGR_PORT_FIELD);
}
action count_egress() {
count(egress_port_counter, EGR_PORT_FIELD);
}
table ingress_port_count_table {
actions { count_ingress; }
default_action: count_ingress;
}
table egress_port_count_table {
actions { count_egress; }
default_action: count_egress;
}
control process_port_counters {
if (EGR_PORT_FIELD < MAX_PORTS) {
apply(ingress_port_count_table);
apply(egress_port_count_table);
}
}
#endif