Fixed bug in P4_16 programs that was making bmv2 crash

Change-Id: Ia5057b3080e55610605908cd36b399db6c50c545
diff --git a/tools/test/p4src/p4-16/include/port_counters.p4 b/tools/test/p4src/p4-16/include/port_counters.p4
index 15ed02f..d8667a3 100644
--- a/tools/test/p4src/p4-16/include/port_counters.p4
+++ b/tools/test/p4src/p4-16/include/port_counters.p4
@@ -24,9 +24,11 @@
 
     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);
         }
+        if (standard_metadata.ingress_port < MAX_PORTS) {
+            ingress_port_counter.count((bit<32>)standard_metadata.ingress_port);
+        }
     }
 }
 #endif