Clarify and clean up some PiPipelineInterpreter usages

Change-Id: I3f48141e72d552259109aba20a6b34a93d94735a
diff --git a/apps/pi-demo/common/src/main/java/org/onosproject/pi/demo/app/common/AbstractUpgradableFabricApp.java b/apps/pi-demo/common/src/main/java/org/onosproject/pi/demo/app/common/AbstractUpgradableFabricApp.java
index 145cf50..94f27b6 100644
--- a/apps/pi-demo/common/src/main/java/org/onosproject/pi/demo/app/common/AbstractUpgradableFabricApp.java
+++ b/apps/pi-demo/common/src/main/java/org/onosproject/pi/demo/app/common/AbstractUpgradableFabricApp.java
@@ -461,17 +461,10 @@
         if (!device.is(PiPipelineInterpreter.class)) {
             throw new FlowRuleGeneratorException(format("Device %s has no PiPipelineInterpreter", did));
         }
-        final PiPipelineInterpreter interpreter = device.as(PiPipelineInterpreter.class);
-        final int flowRuleTableId;
-        if (interpreter.mapPiTableId(tableId).isPresent()) {
-            flowRuleTableId = interpreter.mapPiTableId(tableId).get();
-        } else {
-            throw new FlowRuleGeneratorException(format("Unknown table '%s' in interpreter", tableId));
-        }
 
         return DefaultFlowRule.builder()
                 .forDevice(did)
-                .forTable(flowRuleTableId)
+                .forTable(tableId)
                 .fromApp(appId)
                 .withPriority(FLOW_PRIORITY)
                 .makePermanent();
diff --git a/core/api/src/main/java/org/onosproject/net/pi/model/PiPipelineInterpreter.java b/core/api/src/main/java/org/onosproject/net/pi/model/PiPipelineInterpreter.java
index 1068026..ccf2733 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/model/PiPipelineInterpreter.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/model/PiPipelineInterpreter.java
@@ -64,7 +64,8 @@
 
     /**
      * Returns an integer table ID equivalent to the given PI table ID. If not present, it means that the given PI table
-     * ID refers to a table that does not exist, or that cannot be used for flow rule operations.
+     * ID cannot be mapped to any integer table ID, because such mapping would be meaningless or because such PI table
+     * ID is not defined by the pipeline model.
      *
      * @param piTableId PI table ID
      * @return numeric table ID
@@ -84,8 +85,10 @@
             throws PiInterpreterException;
 
     /**
-     * Returns a PI direct counter ID for the given table, if present. If not present, it means that the given table
-     * does not support direct counters.
+     * Returns a PI direct counter ID for the given table to be used to to compute flow entry statistics, if present. If
+     * not present, it means that the given table does not offer any counter suitable for the purpose of computing flow
+     * rule statistics. Other direct counters might be defined for the given table (check pipeline model), however none
+     * of them should be used for flow entry statistics except for this one.
      *
      * @param piTableId table ID
      * @return optional direct counter ID
diff --git a/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/P4RuntimeFlowRuleProgrammable.java b/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/P4RuntimeFlowRuleProgrammable.java
index 81626fe..898bfbf 100644
--- a/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/P4RuntimeFlowRuleProgrammable.java
+++ b/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/P4RuntimeFlowRuleProgrammable.java
@@ -135,13 +135,6 @@
 
             PiTableId piTableId = tableModel.id();
 
-            // Only dump tables that are exposed by the interpreter.
-            // The reason is that some P4 targets (e.g. BMv2's simple_switch) use more table than those defined in the
-            // P4 program, to implement other capabilities, e.g. action execution in control flow.
-            if (!interpreter.mapPiTableId(piTableId).isPresent()) {
-                continue; // next table
-            }
-
             Collection<PiTableEntry> installedEntries;
             try {
                 // TODO: optimize by dumping entries and counters in parallel, from ALL tables with the same request.