Removed pipeconf dependency from PiPipelineInterpreter
If needed, an interpreter implementation should know which pipeconf it
supports. Instead, mapping of treatments now depends on a table ID,
since table in P4 can potentially support different actions with similar
semantics.
Change-Id: Iffbc84457f08e5dba84a8e949931849006f82535
diff --git a/core/net/src/main/java/org/onosproject/net/pi/impl/PiFlowRuleTranslator.java b/core/net/src/main/java/org/onosproject/net/pi/impl/PiFlowRuleTranslator.java
index 14f15a5..8b28b5e 100644
--- a/core/net/src/main/java/org/onosproject/net/pi/impl/PiFlowRuleTranslator.java
+++ b/core/net/src/main/java/org/onosproject/net/pi/impl/PiFlowRuleTranslator.java
@@ -123,7 +123,7 @@
Collection<PiFieldMatch> fieldMatches = buildFieldMatches(interpreter, rule.selector(), table);
/* Translate treatment */
- PiAction piAction = buildAction(rule.treatment(), interpreter, pipeconf);
+ PiAction piAction = buildAction(rule.treatment(), interpreter, piTableId);
piAction = typeCheckAction(piAction, table);
PiTableEntry.Builder tableEntryBuilder = PiTableEntry.builder();
@@ -155,7 +155,7 @@
* Builds a PI action out of the given treatment, optionally using the given interpreter.
*/
private static PiAction buildAction(TrafficTreatment treatment, PiPipelineInterpreter interpreter,
- PiPipeconf pipeconf)
+ PiTableId tableId)
throws PiFlowRuleTranslationException {
PiTableAction piTableAction = null;
@@ -176,7 +176,7 @@
if (piTableAction == null && interpreter != null) {
// No PiInstruction, use interpreter to build action.
try {
- piTableAction = interpreter.mapTreatment(treatment, pipeconf);
+ piTableAction = interpreter.mapTreatment(treatment, tableId);
} catch (PiPipelineInterpreter.PiInterpreterException e) {
throw new PiFlowRuleTranslationException(
"Interpreter was unable to translate treatment. " + e.getMessage());
diff --git a/core/net/src/test/java/org/onosproject/net/pi/impl/MockInterpreter.java b/core/net/src/test/java/org/onosproject/net/pi/impl/MockInterpreter.java
index 14e698d..04535aa 100644
--- a/core/net/src/test/java/org/onosproject/net/pi/impl/MockInterpreter.java
+++ b/core/net/src/test/java/org/onosproject/net/pi/impl/MockInterpreter.java
@@ -25,7 +25,6 @@
import org.onosproject.net.flow.criteria.Criterion;
import org.onosproject.net.flow.instructions.Instruction;
import org.onosproject.net.packet.OutboundPacket;
-import org.onosproject.net.pi.model.PiPipeconf;
import org.onosproject.net.pi.model.PiPipelineInterpreter;
import org.onosproject.net.pi.runtime.PiAction;
import org.onosproject.net.pi.runtime.PiActionId;
@@ -33,7 +32,6 @@
import org.onosproject.net.pi.runtime.PiActionParamId;
import org.onosproject.net.pi.runtime.PiHeaderFieldId;
import org.onosproject.net.pi.runtime.PiPacketOperation;
-import org.onosproject.net.pi.runtime.PiTableAction;
import org.onosproject.net.pi.runtime.PiTableId;
import java.util.Collection;
@@ -68,7 +66,7 @@
0, PiTableId.of(TABLE0));
@Override
- public PiTableAction mapTreatment(TrafficTreatment treatment, PiPipeconf pipeconf) throws PiInterpreterException {
+ public PiAction mapTreatment(TrafficTreatment treatment, PiTableId piTableId) throws PiInterpreterException {
if (treatment.allInstructions().size() == 0) {
// No instructions means drop for us.
@@ -103,7 +101,7 @@
}
@Override
- public Collection<PiPacketOperation> mapOutboundPacket(OutboundPacket packet, PiPipeconf pipeconf)
+ public Collection<PiPacketOperation> mapOutboundPacket(OutboundPacket packet)
throws PiInterpreterException {
return ImmutableList.of();
}