[ONOS-6596] Port example P4 programs from P4_14 to P4_16
Change-Id: I74485ea66894b425fa9f6508a67cb38dbef85a4f
diff --git a/tools/test/p4src/p4-16/include/port_counters.p4 b/tools/test/p4src/p4-16/include/port_counters.p4
new file mode 100644
index 0000000..90916ba
--- /dev/null
+++ b/tools/test/p4src/p4-16/include/port_counters.p4
@@ -0,0 +1,16 @@
+#ifndef PORT_COUNTERS
+#define PORT_COUNTERS
+#include "defines.p4"
+
+control PortCountersControl(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) {
+ counter(MAX_PORTS, CounterType.packets) egress_port_counter;
+ counter(MAX_PORTS, CounterType.packets) ingress_port_counter;
+
+ apply {
+ if (standard_metadata.egress_spec < MAX_PORTS) {
+ ingress_port_counter.count((bit<32>)standard_metadata.ingress_port);
+ egress_port_counter.count((bit<32>)standard_metadata.egress_spec);
+ }
+ }
+}
+#endif