ONOS-6605 PI flow rule translator implementation
Change-Id: Icac66f17677c494152207f4b52355ad647e1227b
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 443c15b..8d06100 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
@@ -18,15 +18,17 @@
import com.google.common.annotations.Beta;
import org.onosproject.net.driver.HandlerBehaviour;
+import org.onosproject.net.flow.FlowRule;
import org.onosproject.net.flow.TrafficTreatment;
import org.onosproject.net.flow.criteria.Criterion;
import org.onosproject.net.pi.runtime.PiHeaderFieldId;
import org.onosproject.net.pi.runtime.PiTableAction;
+import org.onosproject.net.pi.runtime.PiTableId;
import java.util.Optional;
/**
- * An interpreter of a protocol-independent pipeline.
+ * An interpreter of a protocol-independent pipeline model.
*/
@Beta
public interface PiPipelineInterpreter extends HandlerBehaviour {
@@ -52,6 +54,16 @@
Optional<Criterion.Type> mapPiHeaderFieldId(PiHeaderFieldId headerFieldId);
/**
+ * Returns a protocol-independent table id equivalent to the given numeric table id (as in
+ * {@link FlowRule#tableId()}). If not present, it means that the given numeric table id cannot
+ * be mapped to any table of the pipeline model.
+ *
+ * @param flowRuleTableId a numeric table id
+ * @return a protocol-independent table id
+ */
+ Optional<PiTableId> mapFlowRuleTableId(int flowRuleTableId);
+
+ /**
* Returns a table action of a protocol-independent pipeline that is functionally equivalent to
* the given ONOS traffic treatment for the given pipeline configuration.
*
@@ -72,4 +84,4 @@
super(message);
}
}
-}
+}
\ No newline at end of file
diff --git a/core/api/src/main/java/org/onosproject/net/pi/model/PiTableModel.java b/core/api/src/main/java/org/onosproject/net/pi/model/PiTableModel.java
index 420b5f6..5709e4e 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/model/PiTableModel.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/model/PiTableModel.java
@@ -19,6 +19,7 @@
import com.google.common.annotations.Beta;
import java.util.Collection;
+import java.util.Optional;
/**
* Model of a match+action table in a protocol-independent pipeline.
@@ -67,4 +68,14 @@
* @return a collection of action models
*/
Collection<PiActionModel> actions();
+
+ /**
+ * Returns the action model associated with the given name, if present.
+ * If not present, it means that this table does not support such an action.
+ *
+ * @param name string value
+ * @return optional action model
+ */
+ Optional<PiActionModel> action(String name);
+
}