ONOS-7066 ONOS-7067 PI abstractions refactoring and P4Info model parser

Includes changes previously reviewed in #15607, #15877, and #15955.

Change-Id: Ie2ff62e415f2099832ebfe05961a879b7b188fc3
diff --git a/core/api/src/main/java/org/onosproject/net/pi/model/PiPipelineProgrammable.java b/core/api/src/main/java/org/onosproject/net/behaviour/PiPipelineProgrammable.java
similarity index 85%
rename from core/api/src/main/java/org/onosproject/net/pi/model/PiPipelineProgrammable.java
rename to core/api/src/main/java/org/onosproject/net/behaviour/PiPipelineProgrammable.java
index c222fe6..2373af4 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/model/PiPipelineProgrammable.java
+++ b/core/api/src/main/java/org/onosproject/net/behaviour/PiPipelineProgrammable.java
@@ -14,16 +14,19 @@
  * limitations under the License.
  */
 
-package org.onosproject.net.pi.model;
+package org.onosproject.net.behaviour;
 
+import com.google.common.annotations.Beta;
 import org.onosproject.net.driver.HandlerBehaviour;
+import org.onosproject.net.pi.model.PiPipeconf;
 
 import java.util.Optional;
 import java.util.concurrent.CompletableFuture;
 
 /**
- * Behavior to program the pipeline of a device.
+ * Behavior to program the pipeline of a device that supports protocol-independence.
  */
+@Beta
 public interface PiPipelineProgrammable extends HandlerBehaviour {
     /**
      * Deploys the given pipeconf to the device.
diff --git a/core/api/src/main/java/org/onosproject/net/flow/criteria/PiCriterion.java b/core/api/src/main/java/org/onosproject/net/flow/criteria/PiCriterion.java
index d0a4732..2ba0bc8 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/criteria/PiCriterion.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/criteria/PiCriterion.java
@@ -19,9 +19,9 @@
 import com.google.common.annotations.Beta;
 import com.google.common.base.Objects;
 import com.google.common.collect.ImmutableMap;
+import org.onosproject.net.pi.model.PiMatchFieldId;
 import org.onosproject.net.pi.runtime.PiExactFieldMatch;
 import org.onosproject.net.pi.runtime.PiFieldMatch;
-import org.onosproject.net.pi.runtime.PiHeaderFieldId;
 import org.onosproject.net.pi.runtime.PiLpmFieldMatch;
 import org.onosproject.net.pi.runtime.PiRangeFieldMatch;
 import org.onosproject.net.pi.runtime.PiTernaryFieldMatch;
@@ -40,14 +40,14 @@
 @Beta
 public final class PiCriterion implements Criterion {
 
-    private final ImmutableMap<PiHeaderFieldId, PiFieldMatch> fieldMatchMap;
+    private final ImmutableMap<PiMatchFieldId, PiFieldMatch> fieldMatchMap;
 
     /**
      * Creates a new protocol-independent criterion for the given match fields.
      *
      * @param fieldMatchMap field match map
      */
-    private PiCriterion(ImmutableMap<PiHeaderFieldId, PiFieldMatch> fieldMatchMap) {
+    private PiCriterion(ImmutableMap<PiMatchFieldId, PiFieldMatch> fieldMatchMap) {
         this.fieldMatchMap = fieldMatchMap;
     }
 
@@ -66,7 +66,7 @@
      * @param fieldId field identifier
      * @return optional field match
      */
-    public Optional<PiFieldMatch> fieldMatch(PiHeaderFieldId fieldId) {
+    public Optional<PiFieldMatch> fieldMatch(PiMatchFieldId fieldId) {
         return Optional.ofNullable(fieldMatchMap.get(fieldId));
     }
 
@@ -115,7 +115,7 @@
     public static final class Builder {
 
         // Use map to guarantee that there's only one field match per field id.
-        private final ImmutableMap.Builder<PiHeaderFieldId, PiFieldMatch> fieldMatchMapBuilder = ImmutableMap.builder();
+        private final ImmutableMap.Builder<PiMatchFieldId, PiFieldMatch> fieldMatchMapBuilder = ImmutableMap.builder();
 
         private Builder() {
             // ban constructor.
@@ -128,7 +128,7 @@
          * @param value   exact match value
          * @return this
          */
-        public Builder matchExact(PiHeaderFieldId fieldId, short value) {
+        public Builder matchExact(PiMatchFieldId fieldId, short value) {
             fieldMatchMapBuilder.put(fieldId, new PiExactFieldMatch(fieldId, copyFrom(value)));
             return this;
         }
@@ -140,7 +140,7 @@
          * @param value   exact match value
          * @return this
          */
-        public Builder matchExact(PiHeaderFieldId fieldId, int value) {
+        public Builder matchExact(PiMatchFieldId fieldId, int value) {
             fieldMatchMapBuilder.put(fieldId, new PiExactFieldMatch(fieldId, copyFrom(value)));
             return this;
         }
@@ -152,7 +152,7 @@
          * @param value   exact match value
          * @return this
          */
-        public Builder matchExact(PiHeaderFieldId fieldId, long value) {
+        public Builder matchExact(PiMatchFieldId fieldId, long value) {
             fieldMatchMapBuilder.put(fieldId, new PiExactFieldMatch(fieldId, copyFrom(value)));
             return this;
         }
@@ -164,7 +164,7 @@
          * @param value   exact match value
          * @return this
          */
-        public Builder matchExact(PiHeaderFieldId fieldId, byte[] value) {
+        public Builder matchExact(PiMatchFieldId fieldId, byte[] value) {
             fieldMatchMapBuilder.put(fieldId, new PiExactFieldMatch(fieldId, copyFrom(value)));
             return this;
         }
@@ -177,7 +177,7 @@
          * @param mask    ternary match mask
          * @return this
          */
-        public Builder matchTernary(PiHeaderFieldId fieldId, short value, short mask) {
+        public Builder matchTernary(PiMatchFieldId fieldId, short value, short mask) {
             fieldMatchMapBuilder.put(fieldId, new PiTernaryFieldMatch(fieldId, copyFrom(value), copyFrom(mask)));
             return this;
         }
@@ -190,7 +190,7 @@
          * @param mask    ternary match mask
          * @return this
          */
-        public Builder matchTernary(PiHeaderFieldId fieldId, int value, int mask) {
+        public Builder matchTernary(PiMatchFieldId fieldId, int value, int mask) {
             fieldMatchMapBuilder.put(fieldId, new PiTernaryFieldMatch(fieldId, copyFrom(value), copyFrom(mask)));
             return this;
         }
@@ -203,7 +203,7 @@
          * @param mask    ternary match mask
          * @return this
          */
-        public Builder matchTernary(PiHeaderFieldId fieldId, long value, long mask) {
+        public Builder matchTernary(PiMatchFieldId fieldId, long value, long mask) {
             fieldMatchMapBuilder.put(fieldId, new PiTernaryFieldMatch(fieldId, copyFrom(value), copyFrom(mask)));
             return this;
         }
@@ -216,7 +216,7 @@
          * @param mask    ternary match mask
          * @return this
          */
-        public Builder matchTernary(PiHeaderFieldId fieldId, byte[] value, byte[] mask) {
+        public Builder matchTernary(PiMatchFieldId fieldId, byte[] value, byte[] mask) {
             fieldMatchMapBuilder.put(fieldId, new PiTernaryFieldMatch(fieldId, copyFrom(value), copyFrom(mask)));
             return this;
         }
@@ -229,7 +229,7 @@
          * @param prefixLength lpm match prefix length
          * @return this
          */
-        public Builder matchLpm(PiHeaderFieldId fieldId, short value, int prefixLength) {
+        public Builder matchLpm(PiMatchFieldId fieldId, short value, int prefixLength) {
             fieldMatchMapBuilder.put(fieldId, new PiLpmFieldMatch(fieldId, copyFrom(value), prefixLength));
             return this;
         }
@@ -242,7 +242,7 @@
          * @param prefixLength lpm match prefix length
          * @return this
          */
-        public Builder matchLpm(PiHeaderFieldId fieldId, int value, int prefixLength) {
+        public Builder matchLpm(PiMatchFieldId fieldId, int value, int prefixLength) {
             fieldMatchMapBuilder.put(fieldId, new PiLpmFieldMatch(fieldId, copyFrom(value), prefixLength));
             return this;
         }
@@ -255,7 +255,7 @@
          * @param prefixLength lpm match prefix length
          * @return this
          */
-        public Builder matchLpm(PiHeaderFieldId fieldId, long value, int prefixLength) {
+        public Builder matchLpm(PiMatchFieldId fieldId, long value, int prefixLength) {
             fieldMatchMapBuilder.put(fieldId, new PiLpmFieldMatch(fieldId, copyFrom(value), prefixLength));
             return this;
         }
@@ -268,7 +268,7 @@
          * @param prefixLength lpm match prefix length
          * @return this
          */
-        public Builder matchLpm(PiHeaderFieldId fieldId, byte[] value, int prefixLength) {
+        public Builder matchLpm(PiMatchFieldId fieldId, byte[] value, int prefixLength) {
             fieldMatchMapBuilder.put(fieldId, new PiLpmFieldMatch(fieldId, copyFrom(value), prefixLength));
             return this;
         }
@@ -280,7 +280,7 @@
          * @param flag    a boolean value
          * @return this
          */
-        public Builder matchValid(PiHeaderFieldId fieldId, boolean flag) {
+        public Builder matchValid(PiMatchFieldId fieldId, boolean flag) {
             fieldMatchMapBuilder.put(fieldId, new PiValidFieldMatch(fieldId, flag));
             return this;
         }
@@ -293,7 +293,7 @@
          * @param high    range match high value
          * @return this
          */
-        public Builder matchRange(PiHeaderFieldId fieldId, short low, short high) {
+        public Builder matchRange(PiMatchFieldId fieldId, short low, short high) {
             fieldMatchMapBuilder.put(fieldId, new PiRangeFieldMatch(fieldId, copyFrom(low), copyFrom(high)));
             return this;
         }
@@ -306,7 +306,7 @@
          * @param high    range match high value
          * @return this
          */
-        public Builder matchRange(PiHeaderFieldId fieldId, int low, int high) {
+        public Builder matchRange(PiMatchFieldId fieldId, int low, int high) {
             fieldMatchMapBuilder.put(fieldId, new PiRangeFieldMatch(fieldId, copyFrom(low), copyFrom(high)));
             return this;
         }
@@ -319,7 +319,7 @@
          * @param high    range match high value
          * @return this
          */
-        public Builder matchRange(PiHeaderFieldId fieldId, long low, long high) {
+        public Builder matchRange(PiMatchFieldId fieldId, long low, long high) {
             fieldMatchMapBuilder.put(fieldId, new PiRangeFieldMatch(fieldId, copyFrom(low), copyFrom(high)));
             return this;
         }
@@ -332,7 +332,7 @@
          * @param high    range match high value
          * @return this
          */
-        public Builder matchRange(PiHeaderFieldId fieldId, byte[] low, byte[] high) {
+        public Builder matchRange(PiMatchFieldId fieldId, byte[] low, byte[] high) {
             fieldMatchMapBuilder.put(fieldId, new PiRangeFieldMatch(fieldId, copyFrom(low), copyFrom(high)));
             return this;
         }
@@ -343,9 +343,9 @@
          * @return PiCriterion
          */
         public PiCriterion build() {
-            ImmutableMap<PiHeaderFieldId, PiFieldMatch> fieldMatchMap = fieldMatchMapBuilder.build();
+            ImmutableMap<PiMatchFieldId, PiFieldMatch> fieldMatchMap = fieldMatchMapBuilder.build();
             checkArgument(fieldMatchMap.size() > 0, "Cannot build PI criterion with 0 field matches");
             return new PiCriterion(fieldMatchMap);
         }
     }
-}
\ No newline at end of file
+}
diff --git a/core/api/src/main/java/org/onosproject/net/pi/model/PiHeaderFieldTypeModel.java b/core/api/src/main/java/org/onosproject/net/pi/model/PiActionGroupType.java
similarity index 67%
copy from core/api/src/main/java/org/onosproject/net/pi/model/PiHeaderFieldTypeModel.java
copy to core/api/src/main/java/org/onosproject/net/pi/model/PiActionGroupType.java
index 2f4c67b..dd92888 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/model/PiHeaderFieldTypeModel.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/model/PiActionGroupType.java
@@ -19,21 +19,13 @@
 import com.google.common.annotations.Beta;
 
 /**
- * Model of a header's field type in a protocol-independent pipeline.
+ * Type of action group in a protocol-independent pipeline.
  */
 @Beta
-public interface PiHeaderFieldTypeModel {
-    /**
-     * Returns the name of this header type field.
-     *
-     * @return a string value
-     */
-    String name();
+public enum PiActionGroupType {
 
     /**
-     * Returns the bit width of this header type field.
-     *
-     * @return an integer value
+     * Performs load-balancing among different members of the group.
      */
-    int bitWidth();
+    SELECT
 }
diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionId.java b/core/api/src/main/java/org/onosproject/net/pi/model/PiActionId.java
similarity index 83%
rename from core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionId.java
rename to core/api/src/main/java/org/onosproject/net/pi/model/PiActionId.java
index 7059fb1..1718726 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionId.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/model/PiActionId.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package org.onosproject.net.pi.runtime;
+package org.onosproject.net.pi.model;
 
 import com.google.common.annotations.Beta;
 import org.onlab.util.Identifier;
@@ -23,7 +23,8 @@
 import static com.google.common.base.Preconditions.checkNotNull;
 
 /**
- * Identifier of an action of a match+action table in a protocol-independent pipeline.
+ * Identifier of an action of a match+action table in a protocol-independent pipeline, unique within the scope of a
+ * pipeline model.
  */
 @Beta
 public final class PiActionId extends Identifier<String> {
@@ -38,16 +39,7 @@
     }
 
     /**
-     * Returns the name of the action.
-     *
-     * @return action name
-     */
-    public String name() {
-        return this.identifier;
-    }
-
-    /**
-     * Returns an action identifier with the given name.
+     * Returns an action identifier for the given action name.
      *
      * @param name action name
      * @return action identifier
diff --git a/core/api/src/main/java/org/onosproject/net/pi/model/PiActionModel.java b/core/api/src/main/java/org/onosproject/net/pi/model/PiActionModel.java
index 8fd8dc4..4dad230 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/model/PiActionModel.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/model/PiActionModel.java
@@ -18,7 +18,7 @@
 
 import com.google.common.annotations.Beta;
 
-import java.util.List;
+import java.util.Collection;
 import java.util.Optional;
 
 /**
@@ -26,26 +26,27 @@
  */
 @Beta
 public interface PiActionModel {
-    /**
-     * Returns the name of this action.
-     *
-     * @return a string value
-     */
-    String name();
 
     /**
-     * Returns the model of this action's parameter defined by the given name, if present.
+     * Returns the ID of the action.
      *
-     * @param name action name
+     * @return action ID
+     */
+    PiActionId id();
+
+    /**
+     * Returns the model of the action's parameter defined by the given ID, if present.
+     *
+     * @param paramId parameter ID
      * @return action parameter model
      */
-    Optional<PiActionParamModel> param(String name);
+    Optional<PiActionParamModel> param(PiActionParamId paramId);
 
     /**
-     * Returns the list of action parameter models, ordered according to the same action parameters
-     * defined in the pipeline model.
+     * Returns the collection of all parameter models for the action, or an empty collection if this action has no
+     * parameters.
      *
-     * @return list of action parameter models
+     * @return collection of action parameter models
      */
-    List<PiActionParamModel> params();
+    Collection<PiActionParamModel> params();
 }
diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionParamId.java b/core/api/src/main/java/org/onosproject/net/pi/model/PiActionParamId.java
similarity index 68%
rename from core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionParamId.java
rename to core/api/src/main/java/org/onosproject/net/pi/model/PiActionParamId.java
index 70279ab..143c7bd 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionParamId.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/model/PiActionParamId.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package org.onosproject.net.pi.runtime;
+package org.onosproject.net.pi.model;
 
 import com.google.common.annotations.Beta;
 import org.onlab.util.Identifier;
@@ -23,32 +23,18 @@
 import static com.google.common.base.Preconditions.checkNotNull;
 
 /**
- * Identifier of an action's runtime parameter in a match+action table of a protocol-independent pipeline.
+ * Identifier of an action runtime parameter in a match+action table of a protocol-independent pipeline, unique within
+ * the scope an action model.
  */
 @Beta
 public final class PiActionParamId extends Identifier<String> {
 
-    private final String name;
-
-    // TODO: if needed, we might add here support for positional parameters.
-    // E.g. add a second constructor that takes the "position" of a parameter, vs. its name.
-
     private PiActionParamId(String name) {
         super(name);
-        this.name = name;
     }
 
     /**
-     * Returns the name of this parameter.
-     *
-     * @return parameter name
-     */
-    public String name() {
-        return name;
-    }
-
-    /**
-     * Returns a parameter identifier with the given name.
+     * Returns a parameter identifier for the given parameter name.
      *
      * @param name parameter name
      * @return parameter identifier
diff --git a/core/api/src/main/java/org/onosproject/net/pi/model/PiActionParamModel.java b/core/api/src/main/java/org/onosproject/net/pi/model/PiActionParamModel.java
index 22ceef6..284d2b2 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/model/PiActionParamModel.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/model/PiActionParamModel.java
@@ -19,21 +19,22 @@
 import com.google.common.annotations.Beta;
 
 /**
- * Model of an action parameter in a protocol-independent pipeline.
+ * Model of an action runtime parameter in a protocol-independent pipeline.
  */
 @Beta
 public interface PiActionParamModel {
-    /**
-     * Returns the name of this action parameter.
-     *
-     * @return a string value
-     */
-    String name();
 
     /**
-     * Return the bit width of this action parameter.
+     * Returns the ID of this action parameter.
      *
-     * @return an integer value
+     * @return action parameter ID
+     */
+    PiActionParamId id();
+
+    /**
+     * Return the size in bits of this action parameter.
+     *
+     * @return size in bits
      */
     int bitWidth();
 }
diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionProfileId.java b/core/api/src/main/java/org/onosproject/net/pi/model/PiActionProfileId.java
similarity index 70%
rename from core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionProfileId.java
rename to core/api/src/main/java/org/onosproject/net/pi/model/PiActionProfileId.java
index e0158c9..5ff6cae 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionProfileId.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/model/PiActionProfileId.java
@@ -14,13 +14,13 @@
  * limitations under the License.
  */
 
-package org.onosproject.net.pi.runtime;
+package org.onosproject.net.pi.model;
 
 import com.google.common.annotations.Beta;
 import org.onlab.util.Identifier;
 
 /**
- * Identifier of an action profile of a protocol-independent pipeline.
+ * Identifier of an action profile in a protocol-independent pipeline, unique withing the scope of a pipeline model.
  */
 @Beta
 public final class PiActionProfileId extends Identifier<String> {
@@ -30,12 +30,12 @@
     }
 
     /**
-     * Returns action profile id with given action profile name.
+     * Returns an identifier for the given action profile name.
      *
-     * @param actionProfileName action profile name
-     * @return action profile id
+     * @param name action profile name
+     * @return action profile ID
      */
-    public static PiActionProfileId of(String actionProfileName) {
-        return new PiActionProfileId(actionProfileName);
+    public static PiActionProfileId of(String name) {
+        return new PiActionProfileId(name);
     }
 }
diff --git a/core/api/src/main/java/org/onosproject/net/pi/model/PiActionProfileModel.java b/core/api/src/main/java/org/onosproject/net/pi/model/PiActionProfileModel.java
new file mode 100644
index 0000000..66b8c53
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/pi/model/PiActionProfileModel.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.net.pi.model;
+
+import com.google.common.annotations.Beta;
+
+import java.util.Collection;
+
+/**
+ * Model of an action profile in a protocol-independent pipeline.
+ */
+@Beta
+public interface PiActionProfileModel {
+
+    /**
+     * Returns the ID of this action profile.
+     *
+     * @return action profile ID
+     */
+    PiActionProfileId id();
+
+    /**
+     * Returns the collection of table IDs that use this action profile.
+     *
+     * @return collection of table models
+     */
+    Collection<PiTableId> tables();
+
+    /**
+     * Returns true if this action profile implements dynamic selection, false otherwise.
+     *
+     * @return true if action profile implements dynamic selection, false otherwise
+     */
+    boolean hasSelector();
+
+    /**
+     * Returns the maximum number of member entries of this action profile.
+     *
+     * @return maximum number of member entries
+     */
+    long maxSize();
+}
diff --git a/core/api/src/main/java/org/onosproject/net/pi/model/PiControlMetadataId.java b/core/api/src/main/java/org/onosproject/net/pi/model/PiControlMetadataId.java
new file mode 100644
index 0000000..b17c766
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/pi/model/PiControlMetadataId.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.net.pi.model;
+
+import com.google.common.annotations.Beta;
+import org.onlab.util.Identifier;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Identifier of a control metadata in a protocol-independent pipeline, unique within the scope of a pipeline model.
+ */
+@Beta
+public final class PiControlMetadataId extends Identifier<String> {
+
+    private PiControlMetadataId(String name) {
+        super(name);
+    }
+
+    /**
+     * Returns an identifier for the given control metadata name.
+     *
+     * @param name control metadata name
+     * @return control metadata ID
+     */
+    public static PiControlMetadataId of(String name) {
+        checkNotNull(name);
+        checkArgument(!name.isEmpty(), "Name can't be empty");
+        return new PiControlMetadataId(name);
+    }
+}
diff --git a/core/api/src/main/java/org/onosproject/net/pi/model/PiHeaderFieldTypeModel.java b/core/api/src/main/java/org/onosproject/net/pi/model/PiControlMetadataModel.java
similarity index 71%
rename from core/api/src/main/java/org/onosproject/net/pi/model/PiHeaderFieldTypeModel.java
rename to core/api/src/main/java/org/onosproject/net/pi/model/PiControlMetadataModel.java
index 2f4c67b..3748eac 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/model/PiHeaderFieldTypeModel.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/model/PiControlMetadataModel.java
@@ -19,21 +19,22 @@
 import com.google.common.annotations.Beta;
 
 /**
- * Model of a header's field type in a protocol-independent pipeline.
+ * Model of a control metadata for a protocol-independent pipeline.
  */
 @Beta
-public interface PiHeaderFieldTypeModel {
-    /**
-     * Returns the name of this header type field.
-     *
-     * @return a string value
-     */
-    String name();
+public interface PiControlMetadataModel {
 
     /**
-     * Returns the bit width of this header type field.
+     * Returns the ID of this control metadata.
      *
-     * @return an integer value
+     * @return packet operation metadata ID
+     */
+    PiControlMetadataId id();
+
+    /**
+     * Returns the size in bits of this metadata.
+     *
+     * @return size in bit
      */
     int bitWidth();
 }
diff --git a/core/api/src/main/java/org/onosproject/net/pi/model/PiCounterId.java b/core/api/src/main/java/org/onosproject/net/pi/model/PiCounterId.java
new file mode 100644
index 0000000..e9fdc5b
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/pi/model/PiCounterId.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.net.pi.model;
+
+import com.google.common.annotations.Beta;
+import org.onlab.util.Identifier;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Identifier of a counter in a protocol-independent pipeline, unique within the scope of a pipeline model.
+ */
+@Beta
+public final class PiCounterId extends Identifier<String> {
+
+    private PiCounterId(String name) {
+        super(name);
+    }
+
+    /**
+     * Returns an identifier for the given counter name.
+     *
+     * @param name counter name
+     * @return counter ID
+     */
+    public static PiCounterId of(String name) {
+        checkNotNull(name);
+        checkArgument(!name.isEmpty(), "Name can't be empty");
+        return new PiCounterId(name);
+    }
+}
diff --git a/core/api/src/main/java/org/onosproject/net/pi/model/PiCounterModel.java b/core/api/src/main/java/org/onosproject/net/pi/model/PiCounterModel.java
new file mode 100644
index 0000000..4cfbc92
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/pi/model/PiCounterModel.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.net.pi.model;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * Model of a counter in protocol-independent pipeline.
+ */
+@Beta
+public interface PiCounterModel {
+
+    /**
+     * Counter unit.
+     */
+    enum Unit {
+        /**
+         * Counts only bytes.
+         */
+        BYTES,
+        /**
+         * Counts only packets.
+         */
+        PACKETS,
+        /**
+         * Counts both packets and bytes.
+         */
+        PACKETS_AND_BYTES
+    }
+
+    /**
+     * Returns the ID of this counter.
+     *
+     * @return counter ID
+     */
+    PiCounterId id();
+
+    /**
+     * Returns the type of counter.
+     *
+     * @return counter type
+     */
+    PiCounterType counterType();
+
+    /**
+     * Returns the unit of this counter.
+     *
+     * @return counter unit
+     */
+    Unit unit();
+
+    /**
+     * Returns the table ID associated with this counter. Meaningful only if the counter type is {@link
+     * PiCounterType#DIRECT}.
+     *
+     * @return table model
+     */
+    PiTableId table();
+
+    /**
+     * Returns the number of cells of this counter. Meaningful only if the counter type is {@link
+     * PiCounterType#INDIRECT}.
+     *
+     * @return size
+     */
+    long size();
+}
diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiCounterType.java b/core/api/src/main/java/org/onosproject/net/pi/model/PiCounterType.java
similarity index 91%
rename from core/api/src/main/java/org/onosproject/net/pi/runtime/PiCounterType.java
rename to core/api/src/main/java/org/onosproject/net/pi/model/PiCounterType.java
index b4a709a..4e73483 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiCounterType.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/model/PiCounterType.java
@@ -14,12 +14,16 @@
  * limitations under the License.
  */
 
-package org.onosproject.net.pi.runtime;
+package org.onosproject.net.pi.model;
+
+import com.google.common.annotations.Beta;
 
 /**
  * Type of counter in a protocol-independent pipeline.
  */
+@Beta
 public enum PiCounterType {
+
     /**
      * Identifies a counter associated to a match-action table, where cells are directly associated to table entries.
      */
diff --git a/core/api/src/main/java/org/onosproject/net/pi/model/PiHeaderFieldModel.java b/core/api/src/main/java/org/onosproject/net/pi/model/PiHeaderFieldModel.java
deleted file mode 100644
index 25e9aa1..0000000
--- a/core/api/src/main/java/org/onosproject/net/pi/model/PiHeaderFieldModel.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.net.pi.model;
-
-import com.google.common.annotations.Beta;
-
-/**
- * Model of a header's field instance in a protocol-independent pipeline.
- */
-@Beta
-public interface PiHeaderFieldModel {
-    /**
-     * Returns the header instance of this field instance.
-     *
-     * @return a header instance
-     */
-    PiHeaderModel header();
-
-    /**
-     * Returns the type of this header's field instance.
-     *
-     * @return a field type value
-     */
-    PiHeaderFieldTypeModel type();
-}
diff --git a/core/api/src/main/java/org/onosproject/net/pi/model/PiHeaderModel.java b/core/api/src/main/java/org/onosproject/net/pi/model/PiHeaderModel.java
deleted file mode 100644
index 22d1a24..0000000
--- a/core/api/src/main/java/org/onosproject/net/pi/model/PiHeaderModel.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.net.pi.model;
-
-import com.google.common.annotations.Beta;
-
-/**
- * Model of a header instance in a protocol-independent pipeline.
- */
-@Beta
-public interface PiHeaderModel {
-
-    /**
-     * Returns the name of this header instance.
-     *
-     * @return a string value
-     */
-    String name();
-
-    /**
-     * Returns the type of this header instance.
-     *
-     * @return a header type value
-     */
-    PiHeaderTypeModel type();
-
-    /**
-     * Returns true if this header instance is a metadata, false elsewhere.
-     *
-     * @return a boolean value
-     */
-    boolean isMetadata();
-
-    /**
-     * Returns the index of this header w.r.t. to other headers of the same type.
-     * Index 0 points to the first instance of the header, 1 the second one, etc.
-     * Helpful when dealing with stacked headers. e.g. to match on the second MPLS label.
-     *
-     * @return a non-negative integer value
-     */
-    default int index() {
-        return 0;
-    }
-}
diff --git a/core/api/src/main/java/org/onosproject/net/pi/model/PiHeaderTypeModel.java b/core/api/src/main/java/org/onosproject/net/pi/model/PiHeaderTypeModel.java
deleted file mode 100644
index cfb5ad5..0000000
--- a/core/api/src/main/java/org/onosproject/net/pi/model/PiHeaderTypeModel.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.net.pi.model;
-
-import com.google.common.annotations.Beta;
-
-import java.util.List;
-import java.util.Optional;
-
-/**
- * Model of a header type in a protocol-independent pipeline.
- */
-@Beta
-public interface PiHeaderTypeModel {
-
-    /**
-     * Returns the name of this header type.
-     *
-     * @return name
-     */
-    String name();
-
-    /**
-     * Returns the field type model defined by the given name, if present.
-     *
-     * @param fieldName field name
-     * @return optional field type model
-     */
-    Optional<PiHeaderFieldTypeModel> field(String fieldName);
-
-    /**
-     * Returns a list of field type models for this header type, ordered according to the same
-     * order of header fields as defined in the pipeline model.
-     *
-     * @return list of field type models
-     */
-    List<PiHeaderFieldTypeModel> fields();
-}
diff --git a/core/api/src/main/java/org/onosproject/net/pi/model/PiMatchFieldId.java b/core/api/src/main/java/org/onosproject/net/pi/model/PiMatchFieldId.java
new file mode 100644
index 0000000..ae6f7ca
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/pi/model/PiMatchFieldId.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.net.pi.model;
+
+import com.google.common.annotations.Beta;
+import org.onlab.util.Identifier;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Identifier of a match field in a protocol-independent pipeline, unique within the scope of a table model.
+ */
+@Beta
+public final class PiMatchFieldId extends Identifier<String> {
+
+    private PiMatchFieldId(String name) {
+        super(name);
+    }
+
+    /**
+     * Returns an identifier for the given match field name.
+     *
+     * @param name match field name
+     * @return match field ID
+     */
+    public static PiMatchFieldId of(String name) {
+        checkNotNull(name);
+        checkArgument(!name.isEmpty(), "Name cannot be empty");
+        return new PiMatchFieldId(name);
+    }
+}
diff --git a/core/api/src/main/java/org/onosproject/net/pi/model/PiTableMatchFieldModel.java b/core/api/src/main/java/org/onosproject/net/pi/model/PiMatchFieldModel.java
similarity index 73%
rename from core/api/src/main/java/org/onosproject/net/pi/model/PiTableMatchFieldModel.java
rename to core/api/src/main/java/org/onosproject/net/pi/model/PiMatchFieldModel.java
index 4daf96f..57d817a 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/model/PiTableMatchFieldModel.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/model/PiMatchFieldModel.java
@@ -22,18 +22,26 @@
  * Model of a table match field in a protocol-independent pipeline.
  */
 @Beta
-public interface PiTableMatchFieldModel {
+public interface PiMatchFieldModel {
+
     /**
-     * Returns the match type of this key.
+     * Returns the ID of this match field.
+     *
+     * @return match field ID
+     */
+    PiMatchFieldId id();
+
+    /**
+     * Returns the number of bits matched by this field.
+     *
+     * @return number of bits
+     */
+    int bitWidth();
+
+    /**
+     * Returns the type of match applied to this field.
      *
      * @return a match type
      */
     PiMatchType matchType();
-
-    /**
-     * Returns the header field instance matched by this key.
-     *
-     * @return a header field value
-     */
-    PiHeaderFieldModel field();
 }
diff --git a/core/api/src/main/java/org/onosproject/net/pi/model/PiMatchType.java b/core/api/src/main/java/org/onosproject/net/pi/model/PiMatchType.java
index 4f6ab07..1e24fce 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/model/PiMatchType.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/model/PiMatchType.java
@@ -23,22 +23,27 @@
  */
 @Beta
 public enum PiMatchType {
+
     /**
      * Exact match type.
      */
     EXACT,
+
     /**
      * Ternary match type.
      */
     TERNARY,
+
     /**
      * Longest-prefix match type.
      */
     LPM,
+
     /**
      * Valid match type.
      */
     VALID,
+
     /**
      * Range match type.
      */
diff --git a/core/api/src/main/java/org/onosproject/net/pi/model/PiMeterId.java b/core/api/src/main/java/org/onosproject/net/pi/model/PiMeterId.java
new file mode 100644
index 0000000..cc88133
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/pi/model/PiMeterId.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.net.pi.model;
+
+import com.google.common.annotations.Beta;
+import org.onlab.util.Identifier;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Identifier of a meter in a protocol-independent pipeline, unique within the scope of a pipeline model.
+ */
+@Beta
+public final class PiMeterId extends Identifier<String> {
+
+    private PiMeterId(String name) {
+        super(name);
+    }
+
+    /**
+     * Returns an identifier for the given meter name.
+     *
+     * @param name meter name
+     * @return meter ID
+     */
+    public static PiMeterId of(String name) {
+        checkNotNull(name);
+        checkArgument(!name.isEmpty(), "Name can't be empty");
+        return new PiMeterId(name);
+    }
+}
diff --git a/core/api/src/main/java/org/onosproject/net/pi/model/PiMeterModel.java b/core/api/src/main/java/org/onosproject/net/pi/model/PiMeterModel.java
new file mode 100644
index 0000000..237da05
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/pi/model/PiMeterModel.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.net.pi.model;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * Model of a meter in a protocol-independent pipeline.
+ */
+@Beta
+public interface PiMeterModel {
+
+    /**
+     * Meter rate unit.
+     */
+    enum Unit {
+        /**
+         * Measures rate of bytes.
+         */
+        BYTES,
+        /**
+         * Measures rate of packets.
+         */
+        PACKETS
+    }
+
+    /**
+     * Returns the ID of this meter.
+     *
+     * @return meter ID
+     */
+    PiMeterId id();
+
+    /**
+     * Returns the type of this meter.
+     *
+     * @return meter type
+     */
+    PiMeterType meterType();
+
+    /**
+     * Returns the unit of this meter.
+     *
+     * @return unit
+     */
+    Unit unit();
+
+    /**
+     * Returns the table model associated with this meter. Meaningful only if the meter type is {@link
+     * PiMeterType#DIRECT}.
+     *
+     * @return table model
+     */
+    PiTableId table();
+
+    /**
+     * Returns the number of cells of this meter. Meaningful only if the meter type is {@link PiMeterType#INDIRECT}.
+     *
+     * @return size
+     */
+    long size();
+}
diff --git a/core/api/src/main/java/org/onosproject/net/pi/model/PiHeaderFieldTypeModel.java b/core/api/src/main/java/org/onosproject/net/pi/model/PiMeterType.java
similarity index 69%
copy from core/api/src/main/java/org/onosproject/net/pi/model/PiHeaderFieldTypeModel.java
copy to core/api/src/main/java/org/onosproject/net/pi/model/PiMeterType.java
index 2f4c67b..cb2b57f 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/model/PiHeaderFieldTypeModel.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/model/PiMeterType.java
@@ -19,21 +19,19 @@
 import com.google.common.annotations.Beta;
 
 /**
- * Model of a header's field type in a protocol-independent pipeline.
+ * Types of meter in protocol-independent pipeline.
  */
 @Beta
-public interface PiHeaderFieldTypeModel {
-    /**
-     * Returns the name of this header type field.
-     *
-     * @return a string value
-     */
-    String name();
+public enum PiMeterType {
 
     /**
-     * Returns the bit width of this header type field.
-     *
-     * @return an integer value
+     * Identifies a meter associated to a match-action table, where meter cells are directly associated to table
+     * entries.
      */
-    int bitWidth();
+    DIRECT,
+
+    /**
+     * Identifies a meter not associated with any other resource.
+     */
+    INDIRECT
 }
diff --git a/core/api/src/main/java/org/onosproject/net/pi/model/PiPacketOperationModel.java b/core/api/src/main/java/org/onosproject/net/pi/model/PiPacketOperationModel.java
new file mode 100644
index 0000000..70659a6
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/pi/model/PiPacketOperationModel.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.net.pi.model;
+
+import com.google.common.annotations.Beta;
+
+import java.util.List;
+
+/**
+ * Model of a packet operation in a protocol-independent pipeline.
+ */
+@Beta
+public interface PiPacketOperationModel {
+
+    /**
+     * Returns the type of this packet operation.
+     *
+     * @return packet operation type
+     */
+    PiPacketOperationType type();
+
+    /**
+     * Returns a list of control metadata models for this packet operation. The metadata models are returned in the same
+     * order as they would appear on the control header that is prepended to the packet.
+     *
+     * @return list of packet operation metadata models
+     */
+    List<PiControlMetadataModel> metadatas();
+
+}
diff --git a/core/api/src/main/java/org/onosproject/net/pi/model/PiHeaderFieldTypeModel.java b/core/api/src/main/java/org/onosproject/net/pi/model/PiPacketOperationType.java
similarity index 60%
copy from core/api/src/main/java/org/onosproject/net/pi/model/PiHeaderFieldTypeModel.java
copy to core/api/src/main/java/org/onosproject/net/pi/model/PiPacketOperationType.java
index 2f4c67b..360c621 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/model/PiHeaderFieldTypeModel.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/model/PiPacketOperationType.java
@@ -19,21 +19,20 @@
 import com.google.common.annotations.Beta;
 
 /**
- * Model of a header's field type in a protocol-independent pipeline.
+ * Type of packet operation in a protocol-independent pipeline.
  */
 @Beta
-public interface PiHeaderFieldTypeModel {
-    /**
-     * Returns the name of this header type field.
-     *
-     * @return a string value
-     */
-    String name();
+public enum PiPacketOperationType {
 
     /**
-     * Returns the bit width of this header type field.
-     *
-     * @return an integer value
+     * Represents a packet-out, i.e. a packet generated by the control plane, optionally encapsulated with control
+     * information and sent through a network device port.
      */
-    int bitWidth();
+    PACKET_OUT,
+
+    /**
+     * Represents a packet-in, i.e. a packet originated at the data plane, optionally encapsulated with control
+     * information and sent to the controller for further inspection.
+     */
+    PACKET_IN,
 }
diff --git a/core/api/src/main/java/org/onosproject/net/pi/model/PiPipeconf.java b/core/api/src/main/java/org/onosproject/net/pi/model/PiPipeconf.java
index 0185e9b..9b353c8 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/model/PiPipeconf.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/model/PiPipeconf.java
@@ -24,8 +24,8 @@
 import java.util.Optional;
 
 /**
- * Configuration of a protocol-independent pipeline that includes a pipeline model, a collection of
- * pipeline-specific behaviours implementation, and extensions.
+ * Configuration of a protocol-independent pipeline that includes a pipeline model, a collection of pipeline-specific
+ * behaviour implementations, and extensions.
  */
 @Beta
 public interface PiPipeconf {
@@ -75,13 +75,13 @@
      * @param type extension type
      * @return extension input stream
      */
-    // FIXME: this is a sloppy way of handling extensions.
     Optional<InputStream> extension(ExtensionType type);
 
     /**
      * Type of extension of a protocol-independent pipeline configuration.
      */
     enum ExtensionType {
+
         /**
          * The P4Info as returned by the p4c compiler in text format.
          */
diff --git a/core/api/src/main/java/org/onosproject/net/pi/model/PiPipeconfId.java b/core/api/src/main/java/org/onosproject/net/pi/model/PiPipeconfId.java
index fd1b1bd..4f334e2 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/model/PiPipeconfId.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/model/PiPipeconfId.java
@@ -20,7 +20,7 @@
 import org.onlab.util.Identifier;
 
 /**
- * An identifier of a protocol-independent pipeline configuration.
+ * An identifier of a protocol-independent pipeline configuration, unique within the scope of ONOS.
  */
 @Beta
 public final class PiPipeconfId extends Identifier<String> {
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 738996f..1068026 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
@@ -17,105 +17,99 @@
 package org.onosproject.net.pi.model;
 
 import com.google.common.annotations.Beta;
-import org.onosproject.net.DeviceId;
 import org.onosproject.net.driver.HandlerBehaviour;
 import org.onosproject.net.flow.TrafficTreatment;
 import org.onosproject.net.flow.criteria.Criterion;
 import org.onosproject.net.packet.InboundPacket;
 import org.onosproject.net.packet.OutboundPacket;
 import org.onosproject.net.pi.runtime.PiAction;
-import org.onosproject.net.pi.runtime.PiCounterId;
-import org.onosproject.net.pi.runtime.PiHeaderFieldId;
 import org.onosproject.net.pi.runtime.PiPacketOperation;
-import org.onosproject.net.pi.runtime.PiTableId;
 
 import java.util.Collection;
 import java.util.Optional;
 
 /**
- * An interpreter of a protocol-independent pipeline model.
+ * An interpreter of a PI pipeline model.
  */
 @Beta
 public interface PiPipelineInterpreter extends HandlerBehaviour {
 
     /**
-     * Returns the protocol-independent header field identifier that is equivalent to the given criterion type, if
-     * present. If not present, it means that the given criterion type is not supported by this interpreter.
+     * Returns a PI match field ID that is equivalent to the given criterion type, if present. If not present, it means
+     * that the given criterion type is not supported by this interpreter.
      *
      * @param type criterion type
-     * @return optional header field identifier
+     * @return optional match field ID
      */
-    Optional<PiHeaderFieldId> mapCriterionType(Criterion.Type type);
+    Optional<PiMatchFieldId> mapCriterionType(Criterion.Type type);
 
     /**
-     * Returns the criterion type that is equivalent to the given protocol-independent header field identifier, if
-     * present. If not present, it means that the given field identifier is not supported by this interpreter.
+     * Returns the criterion type that is equivalent to the given PI match field ID, if present. If not present, it
+     * means that the given match field is not supported by this interpreter.
      *
-     * @param headerFieldId header field identifier
+     * @param fieldId match field ID
      * @return optional criterion type
      */
-    Optional<Criterion.Type> mapPiHeaderFieldId(PiHeaderFieldId headerFieldId);
+    Optional<Criterion.Type> mapPiMatchFieldId(PiMatchFieldId fieldId);
 
     /**
-     * Returns a protocol-independent table id equivalent to the given numeric table id (as in {@link
-     * org.onosproject.net.flow.FlowRule#tableId()}). If not present, it means that the given numeric table id cannot be
+     * Returns a PI table ID equivalent to the given numeric table ID (as in {@link
+     * org.onosproject.net.flow.FlowRule#tableId()}). If not present, it means that the given integer table ID cannot be
      * mapped to any table of the pipeline model.
      *
-     * @param flowRuleTableId a numeric table id
-     * @return a protocol-independent table id
+     * @param flowRuleTableId a numeric table ID
+     * @return PI table ID
      */
     Optional<PiTableId> mapFlowRuleTableId(int flowRuleTableId);
 
     /**
-     * Returns a numeric table id (as in {@link org.onosproject.net.flow.FlowRule#tableId()}) equivalent to the given
-     * protocol-independent table id. If not present, it means that the given protocol-independent table id refers to a
-     * table that does not exist, or that cannot be used for flow rule operations.
+     * 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.
      *
-     * @param piTableId protocol-independent table id
-     * @return numeric table id
+     * @param piTableId PI table ID
+     * @return numeric table ID
      */
     Optional<Integer> mapPiTableId(PiTableId piTableId);
 
     /**
-     * Returns an action of a protocol-independent pipeline that is functionally equivalent to the given ONOS traffic
-     * treatment for the given table.
+     * Returns an action of a PI pipeline that is functionally equivalent to the given traffic treatment for the given
+     * table.
      *
-     * @param treatment a ONOS traffic treatment
-     * @param piTableId PI table identifier
-     * @return an action object
-     * @throws PiInterpreterException if the treatment cannot be mapped to any table action
+     * @param treatment traffic treatment
+     * @param piTableId PI table ID
+     * @return action object
+     * @throws PiInterpreterException if the treatment cannot be mapped to any PI action
      */
     PiAction mapTreatment(TrafficTreatment treatment, PiTableId piTableId)
             throws PiInterpreterException;
 
     /**
-     * Returns a protocol-independent direct counter identifier 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, if present. If not present, it means that the given table
+     * does not support direct counters.
      *
-     * @param piTableId table identifier
-     * @return optional direct counter identifier
+     * @param piTableId table ID
+     * @return optional direct counter ID
      */
     Optional<PiCounterId> mapTableCounter(PiTableId piTableId);
 
     /**
-     * Returns a collection of packet operations equivalent to the given OutboundPacket.
+     * Returns a collection of PI packet operations equivalent to the given outbound packet instance.
      *
-     * @param packet a ONOS outbound packet
-     * @return a collection of packet operations
-     * @throws PiInterpreterException if the packet treatments cannot be mapped to any metadata
+     * @param packet outbound packet
+     * @return collection of PI packet operations
+     * @throws PiInterpreterException if the packet treatments cannot be executed by this pipeline
      */
     Collection<PiPacketOperation> mapOutboundPacket(OutboundPacket packet)
             throws PiInterpreterException;
 
     /**
-     * Returns a InboundPacket equivalent to the given packet operation.
+     * Returns an inbound packet equivalent to the given PI packet operation.
      *
-     * @param deviceId          the device that originated the packet-in
-     * @param packetInOperation the packet operation
-     * @return an ONOS inbound packet
-     * @throws PiInterpreterException if the port can't be extracted from the packet metadata
+     * @param packetOperation packet operation
+     * @return inbound packet
+     * @throws PiInterpreterException if the packet operation cannot be mapped to an inbound packet
      */
-    InboundPacket mapInboundPacket(DeviceId deviceId, PiPacketOperation packetInOperation)
+    InboundPacket mapInboundPacket(PiPacketOperation packetOperation)
             throws PiInterpreterException;
 
     /**
@@ -127,4 +121,4 @@
             super(message);
         }
     }
-}
\ No newline at end of file
+}
diff --git a/core/api/src/main/java/org/onosproject/net/pi/model/PiPipelineModel.java b/core/api/src/main/java/org/onosproject/net/pi/model/PiPipelineModel.java
index 123388a..c1840d9 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/model/PiPipelineModel.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/model/PiPipelineModel.java
@@ -28,57 +28,12 @@
 public interface PiPipelineModel {
 
     /**
-     * Returns the header type associated with the given name, if present.
+     * Returns the table model associated with the given ID, if present.
      *
-     * @param name string value
-     * @return optional header type model
-     */
-    Optional<PiHeaderTypeModel> headerType(String name);
-
-    /**
-     * Returns the collection of all header types defined by this pipeline model.
-     *
-     * @return collection of header types
-     */
-    Collection<PiHeaderTypeModel> headerTypes();
-
-    /**
-     * Returns the header instance associated with the given name, if present.
-     *
-     * @param name string value
-     * @return optional header instance model
-     */
-    Optional<PiHeaderModel> header(String name);
-
-    /**
-     * Returns the collection of all header instance models defined by this pipeline model.
-     *
-     * @return collection of header types
-     */
-    Collection<PiHeaderModel> headers();
-
-    /**
-     * Returns the action model associated with the given name, if present.
-     *
-     * @param name string value
-     * @return optional action model
-     */
-    Optional<PiActionModel> action(String name);
-
-    /**
-     * Returns the collection of all action models defined by this pipeline model.
-     *
-     * @return collection of actions
-     */
-    Collection<PiActionModel> actions();
-
-    /**
-     * Returns the table model associated with the given name, if present.
-     *
-     * @param name string value
+     * @param tableId table ID
      * @return optional table model
      */
-    Optional<PiTableModel> table(String name);
+    Optional<PiTableModel> table(PiTableId tableId);
 
     /**
      * Returns the collection of all table models defined by this pipeline model.
@@ -86,4 +41,57 @@
      * @return collection of actions
      */
     Collection<PiTableModel> tables();
+
+    /**
+     * Returns the counter model associated with the given ID, id present.
+     *
+     * @param counterId counter ID
+     * @return optional counter model
+     */
+    Optional<PiCounterModel> counter(PiCounterId counterId);
+
+    /**
+     * Returns all counter models defined by this pipeline model.
+     *
+     * @return collection of counter models
+     */
+    Collection<PiCounterModel> counters();
+
+    /**
+     * Returns the meter model associated with the given ID, id present.
+     *
+     * @param meterId meter ID
+     * @return optional meter model
+     */
+    Optional<PiMeterModel> meter(PiMeterId meterId);
+
+    /**
+     * Returns all meter models defined by this pipeline model.
+     *
+     * @return collection of meter models
+     */
+    Collection<PiMeterModel> meters();
+
+    /**
+     * Returns the action profile model associated with the given ID, id present.
+     *
+     * @param actionProfileId action profile ID
+     * @return optional action profile model
+     */
+    Optional<PiActionProfileModel> actionProfiles(PiActionProfileId actionProfileId);
+
+    /**
+     * Returns all action profile models defined by this pipeline model.
+     *
+     * @return collection of action profile models
+     */
+    Collection<PiActionProfileModel> actionProfiles();
+
+    /**
+     * Returns the packet operation model of the given type, if present.
+     *
+     * @param type packet operation type
+     * @return packet operation model
+     */
+    Optional<PiPacketOperationModel> packetOperationModel(PiPacketOperationType type);
 }
diff --git a/core/api/src/main/java/org/onosproject/net/pi/model/PiTableId.java b/core/api/src/main/java/org/onosproject/net/pi/model/PiTableId.java
new file mode 100644
index 0000000..2e799a9
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/pi/model/PiTableId.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.net.pi.model;
+
+import com.google.common.annotations.Beta;
+import org.onlab.util.Identifier;
+import org.onosproject.net.flow.TableId;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Identifier of a table in a protocol-independent pipeline, unique within the scope of a pipeline model.
+ */
+@Beta
+public final class PiTableId extends Identifier<String> implements TableId {
+
+    private PiTableId(String name) {
+        super(name);
+    }
+
+    /**
+     * Returns an identifier for the given table name.
+     *
+     * @param name table name
+     * @return table ID
+     */
+    public static PiTableId of(String name) {
+        checkNotNull(name);
+        checkArgument(!name.isEmpty(), "Name can't be empty");
+        return new PiTableId(name);
+    }
+
+    @Override
+    public Type type() {
+        return Type.PIPELINE_INDEPENDENT;
+    }
+}
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 038dadd..e2461a8 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
@@ -28,25 +28,47 @@
 public interface PiTableModel {
 
     /**
-     * Returns the name of this table.
+     * Returns the ID of this table.
      *
      * @return a string value
      */
-    String name();
+    PiTableId id();
+
+    /**
+     * Returns the type of this table.
+     *
+     * @return table type
+     */
+    PiTableType tableType();
+
+    /**
+     * Returns the model of the action profile that implements this table. Meaningful if this table is of type {@link
+     * PiTableType#INDIRECT}, otherwise returns null.
+     *
+     * @return action profile ID
+     */
+    PiActionProfileModel actionProfile();
 
     /**
      * Returns the maximum number of entries supported by this table.
      *
      * @return an integer value
      */
-    int maxSize();
+    long maxSize();
 
     /**
-     * Returns true if this table has counters, false otherwise.
+     * Returns a collection of direct counters associated to this table.
      *
-     * @return a boolean value
+     * @return collection of direct counters
      */
-    boolean hasCounters();
+    Collection<PiCounterModel> counters();
+
+    /**
+     * Returns a collection of direct meters associated to this table.
+     *
+     * @return collection of direct meters
+     */
+    Collection<PiMeterModel> meters();
 
     /**
      * Returns true if this table supports aging, false otherwise.
@@ -60,7 +82,7 @@
      *
      * @return a collection of match field models
      */
-    Collection<PiTableMatchFieldModel> matchFields();
+    Collection<PiMatchFieldModel> matchFields();
 
     /**
      * Returns the actions supported by this table.
@@ -70,12 +92,35 @@
     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.
+     * Returns the model of the default action associated with this table, if any.
      *
-     * @param name string value
+     * @return optional default action model
+     */
+    Optional<PiActionModel> defaultAction();
+
+    /**
+     * Returns true if the default action has mutable parameters that can be changed at runtime, false otherwise.
+     *
+     * @return true if the default action has mutable parameters, false otherwise
+     */
+    boolean hasDefaultMutableParams();
+
+    /**
+     * Returns the action model associated with the given ID, if present. If not present, it means that this table does
+     * not support such an action.
+     *
+     * @param actionId action ID
      * @return optional action model
      */
-    Optional<PiActionModel> action(String name);
+    Optional<PiActionModel> action(PiActionId actionId);
+
+    /**
+     * Returns the match field model associated with the given ID, if present. If not present, it means that this table
+     * does not support such a match field.
+     *
+     * @param matchFieldId match field ID
+     * @return optional match field model
+     */
+    Optional<PiMatchFieldModel> matchField(PiMatchFieldId matchFieldId);
 
 }
diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiCounterType.java b/core/api/src/main/java/org/onosproject/net/pi/model/PiTableType.java
similarity index 68%
copy from core/api/src/main/java/org/onosproject/net/pi/runtime/PiCounterType.java
copy to core/api/src/main/java/org/onosproject/net/pi/model/PiTableType.java
index b4a709a..9fa31ed 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiCounterType.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/model/PiTableType.java
@@ -14,19 +14,20 @@
  * limitations under the License.
  */
 
-package org.onosproject.net.pi.runtime;
+package org.onosproject.net.pi.model;
 
 /**
- * Type of counter in a protocol-independent pipeline.
+ * Types of match+action table in a protocol-independent pipeline.
  */
-public enum PiCounterType {
+public enum PiTableType {
+
     /**
-     * Identifies a counter associated to a match-action table, where cells are directly associated to table entries.
+     * Regular match+action table.
      */
     DIRECT,
 
     /**
-     * Identifies a counter not associated with any other resource.
+     * Implementation-based table, e.g. ECMP table where the action executed depends on a selection function.
      */
     INDIRECT
 }
diff --git a/core/api/src/main/java/org/onosproject/net/pi/model/package-info.java b/core/api/src/main/java/org/onosproject/net/pi/model/package-info.java
index 5d9a05b..a218d7c 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/model/package-info.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/model/package-info.java
@@ -15,6 +15,6 @@
  */
 
 /**
- * Base abstractions of a protocol-independent packet forwarding pipeline.
+ * Base abstractions of a protocol-independent packet processing pipeline.
  */
-package org.onosproject.net.pi.model;
\ No newline at end of file
+package org.onosproject.net.pi.model;
diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiAction.java b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiAction.java
index 6300660..bba3338 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiAction.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiAction.java
@@ -21,6 +21,8 @@
 import com.google.common.base.Objects;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Maps;
+import org.onosproject.net.pi.model.PiActionId;
+import org.onosproject.net.pi.model.PiActionParamId;
 
 import java.util.Collection;
 import java.util.Map;
@@ -29,8 +31,7 @@
 import static com.google.common.base.Preconditions.checkNotNull;
 
 /**
- * Instance of an action, and its runtime parameters, of a table entry in a protocol-independent
- * pipeline.
+ * Instance of an action, and its runtime parameters, of a table entry in a protocol-independent pipeline.
  */
 @Beta
 public final class PiAction implements PiTableAction {
@@ -64,8 +65,8 @@
     }
 
     /**
-     * Returns all runtime parameters of this action.
-     * Return an empty collection if the action doesn't take any runtime parameters.
+     * Returns all runtime parameters of this action. Return an empty collection if the action doesn't take any runtime
+     * parameters.
      *
      * @return list of byte sequences
      */
diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionGroup.java b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionGroup.java
index 1de4d61..1d9a94b 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionGroup.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionGroup.java
@@ -21,6 +21,8 @@
 import com.google.common.base.Objects;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Maps;
+import org.onosproject.net.pi.model.PiActionGroupType;
+import org.onosproject.net.pi.model.PiActionProfileId;
 
 import java.util.Collection;
 import java.util.Map;
@@ -29,27 +31,17 @@
 import static com.google.common.base.Preconditions.checkNotNull;
 
 /**
- * Action group of a protocol-independent pipeline.
+ * Instance of an action group of a protocol-independent pipeline.
  */
 @Beta
 public final class PiActionGroup {
 
-    /**
-     * Type of action group.
-     */
-    public enum Type {
-        /**
-         * Load-balancing among different members in a group.
-         */
-        SELECT
-    }
-
     private final PiActionGroupId id;
-    private final Type type;
+    private final PiActionGroupType type;
     private final ImmutableSet<PiActionGroupMember> members;
     private final PiActionProfileId piActionProfileId;
 
-    private PiActionGroup(PiActionGroupId id, Type type,
+    private PiActionGroup(PiActionGroupId id, PiActionGroupType type,
                           ImmutableSet<PiActionGroupMember> members,
                           PiActionProfileId piActionProfileId) {
         this.id = id;
@@ -72,7 +64,7 @@
      *
      * @return action group type
      */
-    public Type type() {
+    public PiActionGroupType type() {
         return type;
     }
 
@@ -139,7 +131,7 @@
     public static final class Builder {
 
         private PiActionGroupId id;
-        private Type type;
+        private PiActionGroupType type;
         private Map<PiActionGroupMemberId, PiActionGroupMember> members = Maps.newHashMap();
         private PiActionProfileId piActionProfileId;
 
@@ -164,7 +156,7 @@
          * @param type action group type
          * @return this
          */
-        public Builder withType(Type type) {
+        public Builder withType(PiActionGroupType type) {
             this.type = type;
             return this;
         }
diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionGroupId.java b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionGroupId.java
index 380a4a1..b604237 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionGroupId.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionGroupId.java
@@ -20,7 +20,7 @@
 import org.onlab.util.Identifier;
 
 /**
- * Identifier of an action group in a protocol-independent pipeline.
+ * Identifier of an action group in a protocol-independent pipeline, unique within the scope of an action profile.
  */
 @Beta
 public final class PiActionGroupId extends Identifier<Integer> implements PiTableAction {
diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionGroupMember.java b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionGroupMember.java
index b5bd542..2905eb9 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionGroupMember.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionGroupMember.java
@@ -23,7 +23,7 @@
 import static com.google.common.base.Preconditions.checkNotNull;
 
 /**
- * Member of an action group in a protocol-independent pipeline.
+ * Instance of a member of an action group in a protocol-independent pipeline.
  */
 @Beta
 public final class PiActionGroupMember {
@@ -57,8 +57,8 @@
     }
 
     /**
-     * Returns the weight associated to this member. Valid if the action group is of type {@link
-     * PiActionGroup.Type#SELECT}.
+     * Returns the weight associated to this member. Meaningful if the action group of this member is of type {@link
+     * org.onosproject.net.pi.model.PiActionGroupType#SELECT}.
      *
      * @return weight
      */
@@ -139,7 +139,8 @@
         }
 
         /**
-         * Sets the weight of this member. Valid if the action group is of type {@link PiActionGroup.Type#SELECT}.
+         * Sets the weight of this member. Meaningful only if the action group is of type {@link
+         * org.onosproject.net.pi.model.PiActionGroupType#SELECT}.
          * <p>
          * Default value is 0.
          *
diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionGroupMemberId.java b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionGroupMemberId.java
index 98b9d31..3b233a0 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionGroupMemberId.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionGroupMemberId.java
@@ -20,7 +20,8 @@
 import org.onlab.util.Identifier;
 
 /**
- * Identifier of a member of an action group in a protocol-independent pipeline.
+ * Identifier of a member of an action group in a protocol-independent pipeline, unique withing the scope on an action
+ * profile.
  */
 @Beta
 public final class PiActionGroupMemberId extends Identifier<Integer> implements PiTableAction {
diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionParam.java b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionParam.java
index 2e4ced3..4498109 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionParam.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionParam.java
@@ -19,12 +19,13 @@
 import com.google.common.annotations.Beta;
 import com.google.common.base.Objects;
 import org.onlab.util.ImmutableByteSequence;
+import org.onosproject.net.pi.model.PiActionParamId;
 
 import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Preconditions.checkNotNull;
 
 /**
- * Runtime parameter of an action in a match+action table of a protocol-independent pipeline.
+ * Instance of an action runtime parameter in a match+action table of a protocol-independent pipeline.
  */
 @Beta
 public final class PiActionParam {
diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiPacketMetadata.java b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiControlMetadata.java
similarity index 70%
rename from core/api/src/main/java/org/onosproject/net/pi/runtime/PiPacketMetadata.java
rename to core/api/src/main/java/org/onosproject/net/pi/runtime/PiControlMetadata.java
index 118195b..3caa71c 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiPacketMetadata.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiControlMetadata.java
@@ -19,35 +19,36 @@
 import com.google.common.annotations.Beta;
 import com.google.common.base.Objects;
 import org.onlab.util.ImmutableByteSequence;
+import org.onosproject.net.pi.model.PiControlMetadataId;
 
 import static com.google.common.base.Preconditions.checkNotNull;
 
 /**
- * Instance of a metadata for a packet I/O operation, with id and value for a protocol-independent pipeline.
+ * Instance of a control metadata for a protocol-independent pipeline.
  */
 @Beta
-public final class PiPacketMetadata {
+public final class PiControlMetadata {
 
-    private final PiPacketMetadataId id;
+    private final PiControlMetadataId id;
     private final ImmutableByteSequence value;
 
     /**
-     * Creates a new packet metadata instance for the given identifier and value.
+     * Creates a new control metadata instance for the given identifier and value.
      *
-     * @param id    packet metadata identifier
+     * @param id    control metadata identifier
      * @param value value for this metadata
      */
-    private PiPacketMetadata(PiPacketMetadataId id, ImmutableByteSequence value) {
+    private PiControlMetadata(PiControlMetadataId id, ImmutableByteSequence value) {
         this.id = id;
         this.value = value;
     }
 
     /**
-     * Return the identifier of this packet metadata.
+     * Return the identifier of this control metadata.
      *
-     * @return packet metadata identifier
+     * @return control metadata identifier
      */
-    public PiPacketMetadataId id() {
+    public PiControlMetadataId id() {
         return id;
     }
 
@@ -68,7 +69,7 @@
         if (o == null || getClass() != o.getClass()) {
             return false;
         }
-        PiPacketMetadata piPacket = (PiPacketMetadata) o;
+        PiControlMetadata piPacket = (PiControlMetadata) o;
         return Objects.equal(id, piPacket.id()) &&
                 Objects.equal(value, piPacket.value());
     }
@@ -84,7 +85,7 @@
     }
 
     /**
-     * Returns a packet metadata builder.
+     * Returns a control metadata builder.
      *
      * @return a new builder
      */
@@ -93,11 +94,11 @@
     }
 
     /**
-     * Builder of protocol-independent packet metadatas.
+     * Builder of protocol-independent control metadatas.
      */
     public static final class Builder {
 
-        private PiPacketMetadataId id;
+        private PiControlMetadataId id;
         private ImmutableByteSequence value;
 
         private Builder() {
@@ -105,12 +106,12 @@
         }
 
         /**
-         * Sets the identifier of this packet metadata.
+         * Sets the identifier of this control metadata.
          *
-         * @param id packet metadata identifier
+         * @param id control metadata identifier
          * @return this
          */
-        public Builder withId(PiPacketMetadataId id) {
+        public Builder withId(PiControlMetadataId id) {
             this.id = id;
             return this;
         }
@@ -127,14 +128,14 @@
         }
 
         /**
-         * Returns a new packet metadata instance.
+         * Returns a new control metadata instance.
          *
-         * @return packet metadata
+         * @return control metadata
          */
-        public PiPacketMetadata build() {
+        public PiControlMetadata build() {
             checkNotNull(id);
             checkNotNull(value);
-            return new PiPacketMetadata(id, value);
+            return new PiControlMetadata(id, value);
         }
     }
 }
diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiCounterCellId.java b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiCounterCellId.java
index cd88d2a..da8a882 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiCounterCellId.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiCounterCellId.java
@@ -16,22 +16,120 @@
 
 package org.onosproject.net.pi.runtime;
 
+import com.google.common.annotations.Beta;
+import com.google.common.base.Objects;
+import org.onosproject.net.pi.model.PiCounterId;
+import org.onosproject.net.pi.model.PiCounterType;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
 /**
  * Identifier of a counter cell in a protocol-independent pipeline.
  */
-public interface PiCounterCellId {
+@Beta
+public final class PiCounterCellId {
+
+    private final PiCounterId counterId;
+    private final PiCounterType counterType;
+    private final long index;
+    private final PiTableEntry tableEntry;
+
+    private PiCounterCellId(PiCounterId counterId, PiCounterType counterType, long index,
+                            PiTableEntry tableEntry) {
+        this.counterId = counterId;
+        this.counterType = counterType;
+        this.index = index;
+        this.tableEntry = tableEntry;
+    }
 
     /**
      * Returns the identifier of the counter instance where this cell is contained.
      *
      * @return counter identifier
      */
-    PiCounterId counterId();
+    public PiCounterId counterId() {
+        return counterId;
+    }
 
     /**
-     * Returns the type of counter identified.
+     * Returns the type of the counter identified.
      *
      * @return counter type
      */
-    PiCounterType type();
+    public PiCounterType counterType() {
+        return counterType;
+    }
+
+    /**
+     * Returns the counter index to which this cell ID is associated. Meaningful only if the counter is of type {@link
+     * PiCounterType#INDIRECT}.
+     *
+     * @return counter index
+     */
+    public long index() {
+        return index;
+    }
+
+    /**
+     * Returns the table entry to which this cell ID is associated. Meaningful only if the counter is of type {@link
+     * PiCounterType#DIRECT}, otherwise returns null.
+     *
+     * @return PI table entry or null
+     */
+    public PiTableEntry tableEntry() {
+        return tableEntry;
+    }
+
+    /**
+     * Return a direct counter cell ID for the given counter ID and table entry.
+     *
+     * @param counterId  counter ID
+     * @param tableEntry table entry
+     * @return counter cell ID
+     */
+    public static PiCounterCellId ofDirect(PiCounterId counterId, PiTableEntry tableEntry) {
+        checkNotNull(counterId);
+        checkNotNull(tableEntry);
+        return new PiCounterCellId(counterId, PiCounterType.DIRECT, -1, tableEntry);
+    }
+
+    /**
+     * Return an indirect counter cell ID for the given counter ID and index.
+     *
+     * @param counterId counter ID
+     * @param index     index
+     * @return counter cell ID
+     */
+    public static PiCounterCellId ofIndirect(PiCounterId counterId, long index) {
+        checkNotNull(counterId);
+        checkArgument(index >= 0, "Index must be a positive number");
+        return new PiCounterCellId(counterId, PiCounterType.INDIRECT, index, null);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null || getClass() != obj.getClass()) {
+            return false;
+        }
+        final PiCounterCellId other = (PiCounterCellId) obj;
+        return Objects.equal(this.counterId, other.counterId)
+                && Objects.equal(this.counterType, other.counterType)
+                && Objects.equal(this.index, other.index)
+                && Objects.equal(this.tableEntry, other.tableEntry);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hashCode(counterId, counterType, index, tableEntry);
+    }
+
+    @Override
+    public String toString() {
+        return counterId.toString() + ':'
+                + (counterType == PiCounterType.DIRECT ? tableEntry.toString() : String.valueOf(index));
+    }
 }
diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiCounterId.java b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiCounterId.java
deleted file mode 100644
index 015d86b..0000000
--- a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiCounterId.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.net.pi.runtime;
-
-import com.google.common.annotations.Beta;
-import com.google.common.base.Objects;
-import org.onlab.util.Identifier;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Identifier of a counter of a protocol-independent pipeline.
- */
-@Beta
-public final class PiCounterId extends Identifier<String> {
-
-    private final String scope;
-    private final String name;
-    private final PiCounterType type;
-
-    private PiCounterId(String scope, String name, PiCounterType type) {
-        super((!scope.isEmpty() ? scope + "." : "") + name);
-        this.scope = scope;
-        this.name = name;
-        this.type = type;
-    }
-
-    /**
-     * Returns a counter identifier for the given name and type.
-     *
-     * @param name counter name
-     * @param type counter type
-     * @return counter identifier
-     */
-    public static PiCounterId of(String name, PiCounterType type) {
-        checkNotNull(name);
-        checkNotNull(type);
-        checkArgument(!name.isEmpty(), "Name can't be empty");
-        return new PiCounterId("", name, type);
-    }
-
-    /**
-     * Returns a counter identifier for the given scope, name, and type.
-     *
-     * @param scope counter scope
-     * @param name  counter name
-     * @param type  counter type
-     * @return counter identifier
-     */
-    public static PiCounterId of(String scope, String name, PiCounterType type) {
-        checkNotNull(scope);
-        checkNotNull(name);
-        checkNotNull(type);
-        checkArgument(!scope.isEmpty(), "Scope can't be empty");
-        checkArgument(!name.isEmpty(), "Name can't be empty");
-        return new PiCounterId(scope, name, type);
-    }
-
-    /**
-     * Returns the scope of the counter.
-     *
-     * @return counter scope
-     */
-    public String scope() {
-        return this.scope;
-    }
-
-    /**
-     * Returns the name of the counter.
-     *
-     * @return counter name
-     */
-    public String name() {
-        return this.name;
-    }
-
-    /**
-     * Returns the type of the counter.
-     *
-     * @return counter type
-     */
-    public PiCounterType type() {
-        return this.type;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) {
-            return true;
-        }
-        if (!(o instanceof PiCounterId)) {
-            return false;
-        }
-        PiCounterId that = (PiCounterId) o;
-        return Objects.equal(id(), that.id()) &&
-                type == that.type;
-    }
-
-    @Override
-    public int hashCode() {
-        return Objects.hashCode(id(), type);
-    }
-}
diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiDirectCounterCellId.java b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiDirectCounterCellId.java
deleted file mode 100644
index 26ae363..0000000
--- a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiDirectCounterCellId.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.net.pi.runtime;
-
-import com.google.common.annotations.Beta;
-import com.google.common.base.Objects;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static java.lang.String.format;
-import static org.onosproject.net.pi.runtime.PiCounterType.DIRECT;
-
-/**
- * Identifier of a direct counter cell of a protocol-independent pipeline.
- */
-@Beta
-public final class PiDirectCounterCellId implements PiCounterCellId {
-
-    private final PiCounterId counterId;
-    private final PiTableEntry tableEntry;
-
-    private PiDirectCounterCellId(PiCounterId counterId, PiTableEntry tableEntry) {
-        this.counterId = counterId;
-        this.tableEntry = tableEntry;
-    }
-
-    /**
-     * Returns a direct counter cell identifier for the given counter identifier and table entry.
-     *
-     * @param counterId  counter identifier
-     * @param tableEntry table entry
-     * @return direct counter cell identifier
-     */
-    public static PiDirectCounterCellId of(PiCounterId counterId, PiTableEntry tableEntry) {
-        checkNotNull(counterId);
-        checkNotNull(tableEntry);
-        checkArgument(counterId.type() == DIRECT, "Counter ID must be of type DIRECT");
-        return new PiDirectCounterCellId(counterId, tableEntry);
-    }
-
-    /**
-     * Returns the table entry associated with this cell identifier.
-     *
-     * @return cell table entry
-     */
-    public PiTableEntry tableEntry() {
-        return tableEntry;
-    }
-
-    @Override
-    public PiCounterId counterId() {
-        return counterId;
-    }
-
-    @Override
-    public PiCounterType type() {
-        return DIRECT;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) {
-            return true;
-        }
-        if (!(o instanceof PiDirectCounterCellId)) {
-            return false;
-        }
-        PiDirectCounterCellId that = (PiDirectCounterCellId) o;
-        return Objects.equal(counterId, that.counterId) &&
-                Objects.equal(tableEntry, that.tableEntry);
-    }
-
-    @Override
-    public int hashCode() {
-        return Objects.hashCode(counterId, tableEntry);
-    }
-
-    @Override
-    public String toString() {
-        return format("%s[{%s}]", counterId, tableEntry);
-    }
-}
diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiExactFieldMatch.java b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiExactFieldMatch.java
index 946f6c1..d81da99 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiExactFieldMatch.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiExactFieldMatch.java
@@ -19,13 +19,14 @@
 import com.google.common.annotations.Beta;
 import com.google.common.base.Objects;
 import org.onlab.util.ImmutableByteSequence;
+import org.onosproject.net.pi.model.PiMatchFieldId;
 import org.onosproject.net.pi.model.PiMatchType;
 
 import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Preconditions.checkNotNull;
 
 /**
- * Exact field match in a protocol-independent pipeline.
+ * Instance of an exact field match in a protocol-independent pipeline.
  */
 @Beta
 public final class PiExactFieldMatch extends PiFieldMatch {
@@ -38,7 +39,7 @@
      * @param fieldId field identifier
      * @param value   value
      */
-    public PiExactFieldMatch(PiHeaderFieldId fieldId, ImmutableByteSequence value) {
+    public PiExactFieldMatch(PiMatchFieldId fieldId, ImmutableByteSequence value) {
         super(fieldId);
         this.value = checkNotNull(value);
         checkArgument(value.size() > 0, "Value can't have size 0");
diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiFieldMatch.java b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiFieldMatch.java
index 8df0452..aa34f22 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiFieldMatch.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiFieldMatch.java
@@ -16,23 +16,24 @@
 
 package org.onosproject.net.pi.runtime;
 
+import org.onosproject.net.pi.model.PiMatchFieldId;
 import org.onosproject.net.pi.model.PiMatchType;
 
 import static com.google.common.base.Preconditions.checkNotNull;
 
 /**
- * Header's field match in a protocol-independent pipeline.
+ * Instance of a field match in a protocol-independent pipeline.
  */
 public abstract class PiFieldMatch {
 
-    private final PiHeaderFieldId fieldId;
+    private final PiMatchFieldId fieldId;
 
     /**
      * Creates a new field match for the given header field identifier.
      *
      * @param fieldId field identifier.
      */
-    PiFieldMatch(PiHeaderFieldId fieldId) {
+    PiFieldMatch(PiMatchFieldId fieldId) {
         this.fieldId = checkNotNull(fieldId);
     }
 
@@ -42,7 +43,7 @@
      *
      * @return a header field ID value
      */
-    public final PiHeaderFieldId fieldId() {
+    public final PiMatchFieldId fieldId() {
         return fieldId;
     }
 
diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiGroupKey.java b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiGroupKey.java
index 598f3e7..14fec81 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiGroupKey.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiGroupKey.java
@@ -18,6 +18,8 @@
 
 import com.google.common.base.Objects;
 import org.onosproject.net.group.GroupKey;
+import org.onosproject.net.pi.model.PiActionProfileId;
+import org.onosproject.net.pi.model.PiTableId;
 
 import static com.google.common.base.Preconditions.checkNotNull;
 
diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiHeaderFieldId.java b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiHeaderFieldId.java
deleted file mode 100644
index 99f7e75..0000000
--- a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiHeaderFieldId.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.net.pi.runtime;
-
-import org.onlab.util.Identifier;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Identifier of a packet's header field.
- */
-public final class PiHeaderFieldId extends Identifier<String> {
-
-    // FIXME: this abstraction is brittle and we should drop any string-composition logic.
-    // e.g. in P4_14 there is no scope for match fields.
-    // In light of ONOS-7066, the best solution seems to have IDs defined as arbitrary
-    // strings equal to the entity names defined in the P4Info.
-    private final String headerName;
-    private final String fieldName;
-    private final int index;
-
-    private PiHeaderFieldId(String headerName, String fieldName, int index) {
-        super(headerName +
-                      (index > 0 ? "[" + String.valueOf(index) + "]" : "") +
-                      "." + fieldName);
-        this.headerName = headerName;
-        this.fieldName = fieldName;
-        this.index = index;
-    }
-
-    /**
-     * Returns an header field identifier for the given header name, field name and index.
-     * <p>
-     * Index represents the position of this header in the packet w.r.t. to other headers of the
-     * same type. Index 0 points to the first instance of the header, 1 the second one, etc. Helpful
-     * when dealing with stacked headers, e.g. to match on the second MPLS label.
-     *
-     * @param headerName header name
-     * @param fieldName  field name
-     * @param index      index
-     * @return header field identifier
-     */
-    public static PiHeaderFieldId of(String headerName, String fieldName, int index) {
-        checkNotNull(headerName);
-        checkNotNull(fieldName);
-        checkArgument(!headerName.isEmpty(), "Header name can't be empty");
-        checkArgument(!fieldName.isEmpty(), "Field name can't be empty");
-        checkArgument(index >= 0, "Index must be a positive integer");
-        return new PiHeaderFieldId(headerName, fieldName, index);
-    }
-
-    /**
-     * Returns an header field identifier for the given header name and field name.
-     * Index is set to default value 0.
-     *
-     * @param headerName header name
-     * @param fieldName  field name
-     * @return header field identifier
-     */
-    public static PiHeaderFieldId of(String headerName, String fieldName) {
-        return of(headerName, fieldName, 0);
-    }
-
-    /**
-     * Returns the name of the header.
-     *
-     * @return a string value
-     */
-    public String headerName() {
-        return headerName;
-    }
-
-    /**
-     * Returns the name of the field.
-     *
-     * @return a string value
-     */
-    public String fieldName() {
-        return fieldName;
-    }
-
-    /**
-     * Returns the index of this header.
-     *
-     * @return an integer value.
-     */
-    public int index() {
-        return index;
-    }
-}
diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiIndirectCounterCellId.java b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiIndirectCounterCellId.java
deleted file mode 100644
index 6f3f73a..0000000
--- a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiIndirectCounterCellId.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.net.pi.runtime;
-
-import com.google.common.annotations.Beta;
-import org.onlab.util.Identifier;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.onosproject.net.pi.runtime.PiCounterType.INDIRECT;
-
-/**
- * Identifier of an indirect counter cell in a protocol-independent pipeline.
- */
-@Beta
-public final class PiIndirectCounterCellId extends Identifier<String> implements PiCounterCellId {
-
-    private final PiCounterId counterId;
-    private final long index;
-
-    private PiIndirectCounterCellId(PiCounterId counterId, long index) {
-        super(counterId.toString() + "[" + index + "]");
-        this.counterId = counterId;
-        this.index = index;
-    }
-
-    /**
-     * Returns a counter cell identifier for the given counter identifier and index.
-     *
-     * @param counterId counter identifier
-     * @param index     index
-     * @return counter cell identifier
-     */
-    public static PiIndirectCounterCellId of(PiCounterId counterId, long index) {
-        checkNotNull(counterId);
-        checkArgument(counterId.type() == INDIRECT, "Counter ID must be of type INDIRECT");
-        checkArgument(index >= 0, "Index must be a positive integer");
-        return new PiIndirectCounterCellId(counterId, index);
-    }
-
-    /**
-     * Returns the index of this cell.
-     *
-     * @return cell index
-     */
-    public long index() {
-        return index;
-    }
-
-    @Override
-    public PiCounterId counterId() {
-        return counterId;
-    }
-
-    @Override
-    public PiCounterType type() {
-        return INDIRECT;
-    }
-}
diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiLpmFieldMatch.java b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiLpmFieldMatch.java
index 87b8723..24ef957 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiLpmFieldMatch.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiLpmFieldMatch.java
@@ -19,13 +19,14 @@
 import com.google.common.annotations.Beta;
 import com.google.common.base.Objects;
 import org.onlab.util.ImmutableByteSequence;
+import org.onosproject.net.pi.model.PiMatchFieldId;
 import org.onosproject.net.pi.model.PiMatchType;
 
 import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Preconditions.checkNotNull;
 
 /**
- * Longest-prefix field match in a protocol-independent pipeline.
+ * Instance of a longest-prefix field match in a protocol-independent pipeline.
  */
 @Beta
 public final class PiLpmFieldMatch extends PiFieldMatch {
@@ -40,7 +41,7 @@
      * @param value        value
      * @param prefixLength prefix length
      */
-    public PiLpmFieldMatch(PiHeaderFieldId fieldId, ImmutableByteSequence value, int prefixLength) {
+    public PiLpmFieldMatch(PiMatchFieldId fieldId, ImmutableByteSequence value, int prefixLength) {
         super(fieldId);
         this.value = checkNotNull(value);
         this.prefixLength = prefixLength;
diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiMatchKey.java b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiMatchKey.java
index e2e8c3d..a978bfa 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiMatchKey.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiMatchKey.java
@@ -19,6 +19,7 @@
 import com.google.common.annotations.Beta;
 import com.google.common.base.Objects;
 import com.google.common.collect.ImmutableMap;
+import org.onosproject.net.pi.model.PiMatchFieldId;
 
 import java.util.Collection;
 import java.util.Optional;
@@ -32,9 +33,9 @@
 
     public static final PiMatchKey EMPTY = builder().build();
 
-    private final ImmutableMap<PiHeaderFieldId, PiFieldMatch> fieldMatches;
+    private final ImmutableMap<PiMatchFieldId, PiFieldMatch> fieldMatches;
 
-    private PiMatchKey(ImmutableMap<PiHeaderFieldId, PiFieldMatch> fieldMatches) {
+    private PiMatchKey(ImmutableMap<PiMatchFieldId, PiFieldMatch> fieldMatches) {
         this.fieldMatches = fieldMatches;
     }
 
@@ -53,7 +54,7 @@
      * @param fieldId field identifier
      * @return optional field match
      */
-    public Optional<PiFieldMatch> fieldMatch(PiHeaderFieldId fieldId) {
+    public Optional<PiFieldMatch> fieldMatch(PiMatchFieldId fieldId) {
         return Optional.ofNullable(fieldMatches.get(fieldId));
     }
 
@@ -95,7 +96,7 @@
      */
     public static final class Builder {
 
-        private final ImmutableMap.Builder<PiHeaderFieldId, PiFieldMatch> fieldMatchesBuilder = ImmutableMap.builder();
+        private final ImmutableMap.Builder<PiMatchFieldId, PiFieldMatch> fieldMatchesBuilder = ImmutableMap.builder();
 
         private Builder() {
             // hides constructor.
@@ -129,7 +130,7 @@
          * @return match key
          */
         public PiMatchKey build() {
-            ImmutableMap<PiHeaderFieldId, PiFieldMatch> fieldMatches = fieldMatchesBuilder.build();
+            ImmutableMap<PiMatchFieldId, PiFieldMatch> fieldMatches = fieldMatchesBuilder.build();
             return new PiMatchKey(fieldMatches);
         }
     }
diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiPacketMetadataId.java b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiPacketMetadataId.java
deleted file mode 100644
index 55bdf5c..0000000
--- a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiPacketMetadataId.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.net.pi.runtime;
-
-import com.google.common.annotations.Beta;
-import org.onlab.util.Identifier;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Identifier of a metadata for a packet I/O operation in a protocol-independent pipeline.
- */
-@Beta
-public final class PiPacketMetadataId extends Identifier<String> {
-
-    /**
-     * Creates a packet metadata identifier.
-     *
-     * @param name packet metadata name
-     */
-    private PiPacketMetadataId(String name) {
-        super(name);
-    }
-
-    /**
-     * Returns the name of the packet metadata.
-     *
-     * @return packet metadata name
-     */
-    public String name() {
-        return this.identifier;
-    }
-
-    /**
-     * Returns a identifier with the given name.
-     *
-     * @param name packet metadata name
-     * @return packet metadata identifier
-     */
-    public static PiPacketMetadataId of(String name) {
-        checkNotNull(name);
-        checkArgument(!name.isEmpty(), "Name can't be empty");
-        return new PiPacketMetadataId(name);
-    }
-}
diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiPacketOperation.java b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiPacketOperation.java
index 4bbab76..74c68d6 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiPacketOperation.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiPacketOperation.java
@@ -21,6 +21,9 @@
 import com.google.common.base.Objects;
 import com.google.common.collect.ImmutableSet;
 import org.onlab.util.ImmutableByteSequence;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.pi.model.PiControlMetadataId;
+import org.onosproject.net.pi.model.PiPacketOperationType;
 
 import java.util.Collection;
 import java.util.HashMap;
@@ -30,46 +33,48 @@
 import static com.google.common.base.Preconditions.checkNotNull;
 
 /**
- * Instance of a packet I/O operation, and its metadatas for a protocol-independent pipeline.
+ * Instance of a packet I/O operation, and its control metadatas, for a protocol-independent pipeline.
  */
 @Beta
 public final class PiPacketOperation {
 
-    public enum Type {
-        /**
-         * Represents a packet out.
-         */
-        PACKET_OUT,
-
-        /**
-         * Represents a packet in.
-         */
-        PACKET_IN,
-    }
-
+    private final DeviceId deviceId;
     private final ImmutableByteSequence data;
-    private final Set<PiPacketMetadata> packetMetadatas;
-    private final PiPacketOperation.Type type;
+    private final Set<PiControlMetadata> packetMetadatas;
+    private final PiPacketOperationType type;
 
     /**
-     * Creates a new packet I/O operation for the given data, metadatas and operation type.
+     * Creates a new packet I/O operation for the given device ID, data, control metadatas and operation type.
      *
+     * @param deviceId        device ID
      * @param data            the packet raw data
-     * @param packetMetadatas set of packet metadata
+     * @param packetMetadatas collection of control metadata
      * @param type            type of this packet operation
      */
-    private PiPacketOperation(ImmutableByteSequence data, Collection<PiPacketMetadata> packetMetadatas, Type type) {
+    private PiPacketOperation(DeviceId deviceId, ImmutableByteSequence data,
+                              Collection<PiControlMetadata> packetMetadatas,
+                              PiPacketOperationType type) {
+        this.deviceId = deviceId;
         this.data = data;
         this.packetMetadatas = ImmutableSet.copyOf(packetMetadatas);
         this.type = type;
     }
 
     /**
+     * Returns the device ID of this packet operation.
+     *
+     * @return device ID
+     */
+    public DeviceId deviceId() {
+        return deviceId;
+    }
+
+    /**
      * Return the type of this packet.
      *
      * @return packet type
      */
-    public Type type() {
+    public PiPacketOperationType type() {
         return type;
     }
 
@@ -83,12 +88,11 @@
     }
 
     /**
-     * Returns all metadatas of this packet.
-     * Returns an empty collection if the packet doesn't have any metadata.
+     * Returns all metadatas of this packet. Returns an empty collection if the packet doesn't have any metadata.
      *
      * @return collection of metadatas
      */
-    public Collection<PiPacketMetadata> metadatas() {
+    public Collection<PiControlMetadata> metadatas() {
         return packetMetadatas;
     }
 
@@ -102,25 +106,27 @@
         }
         PiPacketOperation that = (PiPacketOperation) o;
         return Objects.equal(packetMetadatas, that.packetMetadatas) &&
+                Objects.equal(deviceId, that.deviceId) &&
                 Objects.equal(data, that.data()) &&
                 Objects.equal(type, that.type());
     }
 
     @Override
     public int hashCode() {
-        return Objects.hashCode(data, packetMetadatas, type);
+        return Objects.hashCode(deviceId, data, packetMetadatas, type);
     }
 
     @Override
     public String toString() {
         return MoreObjects.toStringHelper(this)
-                .addValue(packetMetadatas)
+                .add("deviceId", deviceId)
                 .addValue(type.toString())
+                .addValue(packetMetadatas)
                 .toString();
     }
 
     /**
-     * Returns an packet builder.
+     * Returns a new builder of packet operations.
      *
      * @return a new builder
      */
@@ -129,12 +135,13 @@
     }
 
     /**
-     * Builder of protocol-independent packets.
+     * Builder of packet operations.
      */
     public static final class Builder {
 
-        private Map<PiPacketMetadataId, PiPacketMetadata> packetMetadatas = new HashMap<>();
-        private PiPacketOperation.Type type;
+        private DeviceId deviceId;
+        private Map<PiControlMetadataId, PiControlMetadata> packetMetadatas = new HashMap<>();
+        private PiPacketOperationType type;
         private ImmutableByteSequence data;
 
         private Builder() {
@@ -142,7 +149,19 @@
         }
 
         /**
-         * Adds the raw packet data.
+         * Sets the device ID.
+         *
+         * @param deviceId device ID
+         * @return this
+         */
+        public Builder forDevice(DeviceId deviceId) {
+            checkNotNull(deviceId);
+            this.deviceId = deviceId;
+            return this;
+        }
+
+        /**
+         * Sets the raw packet data.
          *
          * @param data the packet raw data
          * @return this
@@ -154,14 +173,13 @@
         }
 
         /**
-         * Adds a metadata.
-         * Only one metadata is allowed for a given metadata id.
-         * If a metadata with same id already exists it will be replaced by the given one.
+         * Adds a control metadata. Only one metadata is allowed for a given metadata id. If a metadata with same id
+         * already exists it will be replaced by the given one.
          *
          * @param metadata packet metadata
          * @return this
          */
-        public Builder withMetadata(PiPacketMetadata metadata) {
+        public Builder withMetadata(PiControlMetadata metadata) {
             checkNotNull(metadata);
             packetMetadatas.put(metadata.id(), metadata);
 
@@ -174,7 +192,7 @@
          * @param metadatas collection of metadata
          * @return this
          */
-        public Builder withMetadatas(Collection<PiPacketMetadata> metadatas) {
+        public Builder withMetadatas(Collection<PiControlMetadata> metadatas) {
             checkNotNull(metadatas);
             metadatas.forEach(this::withMetadata);
             return this;
@@ -186,21 +204,22 @@
          * @param type type of the packet
          * @return this
          */
-        public Builder withType(Type type) {
+        public Builder withType(PiPacketOperationType type) {
             this.type = type;
             return this;
         }
 
         /**
-         * Returns a new packet instance.
+         * Builds a new instance of a packet operation.
          *
-         * @return packet
+         * @return packet operation
          */
         public PiPacketOperation build() {
+            checkNotNull(deviceId);
             checkNotNull(data);
             checkNotNull(packetMetadatas);
             checkNotNull(type);
-            return new PiPacketOperation(data, packetMetadatas.values(), type);
+            return new PiPacketOperation(deviceId, data, packetMetadatas.values(), type);
         }
     }
 }
diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiPipeconfConfig.java b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiPipeconfConfig.java
index 0dfaad9..a04dbf2 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiPipeconfConfig.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiPipeconfConfig.java
@@ -21,7 +21,7 @@
 import org.onosproject.net.pi.model.PiPipeconfId;
 
 /**
- * Configuration fot the PiPipeconf susbystem.
+ * Configuration for the PiPipeconf susbystem.
  */
 @Beta
 public class PiPipeconfConfig extends Config<DeviceId> {
diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiPipeconfService.java b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiPipeconfService.java
index 79bc624..2c6c66c 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiPipeconfService.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiPipeconfService.java
@@ -41,10 +41,9 @@
     void register(PiPipeconf pipeconf) throws IllegalStateException;
 
     /**
-     * Unregisters the Pipeconf identified by the given PiPipeconfId.
-     * Unregistering a Pipeconf removes it from the ONOS controller, thus making it un-capable
-     * of controlling (e.g installing flow rules) the devices that have the pipeconf's p4 program deployed.
-     * For now this method DOES NOT remove the p4 program from the devices.
+     * Unregisters the Pipeconf identified by the given PiPipeconfId. Unregistering a Pipeconf removes it from the ONOS
+     * controller, thus making it un-capable of controlling (e.g installing flow rules) the devices that have the
+     * pipeconf's P4 program deployed. For now this method DOES NOT remove the P4 program from the devices.
      *
      * @param pipeconfId a pipeconfId
      * @throws IllegalStateException if the same pipeconf identifier is already registered.
@@ -59,8 +58,8 @@
     Iterable<PiPipeconf> getPipeconfs();
 
     /**
-     * Returns the pipeconf instance associated with the given identifier, if present.
-     * If not present, it means that no pipeconf with such identifier has been registered so far.
+     * Returns the pipeconf instance associated with the given identifier, if present. If not present, it means that no
+     * pipeconf with such identifier has been registered so far.
      *
      * @param id a pipeconf identifier
      * @return an optional pipeconf
@@ -68,10 +67,9 @@
     Optional<PiPipeconf> getPipeconf(PiPipeconfId id);
 
     /**
-     * Binds the given pipeconf to the given infrastructure device. As a result of this method call,
-     * if the given pipeconf exposes any pipeline-specific behaviours, those will be merged to the
-     * device's driver. Returns a completable future to provide async methods with a boolean if the merge
-     * of the drivers succeeded.
+     * Binds the given pipeconf to the given infrastructure device. As a result of this method call, if the given
+     * pipeconf exposes any pipeline-specific behaviours, those will be merged to the device's driver. Returns a
+     * completable future to provide async methods with a boolean if the merge of the drivers succeeded.
      *
      * @param deviceId   a device identifier
      * @param pipeconfId a pipeconf identifier
@@ -82,8 +80,8 @@
     CompletableFuture<Boolean> bindToDevice(PiPipeconfId pipeconfId, DeviceId deviceId);
 
     /**
-     * Returns the pipeconf identifier currently associated with the given device identifier, if
-     * present. If not present, it means no pipeconf has been associated with that device so far.
+     * Returns the pipeconf identifier currently associated with the given device identifier, if present. If not
+     * present, it means no pipeconf has been associated with that device so far.
      *
      * @param deviceId device identifier
      * @return an optional pipeconf identifier
diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiRangeFieldMatch.java b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiRangeFieldMatch.java
index b6c39aa..0905d9c 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiRangeFieldMatch.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiRangeFieldMatch.java
@@ -19,13 +19,14 @@
 import com.google.common.annotations.Beta;
 import com.google.common.base.Objects;
 import org.onlab.util.ImmutableByteSequence;
+import org.onosproject.net.pi.model.PiMatchFieldId;
 import org.onosproject.net.pi.model.PiMatchType;
 
 import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Preconditions.checkNotNull;
 
 /**
- * Range field match in a protocol-independent pipeline.
+ * Instance of a range field match in a protocol-independent pipeline.
  */
 @Beta
 public final class PiRangeFieldMatch extends PiFieldMatch {
@@ -40,7 +41,7 @@
      * @param lowValue  low value
      * @param highValue high value
      */
-    public PiRangeFieldMatch(PiHeaderFieldId fieldId, ImmutableByteSequence lowValue,
+    public PiRangeFieldMatch(PiMatchFieldId fieldId, ImmutableByteSequence lowValue,
                              ImmutableByteSequence highValue) {
         super(fieldId);
         this.lowValue = checkNotNull(lowValue);
diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiTableAction.java b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiTableAction.java
index cacb49e..7d25e1a 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiTableAction.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiTableAction.java
@@ -19,19 +19,15 @@
 import com.google.common.annotations.Beta;
 
 /**
- * An action that can be executed as a consequence of a match in a match+action table of a protocol-independent
- * pipeline.
+ * Instance of an action that can be executed as a consequence of a match in a match+action table of a
+ * protocol-independent pipeline.
  */
 @Beta
 public interface PiTableAction {
 
     /**
-     * Type of this action.
-     *
-     * @return a type
+     * Types of table action.
      */
-    Type type();
-
     enum Type {
         /**
          * Simple action with runtime parameters set by the control plane.
@@ -48,4 +44,11 @@
          */
         GROUP_MEMBER_ID
     }
+
+    /**
+     * Type of this action.
+     *
+     * @return a type
+     */
+    Type type();
 }
diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiTableEntry.java b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiTableEntry.java
index 6a5f75b..cd7e493 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiTableEntry.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiTableEntry.java
@@ -19,6 +19,7 @@
 import com.google.common.annotations.Beta;
 import com.google.common.base.MoreObjects;
 import com.google.common.base.Objects;
+import org.onosproject.net.pi.model.PiTableId;
 
 import java.util.Optional;
 
@@ -26,7 +27,7 @@
 import static com.google.common.base.Preconditions.checkNotNull;
 
 /**
- * Table entry in a protocol-independent pipeline.
+ * Instance of a table entry in a protocol-independent pipeline.
  */
 @Beta
 public final class PiTableEntry {
@@ -99,8 +100,8 @@
     }
 
     /**
-     * Returns the priority of this table entry, if present.
-     * If the priority value is not present, then this table entry has no explicit priority.
+     * Returns the priority of this table entry, if present. If the priority value is not present, then this table entry
+     * has no explicit priority.
      *
      * @return optional priority
      */
@@ -109,8 +110,8 @@
     }
 
     /**
-     * Returns the timeout in seconds of this table entry, if present.
-     * If the timeout value is not present, then this table entry is meant to be permanent.
+     * Returns the timeout in seconds of this table entry, if present. If the timeout value is not present, then this
+     * table entry is meant to be permanent.
      *
      * @return optional timeout value in seconds
      */
diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiTableId.java b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiTableId.java
deleted file mode 100644
index 7b988b1..0000000
--- a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiTableId.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.net.pi.runtime;
-
-import com.google.common.annotations.Beta;
-import org.onlab.util.Identifier;
-import org.onosproject.net.flow.TableId;
-
-import java.util.Optional;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Identifier of a table in a protocol-independent pipeline.
- */
-@Beta
-public final class PiTableId extends Identifier<String> implements TableId  {
-
-    private final String scope;
-    private final String name;
-
-    private PiTableId(String scope, String name) {
-        super((scope != null ? scope + "." : "") + name);
-        this.scope = scope;
-        this.name = name;
-    }
-
-    /**
-     * Returns a table identifier for the given table scope and name.
-     *
-     * @param scope table scope
-     * @param name  table name
-     * @return table identifier
-     */
-    public static PiTableId of(String scope, String name) {
-        checkNotNull(name);
-        checkNotNull(scope);
-        checkArgument(!name.isEmpty(), "Name can't be empty");
-        checkArgument(!scope.isEmpty(), "Scope can't be empty");
-        return new PiTableId(scope, name);
-    }
-
-    /**
-     * Returns a table identifier for the given table name.
-     *
-     * @param name table name
-     * @return table identifier
-     */
-    public static PiTableId of(String name) {
-        checkNotNull(name);
-        checkArgument(!name.isEmpty(), "Name can't be empty");
-        return new PiTableId(null, name);
-    }
-
-
-    /**
-     * Returns the name of this table.
-     *
-     * @return table name
-     */
-    public String name() {
-        return name;
-    }
-
-    /**
-     * Returns the scope of this table, if present.
-     *
-     * @return optional scope
-     */
-    public Optional<String> scope() {
-        return Optional.ofNullable(scope);
-    }
-
-    @Override
-    public Type type() {
-        return Type.PIPELINE_INDEPENDENT;
-    }
-}
diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiTernaryFieldMatch.java b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiTernaryFieldMatch.java
index 29679ba..8406aed 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiTernaryFieldMatch.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiTernaryFieldMatch.java
@@ -19,13 +19,14 @@
 import com.google.common.annotations.Beta;
 import com.google.common.base.Objects;
 import org.onlab.util.ImmutableByteSequence;
+import org.onosproject.net.pi.model.PiMatchFieldId;
 import org.onosproject.net.pi.model.PiMatchType;
 
 import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Preconditions.checkNotNull;
 
 /**
- * Ternary field match in a protocol-independent pipeline.
+ * Instance of a ternary field match in a protocol-independent pipeline.
  */
 @Beta
 public final class PiTernaryFieldMatch extends PiFieldMatch {
@@ -37,10 +38,10 @@
      * Creates a new ternary field match.
      *
      * @param fieldId field identifier
-     * @param value value
-     * @param mask  mask
+     * @param value   value
+     * @param mask    mask
      */
-    public PiTernaryFieldMatch(PiHeaderFieldId fieldId, ImmutableByteSequence value,
+    public PiTernaryFieldMatch(PiMatchFieldId fieldId, ImmutableByteSequence value,
                                ImmutableByteSequence mask) {
         super(fieldId);
         this.value = checkNotNull(value);
@@ -49,11 +50,6 @@
                       "Value and mask must have same non-zero size");
     }
 
-    @Override
-    public PiMatchType type() {
-        return PiMatchType.TERNARY;
-    }
-
     /**
      * Returns the value matched by this field.
      *
@@ -73,6 +69,11 @@
     }
 
     @Override
+    public PiMatchType type() {
+        return PiMatchType.TERNARY;
+    }
+
+    @Override
     public boolean equals(Object o) {
         if (this == o) {
             return true;
diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiTranslationService.java b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiTranslationService.java
index a0c1101..d099583 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiTranslationService.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiTranslationService.java
@@ -22,7 +22,7 @@
 import org.onosproject.net.pi.model.PiPipeconf;
 
 /**
- * A service to translate ONOS entities to protocol-independent ones.
+ * A service to translate protocol-dependent entities to protocol-independent ones.
  */
 @Beta
 public interface PiTranslationService {
diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiValidFieldMatch.java b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiValidFieldMatch.java
index 8b172de..7894ba82 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiValidFieldMatch.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiValidFieldMatch.java
@@ -18,10 +18,11 @@
 
 import com.google.common.annotations.Beta;
 import com.google.common.base.Objects;
+import org.onosproject.net.pi.model.PiMatchFieldId;
 import org.onosproject.net.pi.model.PiMatchType;
 
 /**
- * A valid field match in a protocol-independent pipeline.
+ * Instance of a valid field match in a protocol-independent pipeline.
  */
 @Beta
 public final class PiValidFieldMatch extends PiFieldMatch {
@@ -34,7 +35,7 @@
      * @param fieldId field identifier
      * @param isValid validity flag
      */
-    public PiValidFieldMatch(PiHeaderFieldId fieldId, boolean isValid) {
+    public PiValidFieldMatch(PiMatchFieldId fieldId, boolean isValid) {
         super(fieldId);
         this.isValid = isValid;
     }
diff --git a/core/api/src/test/java/org/onosproject/net/flow/criteria/PiCriteriaTest.java b/core/api/src/test/java/org/onosproject/net/flow/criteria/PiCriteriaTest.java
index f05dfaf..ab0446d 100644
--- a/core/api/src/test/java/org/onosproject/net/flow/criteria/PiCriteriaTest.java
+++ b/core/api/src/test/java/org/onosproject/net/flow/criteria/PiCriteriaTest.java
@@ -18,9 +18,9 @@
 
 import com.google.common.testing.EqualsTester;
 import org.junit.Test;
+import org.onosproject.net.pi.model.PiMatchFieldId;
 import org.onosproject.net.pi.runtime.PiExactFieldMatch;
 import org.onosproject.net.pi.runtime.PiFieldMatch;
-import org.onosproject.net.pi.runtime.PiHeaderFieldId;
 import org.onosproject.net.pi.runtime.PiLpmFieldMatch;
 import org.onosproject.net.pi.runtime.PiRangeFieldMatch;
 import org.onosproject.net.pi.runtime.PiTernaryFieldMatch;
@@ -38,195 +38,168 @@
  */
 public class PiCriteriaTest {
 
-    PiHeaderFieldId piEthHeaderFieldId = PiHeaderFieldId.of("ethernet_t", "etherType");
-    byte[] matchExactBytes1 = {0x08, 0x00};
-    byte[] matchExactBytes2 = {0x08, 0x06};
-    Criterion matchPiExactByte1 = PiCriterion.builder().matchExact(piEthHeaderFieldId, matchExactBytes1).build();
-    Criterion sameAsMatchPiExactByte1 = PiCriterion.builder().matchExact(piEthHeaderFieldId, matchExactBytes1).build();
-    Criterion matchPiExactByte2 = PiCriterion.builder().matchExact(piEthHeaderFieldId, matchExactBytes2).build();
+    private PiMatchFieldId ethMatchFieldId = PiMatchFieldId.of("ethernet_t.etherType");
+    private byte[] matchExactBytes1 = {0x08, 0x00};
+    private byte[] matchExactBytes2 = {0x08, 0x06};
+    private Criterion matchPiExactByte1 = PiCriterion.builder()
+            .matchExact(ethMatchFieldId, matchExactBytes1).build();
+    private Criterion sameAsMatchPiExactByte1 = PiCriterion.builder()
+            .matchExact(ethMatchFieldId, matchExactBytes1).build();
+    private Criterion matchPiExactByte2 = PiCriterion.builder()
+            .matchExact(ethMatchFieldId, matchExactBytes2).build();
 
-    short matchExactShort1 = 0x800;
-    short matchExactShort2 = 0x806;
-    Criterion matchPiExactShort1 = PiCriterion.builder().matchExact(piEthHeaderFieldId, matchExactShort1).build();
-    Criterion sameAsMatchPiExactShort1 = PiCriterion.builder().matchExact(piEthHeaderFieldId, matchExactShort1).build();
-    Criterion matchPiExactShort2 = PiCriterion.builder().matchExact(piEthHeaderFieldId, matchExactShort2).build();
+    private short matchExactShort1 = 0x800;
+    private short matchExactShort2 = 0x806;
+    private Criterion matchPiExactShort1 = PiCriterion.builder()
+            .matchExact(ethMatchFieldId, matchExactShort1).build();
+    private Criterion sameAsMatchPiExactShort1 = PiCriterion.builder()
+            .matchExact(ethMatchFieldId, matchExactShort1).build();
+    private Criterion matchPiExactShort2 = PiCriterion.builder()
+            .matchExact(ethMatchFieldId, matchExactShort2).build();
 
-    int matchExactInt1 = 0x800;
-    int matchExactInt2 = 0x806;
-    Criterion matchPiExactInt1 = PiCriterion.builder().matchExact(piEthHeaderFieldId, matchExactInt1).build();
-    Criterion sameAsMatchPiExactInt1 = PiCriterion.builder().matchExact(piEthHeaderFieldId, matchExactInt1).build();
-    Criterion matchPiExactInt2 = PiCriterion.builder().matchExact(piEthHeaderFieldId, matchExactInt2).build();
+    private int matchExactInt1 = 0x800;
+    private int matchExactInt2 = 0x806;
+    private Criterion matchPiExactInt1 = PiCriterion.builder()
+            .matchExact(ethMatchFieldId, matchExactInt1).build();
+    private Criterion sameAsMatchPiExactInt1 = PiCriterion.builder()
+            .matchExact(ethMatchFieldId, matchExactInt1).build();
+    private Criterion matchPiExactInt2 = PiCriterion.builder()
+            .matchExact(ethMatchFieldId, matchExactInt2).build();
 
-    long matchExactLong1 = 0x800;
-    long matchExactLong2 = 0x806;
-    Criterion matchPiExactLong1 = PiCriterion.builder().matchExact(piEthHeaderFieldId, matchExactLong1).build();
-    Criterion sameAsMatchPiExactLong1 = PiCriterion.builder().matchExact(piEthHeaderFieldId, matchExactLong1).build();
-    Criterion matchPiExactLong2 = PiCriterion.builder().matchExact(piEthHeaderFieldId, matchExactLong2).build();
+    private long matchExactLong1 = 0x800;
+    private long matchExactLong2 = 0x806;
+    private Criterion matchPiExactLong1 = PiCriterion.builder()
+            .matchExact(ethMatchFieldId, matchExactLong1).build();
+    private Criterion sameAsMatchPiExactLong1 = PiCriterion.builder()
+            .matchExact(ethMatchFieldId, matchExactLong1).build();
+    private Criterion matchPiExactLong2 = PiCriterion.builder()
+            .matchExact(ethMatchFieldId, matchExactLong2).build();
 
-    PiHeaderFieldId piIpv4HeaderFieldId = PiHeaderFieldId.of("ipv4_t", "dstAddr");
-    int mask = 0x00ffffff;
-    byte[] matchLpmBytes1 = {0x0a, 0x01, 0x01, 0x01};
-    byte[] matchLpmBytes2 = {0x0a, 0x01, 0x01, 0x02};
-    Criterion matchPiLpmByte1 = PiCriterion.builder().matchLpm(piIpv4HeaderFieldId, matchLpmBytes1, mask).build();
-    Criterion sameAsMatchPiLpmByte1 = PiCriterion.builder().matchLpm(piIpv4HeaderFieldId, matchLpmBytes1, mask).build();
-    Criterion matchPiLpmByte2 = PiCriterion.builder().matchLpm(piIpv4HeaderFieldId, matchLpmBytes2, mask).build();
+    private PiMatchFieldId ipv4MatchFieldId = PiMatchFieldId.of("ipv4_t.dstAddr");
+    private int mask = 0x00ffffff;
+    private byte[] matchLpmBytes1 = {0x0a, 0x01, 0x01, 0x01};
+    private byte[] matchLpmBytes2 = {0x0a, 0x01, 0x01, 0x02};
+    private Criterion matchPiLpmByte1 = PiCriterion.builder()
+            .matchLpm(ipv4MatchFieldId, matchLpmBytes1, mask).build();
+    private Criterion sameAsMatchPiLpmByte1 = PiCriterion.builder()
+            .matchLpm(ipv4MatchFieldId, matchLpmBytes1, mask).build();
+    private Criterion matchPiLpmByte2 = PiCriterion.builder()
+            .matchLpm(ipv4MatchFieldId, matchLpmBytes2, mask).build();
 
-    short matchLpmShort1 = 0x0a0a;
-    short matchLpmShort2 = 0x0a0b;
-    Criterion matchPiLpmShort1 = PiCriterion.builder().matchLpm(piIpv4HeaderFieldId, matchLpmShort1, mask).build();
-    Criterion sameAsMatchPiLpmShort1 = PiCriterion.builder().matchLpm(piIpv4HeaderFieldId,
-            matchLpmShort1, mask)
-            .build();
-    Criterion matchPiLpmShort2 = PiCriterion.builder().matchLpm(piIpv4HeaderFieldId, matchLpmShort2, mask).build();
+    private short matchLpmShort1 = 0x0a0a;
+    private short matchLpmShort2 = 0x0a0b;
+    private Criterion matchPiLpmShort1 = PiCriterion.builder()
+            .matchLpm(ipv4MatchFieldId, matchLpmShort1, mask).build();
+    private Criterion sameAsMatchPiLpmShort1 = PiCriterion.builder()
+            .matchLpm(ipv4MatchFieldId, matchLpmShort1, mask).build();
+    private Criterion matchPiLpmShort2 = PiCriterion.builder()
+            .matchLpm(ipv4MatchFieldId, matchLpmShort2, mask).build();
 
-    int matchLpmInt1 = 0x0a010101;
-    int matchLpmInt2 = 0x0a010102;
-    Criterion matchPiLpmInt1 = PiCriterion.builder().matchLpm(piIpv4HeaderFieldId, matchLpmInt1, mask).build();
-    Criterion sameAsMatchPiLpmInt1 = PiCriterion.builder().matchLpm(piIpv4HeaderFieldId, matchLpmInt1, mask).build();
-    Criterion matchPiLpmInt2 = PiCriterion.builder().matchLpm(piIpv4HeaderFieldId, matchLpmInt2, mask).build();
+    private int matchLpmInt1 = 0x0a010101;
+    private int matchLpmInt2 = 0x0a010102;
+    private Criterion matchPiLpmInt1 = PiCriterion.builder()
+            .matchLpm(ipv4MatchFieldId, matchLpmInt1, mask).build();
+    private Criterion sameAsMatchPiLpmInt1 = PiCriterion.builder()
+            .matchLpm(ipv4MatchFieldId, matchLpmInt1, mask).build();
+    private Criterion matchPiLpmInt2 = PiCriterion.builder()
+            .matchLpm(ipv4MatchFieldId, matchLpmInt2, mask).build();
 
-    long matchLpmLong1 = 0x0a010101;
-    long matchLpmLong2 = 0x0a010102;
-    Criterion matchPiLpmLong1 = PiCriterion.builder().matchLpm(piIpv4HeaderFieldId, matchLpmLong1, mask).build();
-    Criterion sameAsMatchPiLpmLong1 = PiCriterion.builder().matchLpm(piIpv4HeaderFieldId, matchLpmLong1, mask).build();
-    Criterion matchPiLpmLong2 = PiCriterion.builder().matchLpm(piIpv4HeaderFieldId, matchLpmLong2, mask).build();
+    private long matchLpmLong1 = 0x0a010101;
+    private long matchLpmLong2 = 0x0a010102;
+    private Criterion matchPiLpmLong1 = PiCriterion.builder()
+            .matchLpm(ipv4MatchFieldId, matchLpmLong1, mask).build();
+    private Criterion sameAsMatchPiLpmLong1 = PiCriterion.builder()
+            .matchLpm(ipv4MatchFieldId, matchLpmLong1, mask).build();
+    private Criterion matchPiLpmLong2 = PiCriterion.builder()
+            .matchLpm(ipv4MatchFieldId, matchLpmLong2, mask).build();
 
 
-    byte[] matchTernaryBytes1 = {0x0a, 0x01, 0x01, 0x01};
-    byte[] matchTernaryBytes2 = {0x0a, 0x01, 0x01, 0x02};
-    byte[] matchTernaryMaskBytes = {0x7f, 0x7f, 0x7f, 0x00};
-    Criterion matchPiTernaryByte1 = PiCriterion.builder().matchTernary(piIpv4HeaderFieldId,
-            matchTernaryBytes1,
-            matchTernaryMaskBytes)
-            .build();
-    Criterion sameAsMatchPiTernaryByte1 = PiCriterion.builder().matchTernary(piIpv4HeaderFieldId,
-            matchTernaryBytes1,
-            matchTernaryMaskBytes)
-            .build();
-    Criterion matchPiTernaryByte2 = PiCriterion.builder().matchTernary(piIpv4HeaderFieldId,
-            matchTernaryBytes2,
-            matchTernaryMaskBytes)
-            .build();
+    private byte[] matchTernaryBytes1 = {0x0a, 0x01, 0x01, 0x01};
+    private byte[] matchTernaryBytes2 = {0x0a, 0x01, 0x01, 0x02};
+    private byte[] matchTernaryMaskBytes = {0x7f, 0x7f, 0x7f, 0x00};
+    private Criterion matchPiTernaryByte1 = PiCriterion.builder()
+            .matchTernary(ipv4MatchFieldId, matchTernaryBytes1, matchTernaryMaskBytes).build();
+    private Criterion sameAsMatchPiTernaryByte1 = PiCriterion.builder()
+            .matchTernary(ipv4MatchFieldId, matchTernaryBytes1, matchTernaryMaskBytes).build();
+    private Criterion matchPiTernaryByte2 = PiCriterion.builder()
+            .matchTernary(ipv4MatchFieldId, matchTernaryBytes2, matchTernaryMaskBytes).build();
 
-    short matchTernaryShort1 = 0x0a0a;
-    short matchTernaryShort2 = 0x0a0b;
-    short matchTernaryMaskShort = 0xff0;
-    Criterion matchPiTernaryShort1 = PiCriterion.builder().matchTernary(piIpv4HeaderFieldId,
-            matchTernaryShort1,
-            matchTernaryMaskShort)
-            .build();
-    Criterion sameAsMatchPiTernaryShort1 = PiCriterion.builder().matchTernary(piIpv4HeaderFieldId,
-            matchTernaryShort1,
-            matchTernaryMaskShort)
-            .build();
-    Criterion matchPiTernaryShort2 = PiCriterion.builder().matchTernary(piIpv4HeaderFieldId,
-            matchTernaryShort2,
-            matchTernaryMaskShort)
-            .build();
+    private short matchTernaryShort1 = 0x0a0a;
+    private short matchTernaryShort2 = 0x0a0b;
+    private short matchTernaryMaskShort = 0xff0;
+    private Criterion matchPiTernaryShort1 = PiCriterion.builder()
+            .matchTernary(ipv4MatchFieldId, matchTernaryShort1, matchTernaryMaskShort).build();
+    private Criterion sameAsMatchPiTernaryShort1 = PiCriterion.builder()
+            .matchTernary(ipv4MatchFieldId, matchTernaryShort1, matchTernaryMaskShort).build();
+    private Criterion matchPiTernaryShort2 = PiCriterion.builder()
+            .matchTernary(ipv4MatchFieldId, matchTernaryShort2, matchTernaryMaskShort).build();
 
-    int matchTernaryInt1 = 0x0a010101;
-    int matchTernaryInt2 = 0x0a010102;
-    int matchTernaryMaskInt = 0xffff;
-    Criterion matchPiTernaryInt1 = PiCriterion.builder().matchTernary(piIpv4HeaderFieldId,
-            matchTernaryInt1,
-            matchTernaryMaskInt)
-            .build();
-    Criterion sameAsMatchPiTernaryInt1 = PiCriterion.builder().matchTernary(piIpv4HeaderFieldId,
-            matchTernaryInt1,
-            matchTernaryMaskInt)
-            .build();
-    Criterion matchPiTernaryInt2 = PiCriterion.builder().matchTernary(piIpv4HeaderFieldId,
-            matchTernaryInt2,
-            matchTernaryMaskInt)
-            .build();
+    private int matchTernaryInt1 = 0x0a010101;
+    private int matchTernaryInt2 = 0x0a010102;
+    private int matchTernaryMaskInt = 0xffff;
+    private Criterion matchPiTernaryInt1 = PiCriterion.builder()
+            .matchTernary(ipv4MatchFieldId, matchTernaryInt1, matchTernaryMaskInt).build();
+    private Criterion sameAsMatchPiTernaryInt1 = PiCriterion.builder()
+            .matchTernary(ipv4MatchFieldId, matchTernaryInt1, matchTernaryMaskInt).build();
+    private Criterion matchPiTernaryInt2 = PiCriterion.builder()
+            .matchTernary(ipv4MatchFieldId, matchTernaryInt2, matchTernaryMaskInt).build();
 
-    long matchTernaryLong1 = 0x0a010101;
-    long matchTernaryLong2 = 0x0a010102;
-    long matchTernaryMaskLong = 0xffff;
-    Criterion matchPiTernaryLong1 = PiCriterion.builder().matchTernary(piIpv4HeaderFieldId,
-            matchTernaryLong1,
-            matchTernaryMaskLong)
-            .build();
-    Criterion sameAsMatchPiTernaryLong1 = PiCriterion.builder().matchTernary(piIpv4HeaderFieldId,
-            matchTernaryLong1,
-            matchTernaryMaskLong)
-            .build();
-    Criterion matchPiTernaryLong2 = PiCriterion.builder().matchTernary(piIpv4HeaderFieldId,
-            matchTernaryLong2,
-            matchTernaryMaskLong)
-            .build();
+    private long matchTernaryLong1 = 0x0a010101;
+    private long matchTernaryLong2 = 0x0a010102;
+    private long matchTernaryMaskLong = 0xffff;
+    private Criterion matchPiTernaryLong1 = PiCriterion.builder()
+            .matchTernary(ipv4MatchFieldId, matchTernaryLong1, matchTernaryMaskLong).build();
+    private Criterion sameAsMatchPiTernaryLong1 = PiCriterion.builder()
+            .matchTernary(ipv4MatchFieldId, matchTernaryLong1, matchTernaryMaskLong).build();
+    private Criterion matchPiTernaryLong2 = PiCriterion.builder()
+            .matchTernary(ipv4MatchFieldId, matchTernaryLong2, matchTernaryMaskLong).build();
 
-    Criterion matchPiValid1 = PiCriterion.builder().matchValid(piIpv4HeaderFieldId, false).build();
-    Criterion sameAsMatchPiValid1 = PiCriterion.builder().matchValid(piIpv4HeaderFieldId, false).build();
-    Criterion matchPiValid2 = PiCriterion.builder().matchValid(piIpv4HeaderFieldId, true).build();
+    private Criterion matchPiValid1 = PiCriterion.builder().matchValid(ipv4MatchFieldId, false).build();
+    private Criterion sameAsMatchPiValid1 = PiCriterion.builder().matchValid(ipv4MatchFieldId, false).build();
+    private Criterion matchPiValid2 = PiCriterion.builder().matchValid(ipv4MatchFieldId, true).build();
 
-    byte[] matchRangeBytes1 = {0x10};
-    byte[] matchRangeBytes2 = {0x20};
-    byte[] matchRangeHighBytes = {0x30};
-    Criterion matchPiRangeByte1 = PiCriterion.builder().matchRange(piIpv4HeaderFieldId,
-            matchRangeBytes1,
-            matchRangeHighBytes)
-            .build();
-    Criterion sameAsMatchPiRangeByte1 = PiCriterion.builder().matchRange(piIpv4HeaderFieldId,
-            matchRangeBytes1,
-            matchRangeHighBytes)
-            .build();
-    Criterion matchPiRangeByte2 = PiCriterion.builder().matchRange(piIpv4HeaderFieldId,
-            matchRangeBytes2,
-            matchRangeHighBytes)
-            .build();
+    private byte[] matchRangeBytes1 = {0x10};
+    private byte[] matchRangeBytes2 = {0x20};
+    private byte[] matchRangeHighBytes = {0x30};
+    private Criterion matchPiRangeByte1 = PiCriterion.builder()
+            .matchRange(ipv4MatchFieldId, matchRangeBytes1, matchRangeHighBytes).build();
+    private Criterion sameAsMatchPiRangeByte1 = PiCriterion.builder()
+            .matchRange(ipv4MatchFieldId, matchRangeBytes1, matchRangeHighBytes).build();
+    private Criterion matchPiRangeByte2 = PiCriterion.builder()
+            .matchRange(ipv4MatchFieldId, matchRangeBytes2, matchRangeHighBytes).build();
 
-    short matchRangeShort1 = 0x100;
-    short matchRangeShort2 = 0x200;
-    short matchRangeHighShort = 0x300;
-    Criterion matchPiRangeShort1 = PiCriterion.builder().matchRange(piIpv4HeaderFieldId,
-            matchRangeShort1,
-            matchRangeHighShort)
-            .build();
-    Criterion sameAsMatchPiRangeShort1 = PiCriterion.builder().matchRange(piIpv4HeaderFieldId,
-            matchRangeShort1,
-            matchRangeHighShort)
-            .build();
-    Criterion matchPiRangeShort2 = PiCriterion.builder().matchRange(piIpv4HeaderFieldId,
-            matchRangeShort2,
-            matchRangeHighShort)
-            .build();
+    private short matchRangeShort1 = 0x100;
+    private short matchRangeShort2 = 0x200;
+    private short matchRangeHighShort = 0x300;
+    private Criterion matchPiRangeShort1 = PiCriterion.builder()
+            .matchRange(ipv4MatchFieldId, matchRangeShort1, matchRangeHighShort).build();
+    private Criterion sameAsMatchPiRangeShort1 = PiCriterion.builder()
+            .matchRange(ipv4MatchFieldId, matchRangeShort1, matchRangeHighShort).build();
+    private Criterion matchPiRangeShort2 = PiCriterion.builder()
+            .matchRange(ipv4MatchFieldId, matchRangeShort2, matchRangeHighShort).build();
 
-    int matchRangeInt1 = 0x100;
-    int matchRangeInt2 = 0x200;
-    int matchRangeHighInt = 0x300;
-    Criterion matchPiRangeInt1 = PiCriterion.builder().matchRange(piIpv4HeaderFieldId,
-            matchRangeInt1,
-            matchRangeHighInt)
-            .build();
-    Criterion sameAsMatchPiRangeInt1 = PiCriterion.builder().matchRange(piIpv4HeaderFieldId,
-            matchRangeInt1,
-            matchRangeHighInt)
-            .build();
-    Criterion matchPiRangeInt2 = PiCriterion.builder().matchRange(piIpv4HeaderFieldId,
-            matchRangeInt2,
-            matchRangeHighInt)
-            .build();
+    private int matchRangeInt1 = 0x100;
+    private int matchRangeInt2 = 0x200;
+    private int matchRangeHighInt = 0x300;
+    private Criterion matchPiRangeInt1 = PiCriterion.builder()
+            .matchRange(ipv4MatchFieldId, matchRangeInt1, matchRangeHighInt).build();
+    private Criterion sameAsMatchPiRangeInt1 = PiCriterion.builder()
+            .matchRange(ipv4MatchFieldId, matchRangeInt1, matchRangeHighInt).build();
+    private Criterion matchPiRangeInt2 = PiCriterion.builder()
+            .matchRange(ipv4MatchFieldId, matchRangeInt2, matchRangeHighInt).build();
 
-    long matchRangeLong1 = 0x100;
-    long matchRangeLong2 = 0x200;
-    long matchRangeHighLong = 0x300;
-    Criterion matchPiRangeLong1 = PiCriterion.builder().matchRange(piIpv4HeaderFieldId,
-            matchRangeLong1,
-            matchRangeHighLong)
-            .build();
-    Criterion sameAsMatchPiRangeLong1 = PiCriterion.builder().matchRange(piIpv4HeaderFieldId,
-            matchRangeLong1,
-            matchRangeHighLong)
-            .build();
-    Criterion matchPiRangeLong2 = PiCriterion.builder().matchRange(piIpv4HeaderFieldId,
-            matchRangeLong2,
-            matchRangeHighLong)
-            .build();
+    private long matchRangeLong1 = 0x100;
+    private long matchRangeLong2 = 0x200;
+    private long matchRangeHighLong = 0x300;
+    private Criterion matchPiRangeLong1 = PiCriterion.builder()
+            .matchRange(ipv4MatchFieldId, matchRangeLong1, matchRangeHighLong).build();
+    private Criterion sameAsMatchPiRangeLong1 = PiCriterion.builder()
+            .matchRange(ipv4MatchFieldId, matchRangeLong1, matchRangeHighLong).build();
+    private Criterion matchPiRangeLong2 = PiCriterion.builder()
+            .matchRange(ipv4MatchFieldId, matchRangeLong2, matchRangeHighLong).build();
 
     /**
-     * Checks that a Criterion object has the proper type, and then converts
-     * it to the proper type.
+     * Checks that a Criterion object has the proper type, and then converts it to the proper type.
      *
      * @param criterion Criterion object to convert
      * @param type      Enumerated type value for the Criterion class
@@ -248,28 +221,28 @@
     @Test
     public void testExactMatchPiMethod() {
 
-        Criterion matchPiBytes = PiCriterion.builder().matchExact(piEthHeaderFieldId, matchExactBytes1).build();
+        Criterion matchPiBytes = PiCriterion.builder().matchExact(ethMatchFieldId, matchExactBytes1).build();
         PiCriterion piCriterionBytes = checkAndConvert(matchPiBytes, Criterion.Type.PROTOCOL_INDEPENDENT,
-                PiCriterion.class);
-        PiFieldMatch expectedMatchBytes = new PiExactFieldMatch(piEthHeaderFieldId, copyFrom(matchExactBytes1));
+                                                       PiCriterion.class);
+        PiFieldMatch expectedMatchBytes = new PiExactFieldMatch(ethMatchFieldId, copyFrom(matchExactBytes1));
         assertThat(piCriterionBytes.fieldMatches().iterator().next(), is(expectedMatchBytes));
 
-        Criterion matchPiShort = PiCriterion.builder().matchExact(piEthHeaderFieldId, matchExactShort1).build();
+        Criterion matchPiShort = PiCriterion.builder().matchExact(ethMatchFieldId, matchExactShort1).build();
         PiCriterion piCriterionShort = checkAndConvert(matchPiShort, Criterion.Type.PROTOCOL_INDEPENDENT,
-                PiCriterion.class);
-        PiFieldMatch expectedMatchShort = new PiExactFieldMatch(piEthHeaderFieldId, copyFrom(matchExactShort1));
+                                                       PiCriterion.class);
+        PiFieldMatch expectedMatchShort = new PiExactFieldMatch(ethMatchFieldId, copyFrom(matchExactShort1));
         assertThat(piCriterionShort.fieldMatches().iterator().next(), is(expectedMatchShort));
 
-        Criterion matchPiInt = PiCriterion.builder().matchExact(piEthHeaderFieldId, matchExactInt1).build();
+        Criterion matchPiInt = PiCriterion.builder().matchExact(ethMatchFieldId, matchExactInt1).build();
         PiCriterion piCriterionInt = checkAndConvert(matchPiInt, Criterion.Type.PROTOCOL_INDEPENDENT,
-                PiCriterion.class);
-        PiFieldMatch expectedMatchInt = new PiExactFieldMatch(piEthHeaderFieldId, copyFrom(matchExactInt1));
+                                                     PiCriterion.class);
+        PiFieldMatch expectedMatchInt = new PiExactFieldMatch(ethMatchFieldId, copyFrom(matchExactInt1));
         assertThat(piCriterionInt.fieldMatches().iterator().next(), is(expectedMatchInt));
 
-        Criterion matchPiLong = PiCriterion.builder().matchExact(piEthHeaderFieldId, matchExactLong1).build();
+        Criterion matchPiLong = PiCriterion.builder().matchExact(ethMatchFieldId, matchExactLong1).build();
         PiCriterion piCriterionLong = checkAndConvert(matchPiLong, Criterion.Type.PROTOCOL_INDEPENDENT,
-                PiCriterion.class);
-        PiFieldMatch expectedMatchLong = new PiExactFieldMatch(piEthHeaderFieldId, copyFrom(matchExactLong1));
+                                                      PiCriterion.class);
+        PiFieldMatch expectedMatchLong = new PiExactFieldMatch(ethMatchFieldId, copyFrom(matchExactLong1));
         assertThat(piCriterionLong.fieldMatches().iterator().next(), is(expectedMatchLong));
     }
 
@@ -279,28 +252,28 @@
     @Test
     public void testLpmMatchPiMethod() {
 
-        Criterion matchPiBytes = PiCriterion.builder().matchLpm(piIpv4HeaderFieldId, matchLpmBytes1, mask).build();
+        Criterion matchPiBytes = PiCriterion.builder().matchLpm(ipv4MatchFieldId, matchLpmBytes1, mask).build();
         PiCriterion piCriterionBytes = checkAndConvert(matchPiBytes, Criterion.Type.PROTOCOL_INDEPENDENT,
-                PiCriterion.class);
-        PiFieldMatch expectedMatchBytes = new PiLpmFieldMatch(piIpv4HeaderFieldId, copyFrom(matchLpmBytes1), mask);
+                                                       PiCriterion.class);
+        PiFieldMatch expectedMatchBytes = new PiLpmFieldMatch(ipv4MatchFieldId, copyFrom(matchLpmBytes1), mask);
         assertThat(piCriterionBytes.fieldMatches().iterator().next(), is(expectedMatchBytes));
 
-        Criterion matchPiShort = PiCriterion.builder().matchLpm(piIpv4HeaderFieldId, matchLpmShort1, mask).build();
+        Criterion matchPiShort = PiCriterion.builder().matchLpm(ipv4MatchFieldId, matchLpmShort1, mask).build();
         PiCriterion piCriterionShort = checkAndConvert(matchPiShort, Criterion.Type.PROTOCOL_INDEPENDENT,
-                PiCriterion.class);
-        PiFieldMatch expectedMatchShort = new PiLpmFieldMatch(piIpv4HeaderFieldId, copyFrom(matchLpmShort1), mask);
+                                                       PiCriterion.class);
+        PiFieldMatch expectedMatchShort = new PiLpmFieldMatch(ipv4MatchFieldId, copyFrom(matchLpmShort1), mask);
         assertThat(piCriterionShort.fieldMatches().iterator().next(), is(expectedMatchShort));
 
-        Criterion matchPiInt = PiCriterion.builder().matchLpm(piIpv4HeaderFieldId, matchLpmInt1, mask).build();
+        Criterion matchPiInt = PiCriterion.builder().matchLpm(ipv4MatchFieldId, matchLpmInt1, mask).build();
         PiCriterion piCriterionInt = checkAndConvert(matchPiInt, Criterion.Type.PROTOCOL_INDEPENDENT,
-                PiCriterion.class);
-        PiFieldMatch expectedMatchInt = new PiLpmFieldMatch(piIpv4HeaderFieldId, copyFrom(matchLpmInt1), mask);
+                                                     PiCriterion.class);
+        PiFieldMatch expectedMatchInt = new PiLpmFieldMatch(ipv4MatchFieldId, copyFrom(matchLpmInt1), mask);
         assertThat(piCriterionInt.fieldMatches().iterator().next(), is(expectedMatchInt));
 
-        Criterion matchPiLong = PiCriterion.builder().matchLpm(piIpv4HeaderFieldId, matchLpmLong1, mask).build();
+        Criterion matchPiLong = PiCriterion.builder().matchLpm(ipv4MatchFieldId, matchLpmLong1, mask).build();
         PiCriterion piCriterionLong = checkAndConvert(matchPiLong, Criterion.Type.PROTOCOL_INDEPENDENT,
-                PiCriterion.class);
-        PiFieldMatch expectedMatchLong = new PiLpmFieldMatch(piIpv4HeaderFieldId, copyFrom(matchLpmLong1), mask);
+                                                      PiCriterion.class);
+        PiFieldMatch expectedMatchLong = new PiLpmFieldMatch(ipv4MatchFieldId, copyFrom(matchLpmLong1), mask);
         assertThat(piCriterionLong.fieldMatches().iterator().next(), is(expectedMatchLong));
     }
 
@@ -310,40 +283,40 @@
     @Test
     public void testTernaryMatchPiMethod() {
 
-        Criterion matchPiBytes = PiCriterion.builder().matchTernary(piIpv4HeaderFieldId, matchTernaryBytes1,
-                matchTernaryMaskBytes)
+        Criterion matchPiBytes = PiCriterion.builder().matchTernary(ipv4MatchFieldId, matchTernaryBytes1,
+                                                                    matchTernaryMaskBytes)
                 .build();
         PiCriterion piCriterionBytes = checkAndConvert(matchPiBytes, Criterion.Type.PROTOCOL_INDEPENDENT,
-                PiCriterion.class);
-        PiFieldMatch expectedMatchBytes = new PiTernaryFieldMatch(piIpv4HeaderFieldId, copyFrom(matchTernaryBytes1),
-                copyFrom(matchTernaryMaskBytes));
+                                                       PiCriterion.class);
+        PiFieldMatch expectedMatchBytes = new PiTernaryFieldMatch(ipv4MatchFieldId, copyFrom(matchTernaryBytes1),
+                                                                  copyFrom(matchTernaryMaskBytes));
         assertThat(piCriterionBytes.fieldMatches().iterator().next(), is(expectedMatchBytes));
 
-        Criterion matchPiShort = PiCriterion.builder().matchTernary(piIpv4HeaderFieldId, matchTernaryShort1,
-                matchTernaryMaskShort)
+        Criterion matchPiShort = PiCriterion.builder().matchTernary(ipv4MatchFieldId, matchTernaryShort1,
+                                                                    matchTernaryMaskShort)
                 .build();
         PiCriterion piCriterionShort = checkAndConvert(matchPiShort, Criterion.Type.PROTOCOL_INDEPENDENT,
-                PiCriterion.class);
-        PiFieldMatch expectedMatchShort = new PiTernaryFieldMatch(piIpv4HeaderFieldId, copyFrom(matchTernaryShort1),
-                copyFrom(matchTernaryMaskShort));
+                                                       PiCriterion.class);
+        PiFieldMatch expectedMatchShort = new PiTernaryFieldMatch(ipv4MatchFieldId, copyFrom(matchTernaryShort1),
+                                                                  copyFrom(matchTernaryMaskShort));
         assertThat(piCriterionShort.fieldMatches().iterator().next(), is(expectedMatchShort));
 
-        Criterion matchPiInt = PiCriterion.builder().matchTernary(piIpv4HeaderFieldId, matchTernaryInt1,
-                matchTernaryMaskInt)
+        Criterion matchPiInt = PiCriterion.builder().matchTernary(ipv4MatchFieldId, matchTernaryInt1,
+                                                                  matchTernaryMaskInt)
                 .build();
         PiCriterion piCriterionInt = checkAndConvert(matchPiInt, Criterion.Type.PROTOCOL_INDEPENDENT,
-                PiCriterion.class);
-        PiFieldMatch expectedMatchInt = new PiTernaryFieldMatch(piIpv4HeaderFieldId, copyFrom(matchTernaryInt1),
-                copyFrom(matchTernaryMaskInt));
+                                                     PiCriterion.class);
+        PiFieldMatch expectedMatchInt = new PiTernaryFieldMatch(ipv4MatchFieldId, copyFrom(matchTernaryInt1),
+                                                                copyFrom(matchTernaryMaskInt));
         assertThat(piCriterionInt.fieldMatches().iterator().next(), is(expectedMatchInt));
 
-        Criterion matchPiLong = PiCriterion.builder().matchTernary(piIpv4HeaderFieldId, matchTernaryLong1,
-                matchTernaryMaskLong)
+        Criterion matchPiLong = PiCriterion.builder().matchTernary(ipv4MatchFieldId, matchTernaryLong1,
+                                                                   matchTernaryMaskLong)
                 .build();
         PiCriterion piCriterionLong = checkAndConvert(matchPiLong, Criterion.Type.PROTOCOL_INDEPENDENT,
-                PiCriterion.class);
-        PiFieldMatch expectedMatchLong = new PiTernaryFieldMatch(piIpv4HeaderFieldId, copyFrom(matchTernaryLong1),
-                copyFrom(matchTernaryMaskLong));
+                                                      PiCriterion.class);
+        PiFieldMatch expectedMatchLong = new PiTernaryFieldMatch(ipv4MatchFieldId, copyFrom(matchTernaryLong1),
+                                                                 copyFrom(matchTernaryMaskLong));
         assertThat(piCriterionLong.fieldMatches().iterator().next(), is(expectedMatchLong));
     }
 
@@ -353,10 +326,10 @@
     @Test
     public void testValidMatchPiMethod() {
 
-        Criterion matchPiBytes = PiCriterion.builder().matchValid(piIpv4HeaderFieldId, true).build();
+        Criterion matchPiBytes = PiCriterion.builder().matchValid(ipv4MatchFieldId, true).build();
         PiCriterion piCriterionBytes = checkAndConvert(matchPiBytes, Criterion.Type.PROTOCOL_INDEPENDENT,
-                PiCriterion.class);
-        PiFieldMatch expectedMatch = new PiValidFieldMatch(piIpv4HeaderFieldId, true);
+                                                       PiCriterion.class);
+        PiFieldMatch expectedMatch = new PiValidFieldMatch(ipv4MatchFieldId, true);
         assertThat(piCriterionBytes.fieldMatches().iterator().next(), is(expectedMatch));
     }
 
@@ -366,40 +339,40 @@
     @Test
     public void testRangeMatchPiMethod() {
 
-        Criterion matchPiBytes = PiCriterion.builder().matchRange(piIpv4HeaderFieldId, matchRangeBytes1,
-                matchRangeHighBytes)
+        Criterion matchPiBytes = PiCriterion.builder().matchRange(ipv4MatchFieldId, matchRangeBytes1,
+                                                                  matchRangeHighBytes)
                 .build();
         PiCriterion piCriterionBytes = checkAndConvert(matchPiBytes, Criterion.Type.PROTOCOL_INDEPENDENT,
-                PiCriterion.class);
-        PiFieldMatch expectedMatchBytes = new PiRangeFieldMatch(piIpv4HeaderFieldId, copyFrom(matchRangeBytes1),
-                copyFrom(matchRangeHighBytes));
+                                                       PiCriterion.class);
+        PiFieldMatch expectedMatchBytes = new PiRangeFieldMatch(ipv4MatchFieldId, copyFrom(matchRangeBytes1),
+                                                                copyFrom(matchRangeHighBytes));
         assertThat(piCriterionBytes.fieldMatches().iterator().next(), is(expectedMatchBytes));
 
-        Criterion matchPiShort = PiCriterion.builder().matchRange(piIpv4HeaderFieldId, matchRangeShort1,
-                matchRangeHighShort)
+        Criterion matchPiShort = PiCriterion.builder().matchRange(ipv4MatchFieldId, matchRangeShort1,
+                                                                  matchRangeHighShort)
                 .build();
         PiCriterion piCriterionShort = checkAndConvert(matchPiShort, Criterion.Type.PROTOCOL_INDEPENDENT,
-                PiCriterion.class);
-        PiFieldMatch expectedMatchShort = new PiRangeFieldMatch(piIpv4HeaderFieldId, copyFrom(matchRangeShort1),
-                copyFrom(matchRangeHighShort));
+                                                       PiCriterion.class);
+        PiFieldMatch expectedMatchShort = new PiRangeFieldMatch(ipv4MatchFieldId, copyFrom(matchRangeShort1),
+                                                                copyFrom(matchRangeHighShort));
         assertThat(piCriterionShort.fieldMatches().iterator().next(), is(expectedMatchShort));
 
-        Criterion matchPiInt = PiCriterion.builder().matchRange(piIpv4HeaderFieldId, matchRangeInt1,
-                matchRangeHighInt)
+        Criterion matchPiInt = PiCriterion.builder().matchRange(ipv4MatchFieldId, matchRangeInt1,
+                                                                matchRangeHighInt)
                 .build();
         PiCriterion piCriterionInt = checkAndConvert(matchPiInt, Criterion.Type.PROTOCOL_INDEPENDENT,
-                PiCriterion.class);
-        PiFieldMatch expectedMatchInt = new PiRangeFieldMatch(piIpv4HeaderFieldId, copyFrom(matchRangeInt1),
-                copyFrom(matchRangeHighInt));
+                                                     PiCriterion.class);
+        PiFieldMatch expectedMatchInt = new PiRangeFieldMatch(ipv4MatchFieldId, copyFrom(matchRangeInt1),
+                                                              copyFrom(matchRangeHighInt));
         assertThat(piCriterionInt.fieldMatches().iterator().next(), is(expectedMatchInt));
 
-        Criterion matchPiLong = PiCriterion.builder().matchRange(piIpv4HeaderFieldId, matchRangeLong1,
-                matchRangeHighLong)
+        Criterion matchPiLong = PiCriterion.builder().matchRange(ipv4MatchFieldId, matchRangeLong1,
+                                                                 matchRangeHighLong)
                 .build();
         PiCriterion piCriterionLong = checkAndConvert(matchPiLong, Criterion.Type.PROTOCOL_INDEPENDENT,
-                PiCriterion.class);
-        PiFieldMatch expectedMatchLong = new PiRangeFieldMatch(piIpv4HeaderFieldId, copyFrom(matchRangeLong1),
-                copyFrom(matchRangeHighLong));
+                                                      PiCriterion.class);
+        PiFieldMatch expectedMatchLong = new PiRangeFieldMatch(ipv4MatchFieldId, copyFrom(matchRangeLong1),
+                                                               copyFrom(matchRangeHighLong));
         assertThat(piCriterionLong.fieldMatches().iterator().next(), is(expectedMatchLong));
     }
 
diff --git a/core/api/src/test/java/org/onosproject/net/flow/instructions/InstructionsTest.java b/core/api/src/test/java/org/onosproject/net/flow/instructions/InstructionsTest.java
index ddf6500..68dc489 100644
--- a/core/api/src/test/java/org/onosproject/net/flow/instructions/InstructionsTest.java
+++ b/core/api/src/test/java/org/onosproject/net/flow/instructions/InstructionsTest.java
@@ -34,10 +34,10 @@
 import org.onosproject.net.flow.StatTriggerField;
 import org.onosproject.net.flow.StatTriggerFlag;
 import org.onosproject.net.meter.MeterId;
+import org.onosproject.net.pi.model.PiActionId;
+import org.onosproject.net.pi.model.PiActionParamId;
 import org.onosproject.net.pi.runtime.PiAction;
-import org.onosproject.net.pi.runtime.PiActionId;
 import org.onosproject.net.pi.runtime.PiActionParam;
-import org.onosproject.net.pi.runtime.PiActionParamId;
 import org.onosproject.net.pi.runtime.PiTableAction;
 
 import java.util.EnumMap;
diff --git a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionGroupMemberTest.java b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionGroupMemberTest.java
index c9e53ee..020d575 100644
--- a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionGroupMemberTest.java
+++ b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionGroupMemberTest.java
@@ -18,6 +18,8 @@
 
 import com.google.common.testing.EqualsTester;
 import org.junit.Test;
+import org.onosproject.net.pi.model.PiActionId;
+import org.onosproject.net.pi.model.PiActionParamId;
 
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.is;
@@ -32,22 +34,22 @@
  */
 public class PiActionGroupMemberTest {
 
-    final PiActionGroupMemberId piActionGroupMemberId = PiActionGroupMemberId.of(10);
-    final PiAction piAction = PiAction.builder().withId(PiActionId.of(MOD_NW_DST))
+    private final PiActionGroupMemberId piActionGroupMemberId = PiActionGroupMemberId.of(10);
+    private final PiAction piAction = PiAction.builder().withId(PiActionId.of(MOD_NW_DST))
             .withParameter(new PiActionParam(PiActionParamId.of(DST_ADDR), copyFrom(0x0a010101)))
             .build();
 
-    final PiActionGroupMember piActionGroupMember1 = PiActionGroupMember.builder()
+    private final PiActionGroupMember piActionGroupMember1 = PiActionGroupMember.builder()
             .withId(piActionGroupMemberId)
             .withAction(piAction)
             .withWeight(10)
             .build();
-    final PiActionGroupMember sameAsPiActionGroupMember1 = PiActionGroupMember.builder()
+    private final PiActionGroupMember sameAsPiActionGroupMember1 = PiActionGroupMember.builder()
             .withId(piActionGroupMemberId)
             .withAction(piAction)
             .withWeight(10)
             .build();
-    final PiActionGroupMember piActionGroupMember2 = PiActionGroupMember.builder()
+    private final PiActionGroupMember piActionGroupMember2 = PiActionGroupMember.builder()
             .withId(piActionGroupMemberId)
             .withAction(piAction)
             .withWeight(20)
diff --git a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionGroupTest.java b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionGroupTest.java
index 0da15e4..6672d91 100644
--- a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionGroupTest.java
+++ b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionGroupTest.java
@@ -20,6 +20,9 @@
 import com.google.common.testing.EqualsTester;
 import org.apache.commons.collections.CollectionUtils;
 import org.junit.Test;
+import org.onosproject.net.pi.model.PiActionGroupType;
+import org.onosproject.net.pi.model.PiActionId;
+import org.onosproject.net.pi.model.PiActionParamId;
 
 import java.util.Collection;
 
@@ -37,36 +40,36 @@
  */
 public class PiActionGroupTest {
 
-    final PiActionGroupMemberId piActionGroupMemberId = PiActionGroupMemberId.of(10);
-    final PiAction piAction = PiAction.builder().withId(PiActionId.of(MOD_NW_DST))
+    private final PiActionGroupMemberId piActionGroupMemberId = PiActionGroupMemberId.of(10);
+    private final PiAction piAction = PiAction.builder().withId(PiActionId.of(MOD_NW_DST))
             .withParameter(new PiActionParam(PiActionParamId.of(DST_ADDR), copyFrom(0x0a010101)))
             .build();
 
-    final PiActionGroupMember piActionGroupMember = PiActionGroupMember.builder()
+    private final PiActionGroupMember piActionGroupMember = PiActionGroupMember.builder()
             .withId(piActionGroupMemberId)
             .withAction(piAction)
             .withWeight(10)
             .build();
-    PiActionGroupId piActionGroupId = PiActionGroupId.of(10);
-    PiActionGroup piActionGroup1 = PiActionGroup.builder()
+    private PiActionGroupId piActionGroupId = PiActionGroupId.of(10);
+    private PiActionGroup piActionGroup1 = PiActionGroup.builder()
             .addMember(piActionGroupMember)
             .withId(piActionGroupId)
-            .withType(PiActionGroup.Type.SELECT)
+            .withType(PiActionGroupType.SELECT)
             .withActionProfileId(ACTION_PROF_ID)
             .build();
 
-    PiActionGroup sameAsPiActionGroup1 = PiActionGroup.builder()
+    private PiActionGroup sameAsPiActionGroup1 = PiActionGroup.builder()
             .addMember(piActionGroupMember)
             .withId(piActionGroupId)
-            .withType(PiActionGroup.Type.SELECT)
+            .withType(PiActionGroupType.SELECT)
             .withActionProfileId(ACTION_PROF_ID)
             .build();
 
-    PiActionGroupId piActionGroupId2 = PiActionGroupId.of(20);
-    PiActionGroup piActionGroup2 = PiActionGroup.builder()
+    private PiActionGroupId piActionGroupId2 = PiActionGroupId.of(20);
+    private PiActionGroup piActionGroup2 = PiActionGroup.builder()
             .addMember(piActionGroupMember)
             .withId(piActionGroupId2)
-            .withType(PiActionGroup.Type.SELECT)
+            .withType(PiActionGroupType.SELECT)
             .withActionProfileId(ACTION_PROF_ID)
             .build();
 
@@ -102,7 +105,7 @@
         piActionGroupMembers.add(piActionGroupMember);
         assertThat(piActionGroup1, is(notNullValue()));
         assertThat(piActionGroup1.id(), is(piActionGroupId));
-        assertThat(piActionGroup1.type(), is(PiActionGroup.Type.SELECT));
+        assertThat(piActionGroup1.type(), is(PiActionGroupType.SELECT));
         assertThat("Incorrect members value",
                    CollectionUtils.isEqualCollection(piActionGroup1.members(), piActionGroupMembers));
     }
diff --git a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionIdTest.java b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionIdTest.java
index 72e27af..262a50f 100644
--- a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionIdTest.java
+++ b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionIdTest.java
@@ -18,6 +18,7 @@
 
 import com.google.common.testing.EqualsTester;
 import org.junit.Test;
+import org.onosproject.net.pi.model.PiActionId;
 
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.is;
@@ -60,9 +61,8 @@
      */
     @Test
     public void testConstruction() {
-        final String id = DEC_TTL;
-        final PiActionId actionId = PiActionId.of(id);
+        final PiActionId actionId = PiActionId.of(DEC_TTL);
         assertThat(actionId, is(notNullValue()));
-        assertThat(actionId.name(), is(id));
+        assertThat(actionId.id(), is(DEC_TTL));
     }
 }
diff --git a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionParamIdTest.java b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionParamIdTest.java
index b24adf0..c2793e7 100644
--- a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionParamIdTest.java
+++ b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionParamIdTest.java
@@ -18,6 +18,7 @@
 
 import com.google.common.testing.EqualsTester;
 import org.junit.Test;
+import org.onosproject.net.pi.model.PiActionParamId;
 
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.is;
@@ -60,8 +61,8 @@
     @Test
     public void testConstruction() {
         final String param = SRC_ADDR;
-        final PiActionParamId actionParamId = PiActionParamId.of(SRC_ADDR);
+        final PiActionParamId actionParamId = PiActionParamId.of(param);
         assertThat(actionParamId, is(notNullValue()));
-        assertThat(actionParamId.name(), is(param));
+        assertThat(actionParamId.id(), is(param));
     }
 }
diff --git a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionParamTest.java b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionParamTest.java
index e8181b4..993c5e2 100644
--- a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionParamTest.java
+++ b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionParamTest.java
@@ -19,6 +19,7 @@
 import com.google.common.testing.EqualsTester;
 import org.junit.Test;
 import org.onlab.util.ImmutableByteSequence;
+import org.onosproject.net.pi.model.PiActionParamId;
 
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.is;
@@ -32,11 +33,11 @@
  * Unit tests for PiActionParam class.
  */
 public class PiActionParamTest {
-    ImmutableByteSequence value1 = copyFrom(0x0a010101);
-    ImmutableByteSequence value2 = copyFrom(0x0a010102);
-    final PiActionParam piActionParam1 = new PiActionParam(PiActionParamId.of(DST_ADDR), value1);
-    final PiActionParam sameAsPiActionParam1 = new PiActionParam(PiActionParamId.of(DST_ADDR), value1);
-    final PiActionParam piActionParam2 = new PiActionParam(PiActionParamId.of(DST_ADDR), value2);
+    private ImmutableByteSequence value1 = copyFrom(0x0a010101);
+    private ImmutableByteSequence value2 = copyFrom(0x0a010102);
+    private final PiActionParam piActionParam1 = new PiActionParam(PiActionParamId.of(DST_ADDR), value1);
+    private final PiActionParam sameAsPiActionParam1 = new PiActionParam(PiActionParamId.of(DST_ADDR), value1);
+    private final PiActionParam piActionParam2 = new PiActionParam(PiActionParamId.of(DST_ADDR), value2);
 
     /**
      * Checks that the PiActionParam class is immutable.
diff --git a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionTest.java b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionTest.java
index 86f8686..9a69ab3 100644
--- a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionTest.java
+++ b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionTest.java
@@ -19,7 +19,8 @@
 import com.google.common.collect.Lists;
 import com.google.common.testing.EqualsTester;
 import org.junit.Test;
-
+import org.onosproject.net.pi.model.PiActionId;
+import org.onosproject.net.pi.model.PiActionParamId;
 
 import java.util.Collection;
 
@@ -35,13 +36,13 @@
  * Unit tests for PiAction class.
  */
 public class PiActionTest {
-    final PiAction piAction1 = PiAction.builder().withId(PiActionId.of(MOD_NW_DST))
+    private final PiAction piAction1 = PiAction.builder().withId(PiActionId.of(MOD_NW_DST))
             .withParameter(new PiActionParam(PiActionParamId.of(DST_ADDR), copyFrom(0x0a010101)))
             .build();
-    final PiAction sameAsPiAction1 = PiAction.builder().withId(PiActionId.of(MOD_NW_DST))
+    private final PiAction sameAsPiAction1 = PiAction.builder().withId(PiActionId.of(MOD_NW_DST))
             .withParameter(new PiActionParam(PiActionParamId.of(DST_ADDR), copyFrom(0x0a010101)))
             .build();
-    final PiAction piAction2 = PiAction.builder().withId(PiActionId.of("set_egress_port_0")).build();
+    private final PiAction piAction2 = PiAction.builder().withId(PiActionId.of("set_egress_port_0")).build();
 
     /**
      * Checks that the PiAction class is immutable.
diff --git a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiConstantsTest.java b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiConstantsTest.java
index 86f713d..158baab 100644
--- a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiConstantsTest.java
+++ b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiConstantsTest.java
@@ -15,30 +15,36 @@
  */
 package org.onosproject.net.pi.runtime;
 
+import org.onosproject.net.pi.model.PiActionProfileId;
+
 /**
- * Unit tests for PiActionId class.
+ * Constants for Pi* unit tests.
  */
 public final class PiConstantsTest {
-    private PiConstantsTest() {
-    }
-    public static final String MOD_NW_DST = "mod_nw_dst";
-    public static final String DEC_TTL = "dec_ttl";
-    public static final String MOD_VLAN_VID = "mod_vlan_vid";
+
+    static final String DOT = ".";
+    static final String MOD_NW_DST = "mod_nw_dst";
+    static final String DEC_TTL = "dec_ttl";
+    static final String MOD_VLAN_VID = "mod_vlan_vid";
     public static final String DROP = "drop";
 
-    public static final String IPV4_HEADER_NAME = "ipv4_t";
-    public static final String ETH_HEADER_NAME = "ethernet_t";
-    public static final String VLAN_HEADER_NAME = "vlan_tag_t";
+    static final String IPV4_HEADER_NAME = "ipv4_t";
+    static final String ETH_HEADER_NAME = "ethernet_t";
+    static final String VLAN_HEADER_NAME = "vlan_tag_t";
 
     public static final String ETH_TYPE = "etherType";
     public static final String DST_ADDR = "dstAddr";
-    public static final String SRC_ADDR = "srcAddr";
-    public static final String VID = "vid";
+    static final String SRC_ADDR = "srcAddr";
+    static final String VID = "vid";
     public static final String PORT = "port";
 
-    public static final String EGRESS_PORT = "egress_port";
-    public static final String INGRESS_PORT = "ingress_port";
+    static final String EGRESS_PORT = "egress_port";
+    static final String INGRESS_PORT = "ingress_port";
 
-    public static final PiActionProfileId ACTION_PROF_ID =
+    static final PiActionProfileId ACTION_PROF_ID =
             PiActionProfileId.of("Test action profile");
+
+    private PiConstantsTest() {
+        // Hides constructor.
+    }
 }
diff --git a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiPacketMetadataIdTest.java b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiControlMetadataIdTest.java
similarity index 62%
rename from core/api/src/test/java/org/onosproject/net/pi/runtime/PiPacketMetadataIdTest.java
rename to core/api/src/test/java/org/onosproject/net/pi/runtime/PiControlMetadataIdTest.java
index a2ee50f..d65ef2e 100644
--- a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiPacketMetadataIdTest.java
+++ b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiControlMetadataIdTest.java
@@ -18,6 +18,7 @@
 
 import com.google.common.testing.EqualsTester;
 import org.junit.Test;
+import org.onosproject.net.pi.model.PiControlMetadataId;
 
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.is;
@@ -27,21 +28,21 @@
 import static org.onosproject.net.pi.runtime.PiConstantsTest.INGRESS_PORT;
 
 /**
- * Unit tests for PiPacketMetadataId class.
+ * Unit tests for PiControlMetadataId class.
  */
-public class PiPacketMetadataIdTest {
+public class PiControlMetadataIdTest {
 
-    final PiPacketMetadataId piPacketMetadataId1 = PiPacketMetadataId.of(EGRESS_PORT);
-    final PiPacketMetadataId sameAsPiPacketMetadataId1 = PiPacketMetadataId.of(EGRESS_PORT);
-    final PiPacketMetadataId piPacketMetadataId2 = PiPacketMetadataId.of(INGRESS_PORT);
+    final PiControlMetadataId piControlMetadataId1 = PiControlMetadataId.of(EGRESS_PORT);
+    final PiControlMetadataId sameAsPiControlMetadataId1 = PiControlMetadataId.of(EGRESS_PORT);
+    final PiControlMetadataId piControlMetadataId2 = PiControlMetadataId.of(INGRESS_PORT);
 
     /**
-     * Checks that the PiPacketMetadataId class is immutable.
+     * Checks that the PiControlMetadataId class is immutable.
      */
     @Test
     public void testImmutability() {
 
-        assertThatClassIsImmutable(PiPacketMetadataId.class);
+        assertThatClassIsImmutable(PiControlMetadataId.class);
     }
 
     /**
@@ -51,18 +52,17 @@
     public void testEquals() {
 
         new EqualsTester()
-                .addEqualityGroup(piPacketMetadataId1, sameAsPiPacketMetadataId1)
-                .addEqualityGroup(piPacketMetadataId2)
+                .addEqualityGroup(piControlMetadataId1, sameAsPiControlMetadataId1)
+                .addEqualityGroup(piControlMetadataId2)
                 .testEquals();
     }
 
     /**
-     * Checks the methods of PiPacketMetadataId.
+     * Checks the methods of PiControlMetadataId.
      */
     @Test
     public void testMethods() {
-
-        assertThat(piPacketMetadataId1, is(notNullValue()));
-        assertThat(piPacketMetadataId1.name(), is(EGRESS_PORT));
+        assertThat(piControlMetadataId1, is(notNullValue()));
+        assertThat(piControlMetadataId1.id(), is(EGRESS_PORT));
     }
 }
diff --git a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiControlMetadataTest.java b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiControlMetadataTest.java
new file mode 100644
index 0000000..ab80fd6
--- /dev/null
+++ b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiControlMetadataTest.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.net.pi.runtime;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+import org.onosproject.net.pi.model.PiControlMetadataId;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
+import static org.onlab.util.ImmutableByteSequence.copyFrom;
+import static org.onosproject.net.pi.runtime.PiConstantsTest.EGRESS_PORT;
+
+/**
+ * Unit tests for PiControlMetadata class.
+ */
+public class PiControlMetadataTest {
+
+    final PiControlMetadataId piControlMetadataId = PiControlMetadataId.of(EGRESS_PORT);
+
+    final PiControlMetadata piControlMetadata1 = PiControlMetadata.builder()
+            .withId(piControlMetadataId)
+            .withValue(copyFrom(0x10))
+            .build();
+    final PiControlMetadata sameAsPiControlMetadata1 = PiControlMetadata.builder()
+            .withId(piControlMetadataId)
+            .withValue(copyFrom(0x10))
+            .build();
+    final PiControlMetadata piControlMetadata2 = PiControlMetadata.builder()
+            .withId(piControlMetadataId)
+            .withValue(copyFrom(0x20))
+            .build();
+
+    /**
+     * Checks that the PiControlMetadata class is immutable.
+     */
+    @Test
+    public void testImmutability() {
+
+        assertThatClassIsImmutable(PiControlMetadata.class);
+    }
+
+    /**
+     * Checks the operation of equals(), hashCode() and toString() methods.
+     */
+    @Test
+    public void testEquals() {
+
+        new EqualsTester()
+                .addEqualityGroup(piControlMetadata1, sameAsPiControlMetadata1)
+                .addEqualityGroup(piControlMetadata2)
+                .testEquals();
+    }
+
+    /**
+     * Checks the methods of PiControlMetadata.
+     */
+    @Test
+    public void testMethods() {
+
+        assertThat(piControlMetadata1, is(notNullValue()));
+        assertThat(piControlMetadata1.id(), is(PiControlMetadataId.of(EGRESS_PORT)));
+        assertThat(piControlMetadata1.value(), is(copyFrom(0x10)));
+    }
+}
diff --git a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiExactFieldMatchTest.java b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiExactFieldMatchTest.java
index af331c6..38b6765 100644
--- a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiExactFieldMatchTest.java
+++ b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiExactFieldMatchTest.java
@@ -19,6 +19,7 @@
 import com.google.common.testing.EqualsTester;
 import org.junit.Test;
 import org.onlab.util.ImmutableByteSequence;
+import org.onosproject.net.pi.model.PiMatchFieldId;
 import org.onosproject.net.pi.model.PiMatchType;
 
 import static org.hamcrest.MatcherAssert.assertThat;
@@ -26,6 +27,7 @@
 import static org.hamcrest.Matchers.notNullValue;
 import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
 import static org.onlab.util.ImmutableByteSequence.copyFrom;
+import static org.onosproject.net.pi.runtime.PiConstantsTest.DOT;
 import static org.onosproject.net.pi.runtime.PiConstantsTest.ETH_HEADER_NAME;
 import static org.onosproject.net.pi.runtime.PiConstantsTest.ETH_TYPE;
 
@@ -33,12 +35,13 @@
  * Unit tests for PiExactFieldMatch class.
  */
 public class PiExactFieldMatchTest {
-    final ImmutableByteSequence value1 = copyFrom(0x0800);
-    final ImmutableByteSequence value2 = copyFrom(0x0806);
-    final PiHeaderFieldId piHeaderField = PiHeaderFieldId.of(ETH_HEADER_NAME, ETH_TYPE);
-    PiExactFieldMatch piExactFieldMatch1 = new PiExactFieldMatch(piHeaderField, value1);
-    PiExactFieldMatch sameAsPiExactFieldMatch1 = new PiExactFieldMatch(piHeaderField, value1);
-    PiExactFieldMatch piExactFieldMatch2 = new PiExactFieldMatch(piHeaderField, value2);
+
+    private final ImmutableByteSequence value1 = copyFrom(0x0800);
+    private final ImmutableByteSequence value2 = copyFrom(0x0806);
+    private final PiMatchFieldId piMatchField = PiMatchFieldId.of(ETH_HEADER_NAME + DOT + ETH_TYPE);
+    private PiExactFieldMatch piExactFieldMatch1 = new PiExactFieldMatch(piMatchField, value1);
+    private PiExactFieldMatch sameAsPiExactFieldMatch1 = new PiExactFieldMatch(piMatchField, value1);
+    private PiExactFieldMatch piExactFieldMatch2 = new PiExactFieldMatch(piMatchField, value2);
 
     /**
      * Checks that the PiExactFieldMatch class is immutable.
@@ -65,8 +68,8 @@
     @Test
     public void testConstruction() {
         final ImmutableByteSequence value = copyFrom(0x0806);
-        final PiHeaderFieldId piHeaderField = PiHeaderFieldId.of(ETH_HEADER_NAME, ETH_TYPE);
-        PiExactFieldMatch piExactFieldMatch = new PiExactFieldMatch(piHeaderField, value);
+        final PiMatchFieldId piMatchField = PiMatchFieldId.of(ETH_HEADER_NAME + DOT + ETH_TYPE);
+        PiExactFieldMatch piExactFieldMatch = new PiExactFieldMatch(piMatchField, value);
         assertThat(piExactFieldMatch, is(notNullValue()));
         assertThat(piExactFieldMatch.value(), is(value));
         assertThat(piExactFieldMatch.type(), is(PiMatchType.EXACT));
diff --git a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiFieldMatchTest.java b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiFieldMatchTest.java
index 89f9442..2e63d45 100644
--- a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiFieldMatchTest.java
+++ b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiFieldMatchTest.java
@@ -17,11 +17,13 @@
 package org.onosproject.net.pi.runtime;
 
 import org.junit.Test;
+import org.onosproject.net.pi.model.PiMatchFieldId;
 import org.onosproject.net.pi.model.PiMatchType;
 
 import static org.junit.Assert.assertEquals;
 import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutableBaseClass;
 import static org.onlab.util.ImmutableByteSequence.copyFrom;
+import static org.onosproject.net.pi.runtime.PiConstantsTest.DOT;
 import static org.onosproject.net.pi.runtime.PiConstantsTest.ETH_HEADER_NAME;
 import static org.onosproject.net.pi.runtime.PiConstantsTest.ETH_TYPE;
 
@@ -41,10 +43,10 @@
 
     @Test
     public void basics() {
-        final PiHeaderFieldId piHeaderField = PiHeaderFieldId.of(ETH_HEADER_NAME, ETH_TYPE);
-        PiFieldMatch piFieldMatch = new PiExactFieldMatch(piHeaderField, copyFrom(0x0806));
+        final PiMatchFieldId piMatchField = PiMatchFieldId.of(ETH_HEADER_NAME + DOT + ETH_TYPE);
+        PiFieldMatch piFieldMatch = new PiExactFieldMatch(piMatchField, copyFrom(0x0806));
 
-        assertEquals(piFieldMatch.fieldId(), piHeaderField);
+        assertEquals(piFieldMatch.fieldId(), piMatchField);
         assertEquals(piFieldMatch.type(), PiMatchType.EXACT);
     }
 }
diff --git a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiHeaderFieldIdTest.java b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiHeaderFieldIdTest.java
deleted file mode 100644
index 8521d5c..0000000
--- a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiHeaderFieldIdTest.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.net.pi.runtime;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-import static org.onosproject.net.pi.runtime.PiConstantsTest.DST_ADDR;
-import static org.onosproject.net.pi.runtime.PiConstantsTest.ETH_HEADER_NAME;
-import static org.onosproject.net.pi.runtime.PiConstantsTest.ETH_TYPE;
-import static org.onosproject.net.pi.runtime.PiConstantsTest.IPV4_HEADER_NAME;
-
-/**
- * Unit tests for PiHeaderFieldId class.
- */
-public class PiHeaderFieldIdTest {
-    final String headerName = ETH_HEADER_NAME;
-    final String dstAddr = DST_ADDR;
-    final String etherType = ETH_TYPE;
-
-    final PiHeaderFieldId piHeaderFieldId1 = PiHeaderFieldId.of(headerName, dstAddr);
-    final PiHeaderFieldId sameAsPiHeaderFieldId1 = PiHeaderFieldId.of(headerName, dstAddr);
-    final PiHeaderFieldId piHeaderFieldId2 = PiHeaderFieldId.of(headerName, etherType);
-
-    int index = 10;
-    final PiHeaderFieldId piHeaderFieldId1WithIndex = PiHeaderFieldId.of(headerName, dstAddr, index);
-    final PiHeaderFieldId sameAsPiHeaderFieldId1WithIndex = PiHeaderFieldId.of(headerName, dstAddr, index);
-    final PiHeaderFieldId piHeaderFieldId2WithIndex = PiHeaderFieldId.of(headerName, etherType, index);
-
-    /**
-     * Checks that the PiHeaderFieldId class is immutable.
-     */
-    @Test
-    public void testImmutability() {
-        assertThatClassIsImmutable(PiHeaderFieldId.class);
-    }
-
-    /**
-     * Checks the operation of equals(), hashCode() and toString() methods.
-     */
-    @Test
-    public void testEquals() {
-        new EqualsTester()
-                .addEqualityGroup(piHeaderFieldId1, sameAsPiHeaderFieldId1)
-                .addEqualityGroup(piHeaderFieldId2)
-                .testEquals();
-    }
-
-    /**
-     * Checks the operation of equals(), hashCode() and toString() methods.
-     */
-    @Test
-    public void testEqualsWithIndex() {
-        new EqualsTester()
-                .addEqualityGroup(piHeaderFieldId1WithIndex, sameAsPiHeaderFieldId1WithIndex)
-                .addEqualityGroup(piHeaderFieldId2WithIndex)
-                .testEquals();
-    }
-
-    /**
-     * Checks the construction of a PiHeaderFieldId object.
-     */
-    @Test
-    public void testConstruction() {
-        final String name = IPV4_HEADER_NAME;
-        final String field = DST_ADDR;
-
-        final PiHeaderFieldId piHeaderFieldId = PiHeaderFieldId.of(name, field);
-        assertThat(piHeaderFieldId, is(notNullValue()));
-        assertThat(piHeaderFieldId.headerName(), is(name));
-        assertThat(piHeaderFieldId.fieldName(), is(field));
-    }
-
-    /**
-     * Checks the construction of a PiHeaderFieldId object with index.
-     */
-    @Test
-    public void testConstructionWithIndex() {
-        final String name = IPV4_HEADER_NAME;
-        final String field = DST_ADDR;
-        final int index = 1;
-        final PiHeaderFieldId piHeaderFieldId = PiHeaderFieldId.of(name, field, index);
-        assertThat(piHeaderFieldId, is(notNullValue()));
-        assertThat(piHeaderFieldId.headerName(), is(name));
-        assertThat(piHeaderFieldId.fieldName(), is(field));
-        assertThat(piHeaderFieldId.index(), is(index));
-    }
-}
diff --git a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiLpmFieldMatchTest.java b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiLpmFieldMatchTest.java
index a25c434..8257fcc 100644
--- a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiLpmFieldMatchTest.java
+++ b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiLpmFieldMatchTest.java
@@ -19,6 +19,7 @@
 import com.google.common.testing.EqualsTester;
 import org.junit.Test;
 import org.onlab.util.ImmutableByteSequence;
+import org.onosproject.net.pi.model.PiMatchFieldId;
 import org.onosproject.net.pi.model.PiMatchType;
 
 import static org.hamcrest.MatcherAssert.assertThat;
@@ -26,6 +27,7 @@
 import static org.hamcrest.Matchers.notNullValue;
 import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
 import static org.onlab.util.ImmutableByteSequence.copyFrom;
+import static org.onosproject.net.pi.runtime.PiConstantsTest.DOT;
 import static org.onosproject.net.pi.runtime.PiConstantsTest.DST_ADDR;
 import static org.onosproject.net.pi.runtime.PiConstantsTest.IPV4_HEADER_NAME;
 
@@ -33,13 +35,13 @@
  * Unit tests for PiLpmFieldMatch class.
  */
 public class PiLpmFieldMatchTest {
-    final ImmutableByteSequence value1 = copyFrom(0x0a010101);
-    final ImmutableByteSequence value2 = copyFrom(0x0a010102);
-    int prefixLength = 24;
-    final PiHeaderFieldId piHeaderField = PiHeaderFieldId.of(IPV4_HEADER_NAME, DST_ADDR);
-    PiLpmFieldMatch piLpmFieldMatch1 = new PiLpmFieldMatch(piHeaderField, value1, prefixLength);
-    PiLpmFieldMatch sameAsPiLpmFieldMatch1 = new PiLpmFieldMatch(piHeaderField, value1, prefixLength);
-    PiLpmFieldMatch piLpmFieldMatch2 = new PiLpmFieldMatch(piHeaderField, value2, prefixLength);
+    private final ImmutableByteSequence value1 = copyFrom(0x0a010101);
+    private final ImmutableByteSequence value2 = copyFrom(0x0a010102);
+    private int prefixLength = 24;
+    private final PiMatchFieldId piMatchField = PiMatchFieldId.of(IPV4_HEADER_NAME + DOT + DST_ADDR);
+    private PiLpmFieldMatch piLpmFieldMatch1 = new PiLpmFieldMatch(piMatchField, value1, prefixLength);
+    private PiLpmFieldMatch sameAsPiLpmFieldMatch1 = new PiLpmFieldMatch(piMatchField, value1, prefixLength);
+    private PiLpmFieldMatch piLpmFieldMatch2 = new PiLpmFieldMatch(piMatchField, value2, prefixLength);
 
     /**
      * Checks that the PiLpmFieldMatch class is immutable.
@@ -67,8 +69,8 @@
     public void testConstruction() {
         final ImmutableByteSequence value = copyFrom(0x0a01010a);
         int prefix = 24;
-        final PiHeaderFieldId piHeaderField = PiHeaderFieldId.of(IPV4_HEADER_NAME, DST_ADDR);
-        PiLpmFieldMatch piLpmFieldMatch = new PiLpmFieldMatch(piHeaderField, value, prefix);
+        final PiMatchFieldId piMatchField = PiMatchFieldId.of(IPV4_HEADER_NAME + DOT + DST_ADDR);
+        PiLpmFieldMatch piLpmFieldMatch = new PiLpmFieldMatch(piMatchField, value, prefix);
         assertThat(piLpmFieldMatch, is(notNullValue()));
         assertThat(piLpmFieldMatch.value(), is(value));
         assertThat(piLpmFieldMatch.prefixLength(), is(prefix));
diff --git a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiMatchFieldIdTest.java b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiMatchFieldIdTest.java
new file mode 100644
index 0000000..2724da0
--- /dev/null
+++ b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiMatchFieldIdTest.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.net.pi.runtime;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+import org.onosproject.net.pi.model.PiMatchFieldId;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
+import static org.onosproject.net.pi.runtime.PiConstantsTest.DOT;
+import static org.onosproject.net.pi.runtime.PiConstantsTest.DST_ADDR;
+import static org.onosproject.net.pi.runtime.PiConstantsTest.ETH_HEADER_NAME;
+import static org.onosproject.net.pi.runtime.PiConstantsTest.ETH_TYPE;
+import static org.onosproject.net.pi.runtime.PiConstantsTest.IPV4_HEADER_NAME;
+
+/**
+ * Unit tests for PiMatchFieldId class.
+ */
+public class PiMatchFieldIdTest {
+    private final String headerName = ETH_HEADER_NAME;
+    private final String dstAddr = DST_ADDR;
+    private final String etherType = ETH_TYPE;
+
+    private final PiMatchFieldId piMatchFieldId1 = PiMatchFieldId.of(headerName + DOT + dstAddr);
+    private final PiMatchFieldId sameAsPiMatchFieldId1 = PiMatchFieldId.of(headerName + DOT + dstAddr);
+    private final PiMatchFieldId piMatchFieldId2 = PiMatchFieldId.of(headerName + DOT + etherType);
+
+    private int index = 10;
+    private final PiMatchFieldId piMatchFieldId1WithIndex = PiMatchFieldId
+            .of(headerName + DOT + dstAddr + "[" + index + "]");
+    private final PiMatchFieldId sameAsPiMatchFieldId1WithIndex = PiMatchFieldId
+            .of(headerName + DOT + dstAddr + "[" + index + "]");
+    private final PiMatchFieldId piMatchFieldId2WithIndex = PiMatchFieldId
+            .of(headerName + DOT + etherType + "[" + index + "]");
+
+    /**
+     * Checks that the PiMatchFieldId class is immutable.
+     */
+    @Test
+    public void testImmutability() {
+        assertThatClassIsImmutable(PiMatchFieldId.class);
+    }
+
+    /**
+     * Checks the operation of equals(), hashCode() and toString() methods.
+     */
+    @Test
+    public void testEquals() {
+        new EqualsTester()
+                .addEqualityGroup(piMatchFieldId1, sameAsPiMatchFieldId1)
+                .addEqualityGroup(piMatchFieldId2)
+                .testEquals();
+    }
+
+    /**
+     * Checks the operation of equals(), hashCode() and toString() methods.
+     */
+    @Test
+    public void testEqualsWithIndex() {
+        new EqualsTester()
+                .addEqualityGroup(piMatchFieldId1WithIndex, sameAsPiMatchFieldId1WithIndex)
+                .addEqualityGroup(piMatchFieldId2WithIndex)
+                .testEquals();
+    }
+
+    /**
+     * Checks the construction of a PiMatchFieldId object.
+     */
+    @Test
+    public void testConstruction() {
+        final String name = IPV4_HEADER_NAME  + DOT + DST_ADDR;
+        final PiMatchFieldId piMatchFieldId = PiMatchFieldId.of(name);
+        assertThat(piMatchFieldId, is(notNullValue()));
+        assertThat(piMatchFieldId.id(), is(name));
+    }
+
+    /**
+     * Checks the construction of a PiMatchFieldId object with index.
+     */
+    @Test
+    public void testConstructionWithIndex() {
+        final String name = IPV4_HEADER_NAME + DOT + DST_ADDR + "[1]";
+        final PiMatchFieldId piMatchFieldId = PiMatchFieldId.of(name);
+        assertThat(piMatchFieldId, is(notNullValue()));
+        assertThat(piMatchFieldId.id(), is(name));
+    }
+}
diff --git a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiMatchKeyTest.java b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiMatchKeyTest.java
index ea866fa..a6d62af 100644
--- a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiMatchKeyTest.java
+++ b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiMatchKeyTest.java
@@ -21,6 +21,7 @@
 import org.apache.commons.collections.CollectionUtils;
 import org.junit.Test;
 import org.onlab.util.ImmutableByteSequence;
+import org.onosproject.net.pi.model.PiMatchFieldId;
 
 import java.util.Collection;
 
@@ -29,6 +30,7 @@
 import static org.hamcrest.Matchers.notNullValue;
 import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
 import static org.onlab.util.ImmutableByteSequence.copyFrom;
+import static org.onosproject.net.pi.runtime.PiConstantsTest.DOT;
 import static org.onosproject.net.pi.runtime.PiConstantsTest.DST_ADDR;
 import static org.onosproject.net.pi.runtime.PiConstantsTest.IPV4_HEADER_NAME;
 import static org.onosproject.net.pi.runtime.PiConstantsTest.SRC_ADDR;
@@ -38,21 +40,21 @@
  */
 public class PiMatchKeyTest {
 
-    final ImmutableByteSequence value1 = copyFrom(0x0a010101);
-    final ImmutableByteSequence value2 = copyFrom(0x0a010102);
-    int prefixLength = 24;
-    final PiHeaderFieldId piHeaderField1 = PiHeaderFieldId.of(IPV4_HEADER_NAME, SRC_ADDR);
-    final PiHeaderFieldId piHeaderField2 = PiHeaderFieldId.of(IPV4_HEADER_NAME, DST_ADDR);
-    PiLpmFieldMatch piLpmFieldMatch1 = new PiLpmFieldMatch(piHeaderField1, value1, prefixLength);
-    PiLpmFieldMatch piLpmFieldMatch2 = new PiLpmFieldMatch(piHeaderField2, value2, prefixLength);
+    private final ImmutableByteSequence value1 = copyFrom(0x0a010101);
+    private final ImmutableByteSequence value2 = copyFrom(0x0a010102);
+    private int prefixLength = 24;
+    private final PiMatchFieldId piMatchField1 = PiMatchFieldId.of(IPV4_HEADER_NAME + DOT + SRC_ADDR);
+    private final PiMatchFieldId piMatchField2 = PiMatchFieldId.of(IPV4_HEADER_NAME + DOT + DST_ADDR);
+    private PiLpmFieldMatch piLpmFieldMatch1 = new PiLpmFieldMatch(piMatchField1, value1, prefixLength);
+    private PiLpmFieldMatch piLpmFieldMatch2 = new PiLpmFieldMatch(piMatchField2, value2, prefixLength);
 
-    final PiMatchKey piMatchKey1 = PiMatchKey.builder()
+    private final PiMatchKey piMatchKey1 = PiMatchKey.builder()
             .addFieldMatch(piLpmFieldMatch1)
             .build();
-    final PiMatchKey sameAsPiMatchKey1 = PiMatchKey.builder()
+    private final PiMatchKey sameAsPiMatchKey1 = PiMatchKey.builder()
             .addFieldMatch(piLpmFieldMatch1)
             .build();
-    final PiMatchKey piMatchKey2 = PiMatchKey.builder()
+    private final PiMatchKey piMatchKey2 = PiMatchKey.builder()
             .addFieldMatch(piLpmFieldMatch2)
             .build();
 
diff --git a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiPacketMetadataTest.java b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiPacketMetadataTest.java
deleted file mode 100644
index 8ba4d4e..0000000
--- a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiPacketMetadataTest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.net.pi.runtime;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-import static org.onlab.util.ImmutableByteSequence.copyFrom;
-import static org.onosproject.net.pi.runtime.PiConstantsTest.EGRESS_PORT;
-
-/**
- * Unit tests for PiPacketMetadata class.
- */
-public class PiPacketMetadataTest {
-
-    final PiPacketMetadataId piPacketMetadataId = PiPacketMetadataId.of(EGRESS_PORT);
-
-    final PiPacketMetadata piPacketMetadata1 = PiPacketMetadata.builder()
-            .withId(piPacketMetadataId)
-            .withValue(copyFrom(0x10))
-            .build();
-    final PiPacketMetadata sameAsPiPacketMetadata1 = PiPacketMetadata.builder()
-            .withId(piPacketMetadataId)
-            .withValue(copyFrom(0x10))
-            .build();
-    final PiPacketMetadata piPacketMetadata2 = PiPacketMetadata.builder()
-            .withId(piPacketMetadataId)
-            .withValue(copyFrom(0x20))
-            .build();
-
-    /**
-     * Checks that the PiPacketMetadata class is immutable.
-     */
-    @Test
-    public void testImmutability() {
-
-        assertThatClassIsImmutable(PiPacketMetadata.class);
-    }
-
-    /**
-     * Checks the operation of equals(), hashCode() and toString() methods.
-     */
-    @Test
-    public void testEquals() {
-
-        new EqualsTester()
-                .addEqualityGroup(piPacketMetadata1, sameAsPiPacketMetadata1)
-                .addEqualityGroup(piPacketMetadata2)
-                .testEquals();
-    }
-
-    /**
-     * Checks the methods of PiPacketMetadata.
-     */
-    @Test
-    public void testMethods() {
-
-        assertThat(piPacketMetadata1, is(notNullValue()));
-        assertThat(piPacketMetadata1.id(), is(PiPacketMetadataId.of(EGRESS_PORT)));
-        assertThat(piPacketMetadata1.value(), is(copyFrom(0x10)));
-    }
-}
diff --git a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiPacketOperationTest.java b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiPacketOperationTest.java
index 619099f..d675b51 100644
--- a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiPacketOperationTest.java
+++ b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiPacketOperationTest.java
@@ -21,43 +21,50 @@
 import org.apache.commons.collections.CollectionUtils;
 import org.junit.Test;
 import org.onlab.util.ImmutableByteSequence;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.pi.model.PiControlMetadataId;
 
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.is;
 import static org.hamcrest.Matchers.notNullValue;
 import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
 import static org.onlab.util.ImmutableByteSequence.copyFrom;
+import static org.onosproject.net.pi.model.PiPacketOperationType.PACKET_OUT;
 import static org.onosproject.net.pi.runtime.PiConstantsTest.EGRESS_PORT;
-import static org.onosproject.net.pi.runtime.PiPacketOperation.Type.PACKET_OUT;
 
 /**
  * Unit tests for PiPacketOperation class.
  */
 public class PiPacketOperationTest {
 
-    final PiPacketOperation piPacketOperation1 = PiPacketOperation.builder()
+    private final DeviceId deviceId = DeviceId.deviceId("dummy");
+
+    private final PiPacketOperation piPacketOperation1 = PiPacketOperation.builder()
+            .forDevice(deviceId)
             .withData(ImmutableByteSequence.ofOnes(512))
             .withType(PACKET_OUT)
-            .withMetadata(PiPacketMetadata.builder()
-                                  .withId(PiPacketMetadataId.of(EGRESS_PORT))
+            .withMetadata(PiControlMetadata.builder()
+                                  .withId(PiControlMetadataId.of(EGRESS_PORT))
                                   .withValue(copyFrom((short) 255))
                                   .build())
             .build();
 
-    final PiPacketOperation sameAsPiPacketOperation1 = PiPacketOperation.builder()
+    private final PiPacketOperation sameAsPiPacketOperation1 = PiPacketOperation.builder()
+            .forDevice(deviceId)
             .withData(ImmutableByteSequence.ofOnes(512))
             .withType(PACKET_OUT)
-            .withMetadata(PiPacketMetadata.builder()
-                                  .withId(PiPacketMetadataId.of(EGRESS_PORT))
+            .withMetadata(PiControlMetadata.builder()
+                                  .withId(PiControlMetadataId.of(EGRESS_PORT))
                                   .withValue(copyFrom((short) 255))
                                   .build())
             .build();
 
-    final PiPacketOperation piPacketOperation2 = PiPacketOperation.builder()
+    private final PiPacketOperation piPacketOperation2 = PiPacketOperation.builder()
+            .forDevice(deviceId)
             .withData(ImmutableByteSequence.ofOnes(512))
             .withType(PACKET_OUT)
-            .withMetadata(PiPacketMetadata.builder()
-                                  .withId(PiPacketMetadataId.of(EGRESS_PORT))
+            .withMetadata(PiControlMetadata.builder()
+                                  .withId(PiControlMetadataId.of(EGRESS_PORT))
                                   .withValue(copyFrom((short) 200))
                                   .build())
             .build();
@@ -90,21 +97,23 @@
     public void testMethods() {
 
         final PiPacketOperation piPacketOperation = PiPacketOperation.builder()
+                .forDevice(deviceId)
                 .withData(ImmutableByteSequence.ofOnes(512))
                 .withType(PACKET_OUT)
-                .withMetadata(PiPacketMetadata.builder()
-                                      .withId(PiPacketMetadataId.of(EGRESS_PORT))
+                .withMetadata(PiControlMetadata.builder()
+                                      .withId(PiControlMetadataId.of(EGRESS_PORT))
                                       .withValue(copyFrom((short) 10))
                                       .build())
                 .build();
 
         assertThat(piPacketOperation, is(notNullValue()));
+        assertThat(piPacketOperation.deviceId(), is(deviceId));
         assertThat(piPacketOperation.type(), is(PACKET_OUT));
         assertThat(piPacketOperation.data(), is(ImmutableByteSequence.ofOnes(512)));
         assertThat("Incorrect metadatas value",
                    CollectionUtils.isEqualCollection(piPacketOperation.metadatas(),
-                                                     ImmutableList.of(PiPacketMetadata.builder()
-                                                                              .withId(PiPacketMetadataId
+                                                     ImmutableList.of(PiControlMetadata.builder()
+                                                                              .withId(PiControlMetadataId
                                                                                               .of(EGRESS_PORT))
                                                                               .withValue(copyFrom((short) 10))
                                                                               .build())));
diff --git a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiRangeFieldMatchTest.java b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiRangeFieldMatchTest.java
index 27c551c..7fb28b9 100644
--- a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiRangeFieldMatchTest.java
+++ b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiRangeFieldMatchTest.java
@@ -19,6 +19,7 @@
 import com.google.common.testing.EqualsTester;
 import org.junit.Test;
 import org.onlab.util.ImmutableByteSequence;
+import org.onosproject.net.pi.model.PiMatchFieldId;
 import org.onosproject.net.pi.model.PiMatchType;
 
 import static org.hamcrest.MatcherAssert.assertThat;
@@ -26,6 +27,7 @@
 import static org.hamcrest.Matchers.notNullValue;
 import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
 import static org.onlab.util.ImmutableByteSequence.copyFrom;
+import static org.onosproject.net.pi.runtime.PiConstantsTest.DOT;
 import static org.onosproject.net.pi.runtime.PiConstantsTest.VID;
 import static org.onosproject.net.pi.runtime.PiConstantsTest.VLAN_HEADER_NAME;
 
@@ -33,15 +35,15 @@
  * Unit tests for PiRangeFieldMatch class.
  */
 public class PiRangeFieldMatchTest {
-    final ImmutableByteSequence high1 = copyFrom(0x10);
-    final ImmutableByteSequence low1 = copyFrom(0x00);
-    final ImmutableByteSequence high2 = copyFrom(0x30);
-    final ImmutableByteSequence low2 = copyFrom(0x40);
+    private final ImmutableByteSequence high1 = copyFrom(0x10);
+    private final ImmutableByteSequence low1 = copyFrom(0x00);
+    private final ImmutableByteSequence high2 = copyFrom(0x30);
+    private final ImmutableByteSequence low2 = copyFrom(0x40);
 
-    final PiHeaderFieldId piHeaderField = PiHeaderFieldId.of(VLAN_HEADER_NAME, VID);
-    PiRangeFieldMatch piRangeFieldMatch1 = new PiRangeFieldMatch(piHeaderField, low1, high1);
-    PiRangeFieldMatch sameAsPiRangeFieldMatch1 = new PiRangeFieldMatch(piHeaderField, low1, high1);
-    PiRangeFieldMatch piRangeFieldMatch2 = new PiRangeFieldMatch(piHeaderField, low2, high2);
+    private final PiMatchFieldId piMatchField = PiMatchFieldId.of(VLAN_HEADER_NAME + DOT + VID);
+    private PiRangeFieldMatch piRangeFieldMatch1 = new PiRangeFieldMatch(piMatchField, low1, high1);
+    private PiRangeFieldMatch sameAsPiRangeFieldMatch1 = new PiRangeFieldMatch(piMatchField, low1, high1);
+    private PiRangeFieldMatch piRangeFieldMatch2 = new PiRangeFieldMatch(piMatchField, low2, high2);
 
     /**
      * Checks that the PiRangeFieldMatch class is immutable.
@@ -69,8 +71,8 @@
     public void testConstruction() {
         final ImmutableByteSequence high = copyFrom(0x50);
         final ImmutableByteSequence low = copyFrom(0x00);
-        final PiHeaderFieldId piHeaderField = PiHeaderFieldId.of(VLAN_HEADER_NAME, VID);
-        PiRangeFieldMatch piRangeFieldMatch = new PiRangeFieldMatch(piHeaderField, low, high);
+        final PiMatchFieldId piMatchField = PiMatchFieldId.of(VLAN_HEADER_NAME + DOT + VID);
+        PiRangeFieldMatch piRangeFieldMatch = new PiRangeFieldMatch(piMatchField, low, high);
         assertThat(piRangeFieldMatch, is(notNullValue()));
         assertThat(piRangeFieldMatch.lowValue(), is(low));
         assertThat(piRangeFieldMatch.highValue(), is(high));
diff --git a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiTableEntryTest.java b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiTableEntryTest.java
index 6caa63c..0b451e8 100644
--- a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiTableEntryTest.java
+++ b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiTableEntryTest.java
@@ -21,13 +21,19 @@
 import org.apache.commons.collections.CollectionUtils;
 import org.junit.Test;
 import org.onlab.util.ImmutableByteSequence;
+import org.onosproject.net.pi.model.PiActionId;
+import org.onosproject.net.pi.model.PiMatchFieldId;
+import org.onosproject.net.pi.model.PiTableId;
 
 import java.util.Map;
 
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.is;
 import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-import static org.onosproject.net.pi.runtime.PiConstantsTest.*;
+import static org.onosproject.net.pi.runtime.PiConstantsTest.DOT;
+import static org.onosproject.net.pi.runtime.PiConstantsTest.DROP;
+import static org.onosproject.net.pi.runtime.PiConstantsTest.DST_ADDR;
+import static org.onosproject.net.pi.runtime.PiConstantsTest.IPV4_HEADER_NAME;
 
 /**
  * Unit tests for PiTableEntry class.
@@ -94,11 +100,11 @@
         long cookie = 0xfff0323;
         int priority = 100;
         double timeout = 1000;
-        PiHeaderFieldId piHeaderFieldId = PiHeaderFieldId.of(IPV4_HEADER_NAME, DST_ADDR);
-        PiFieldMatch piFieldMatch = new PiExactFieldMatch(piHeaderFieldId, ImmutableByteSequence.copyFrom(0x0a010101));
+        PiMatchFieldId piMatchFieldId = PiMatchFieldId.of(IPV4_HEADER_NAME + DOT + DST_ADDR);
+        PiFieldMatch piFieldMatch = new PiExactFieldMatch(piMatchFieldId, ImmutableByteSequence.copyFrom(0x0a010101));
         PiAction piAction = PiAction.builder().withId(PiActionId.of(DROP)).build();
-        final Map<PiHeaderFieldId, PiFieldMatch> fieldMatches = Maps.newHashMap();
-        fieldMatches.put(piHeaderFieldId, piFieldMatch);
+        final Map<PiMatchFieldId, PiFieldMatch> fieldMatches = Maps.newHashMap();
+        fieldMatches.put(piMatchFieldId, piFieldMatch);
         final PiTableEntry piTableEntry = PiTableEntry.builder()
                 .forTable(piTableId)
                 .withMatchKey(PiMatchKey.builder()
@@ -112,6 +118,8 @@
 
         assertThat(piTableEntry.table(), is(piTableId));
         assertThat(piTableEntry.cookie(), is(cookie));
+        assertThat("Priority must be set", piTableEntry.priority().isPresent());
+        assertThat("Timeout must be set", piTableEntry.timeout().isPresent());
         assertThat(piTableEntry.priority().get(), is(priority));
         assertThat(piTableEntry.timeout().get(), is(timeout));
         assertThat("Incorrect match param value",
diff --git a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiTableIdTest.java b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiTableIdTest.java
index d343cd7..eb1de71 100644
--- a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiTableIdTest.java
+++ b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiTableIdTest.java
@@ -18,6 +18,7 @@
 
 import com.google.common.testing.EqualsTester;
 import org.junit.Test;
+import org.onosproject.net.pi.model.PiTableId;
 
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.is;
@@ -28,16 +29,12 @@
  * Unit tests for PiTableId class.
  */
 public class PiTableIdTest {
-    final String table10 = "table10";
-    final String table20 = "table20";
-    final PiTableId piTableId1 = PiTableId.of(table10);
-    final PiTableId sameAsPiTableId1 = PiTableId.of(table10);
-    final PiTableId piTableId2 = PiTableId.of(table20);
+    private final String table10 = "table10";
+    private final String table20 = "table20";
+    private final PiTableId piTableId1 = PiTableId.of(table10);
+    private final PiTableId sameAsPiTableId1 = PiTableId.of(table10);
+    private final PiTableId piTableId2 = PiTableId.of(table20);
 
-    final String tableScope = "local";
-    final PiTableId piTableIdWithScope1 = PiTableId.of(tableScope, table10);
-    final PiTableId sameAsPiTableIdWithScope1 = PiTableId.of(tableScope, table10);
-    final PiTableId piTableIdWithScope2 = PiTableId.of(tableScope, table20);
     /**
      * Checks that the PiTableId class is immutable.
      */
@@ -58,37 +55,11 @@
     }
 
     /**
-     * Checks the operation of equals(), hashCode() and toString() methods.
-     */
-    @Test
-    public void testEqualsWithScope() {
-        new EqualsTester()
-                .addEqualityGroup(piTableIdWithScope1, sameAsPiTableIdWithScope1)
-                .addEqualityGroup(piTableIdWithScope2)
-                .testEquals();
-    }
-
-    /**
      * Checks the construction of a PiTableId object.
      */
     @Test
     public void testConstruction() {
-        final String name = "table1";
-        final PiTableId piTableId = PiTableId.of(name);
-        assertThat(piTableId, is(notNullValue()));
-        assertThat(piTableId.name(), is(name));
-    }
-
-    /**
-     * Checks the construction of a PiTableId object.
-     */
-    @Test
-    public void testConstructionWithScope() {
-        final String name = "table1";
-        final String scope = "local";
-        final PiTableId piTableId = PiTableId.of(scope, name);
-        assertThat(piTableId, is(notNullValue()));
-        assertThat(piTableId.name(), is(name));
-        assertThat(piTableId.scope().get(), is(scope));
+        assertThat(piTableId1, is(notNullValue()));
+        assertThat(piTableId1.id(), is(table10));
     }
 }
diff --git a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiTernaryFieldMatchTest.java b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiTernaryFieldMatchTest.java
index 2078496..f36ba6b 100644
--- a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiTernaryFieldMatchTest.java
+++ b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiTernaryFieldMatchTest.java
@@ -19,6 +19,7 @@
 import com.google.common.testing.EqualsTester;
 import org.junit.Test;
 import org.onlab.util.ImmutableByteSequence;
+import org.onosproject.net.pi.model.PiMatchFieldId;
 import org.onosproject.net.pi.model.PiMatchType;
 
 import static org.hamcrest.MatcherAssert.assertThat;
@@ -26,6 +27,7 @@
 import static org.hamcrest.Matchers.notNullValue;
 import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
 import static org.onlab.util.ImmutableByteSequence.copyFrom;
+import static org.onosproject.net.pi.runtime.PiConstantsTest.DOT;
 import static org.onosproject.net.pi.runtime.PiConstantsTest.DST_ADDR;
 import static org.onosproject.net.pi.runtime.PiConstantsTest.IPV4_HEADER_NAME;
 
@@ -33,15 +35,15 @@
  * Unit tests for PiTernaryFieldMatch class.
  */
 public class PiTernaryFieldMatchTest {
-    final ImmutableByteSequence value1 = copyFrom(0x0a010101);
-    final ImmutableByteSequence mask1 = copyFrom(0x00ffffff);
-    final ImmutableByteSequence value2 = copyFrom(0x0a010102);
-    final ImmutableByteSequence mask2 = copyFrom(0x0000ffff);
+    private final ImmutableByteSequence value1 = copyFrom(0x0a010101);
+    private final ImmutableByteSequence mask1 = copyFrom(0x00ffffff);
+    private final ImmutableByteSequence value2 = copyFrom(0x0a010102);
+    private final ImmutableByteSequence mask2 = copyFrom(0x0000ffff);
 
-    final PiHeaderFieldId piHeaderField = PiHeaderFieldId.of(IPV4_HEADER_NAME, DST_ADDR);
-    PiTernaryFieldMatch piTernaryFieldMatch1 = new PiTernaryFieldMatch(piHeaderField, value1, mask1);
-    PiTernaryFieldMatch sameAsPiTernaryFieldMatch1 = new PiTernaryFieldMatch(piHeaderField, value1, mask1);
-    PiTernaryFieldMatch piTernaryFieldMatch2 = new PiTernaryFieldMatch(piHeaderField, value2, mask2);
+    private final PiMatchFieldId piMatchField = PiMatchFieldId.of(IPV4_HEADER_NAME + DOT + DST_ADDR);
+    private PiTernaryFieldMatch piTernaryFieldMatch1 = new PiTernaryFieldMatch(piMatchField, value1, mask1);
+    private PiTernaryFieldMatch sameAsPiTernaryFieldMatch1 = new PiTernaryFieldMatch(piMatchField, value1, mask1);
+    private PiTernaryFieldMatch piTernaryFieldMatch2 = new PiTernaryFieldMatch(piMatchField, value2, mask2);
 
     /**
      * Checks that the PiTernaryFieldMatch class is immutable.
@@ -69,8 +71,8 @@
     public void testConstruction() {
         final ImmutableByteSequence value = copyFrom(0x0a01010a);
         final ImmutableByteSequence mask = copyFrom(0x00ffffff);
-        final PiHeaderFieldId piHeaderField = PiHeaderFieldId.of(IPV4_HEADER_NAME, DST_ADDR);
-        PiTernaryFieldMatch piTernaryFieldMatch = new PiTernaryFieldMatch(piHeaderField, value, mask);
+        final PiMatchFieldId piMatchField = PiMatchFieldId.of(IPV4_HEADER_NAME + DOT + DST_ADDR);
+        PiTernaryFieldMatch piTernaryFieldMatch = new PiTernaryFieldMatch(piMatchField, value, mask);
         assertThat(piTernaryFieldMatch, is(notNullValue()));
         assertThat(piTernaryFieldMatch.value(), is(value));
         assertThat(piTernaryFieldMatch.mask(), is(mask));
diff --git a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiValidFieldMatchTest.java b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiValidFieldMatchTest.java
index 6a32ed1..a62588a 100644
--- a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiValidFieldMatchTest.java
+++ b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiValidFieldMatchTest.java
@@ -18,12 +18,14 @@
 
 import com.google.common.testing.EqualsTester;
 import org.junit.Test;
+import org.onosproject.net.pi.model.PiMatchFieldId;
 import org.onosproject.net.pi.model.PiMatchType;
 
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.is;
 import static org.hamcrest.Matchers.notNullValue;
 import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
+import static org.onosproject.net.pi.runtime.PiConstantsTest.DOT;
 import static org.onosproject.net.pi.runtime.PiConstantsTest.VID;
 import static org.onosproject.net.pi.runtime.PiConstantsTest.VLAN_HEADER_NAME;
 
@@ -31,13 +33,12 @@
  * Unit tests for PiValidFieldMatch class.
  */
 public class PiValidFieldMatchTest {
-
-    final boolean isValid1 = true;
-    final boolean isValid2 = false;
-    final PiHeaderFieldId piHeaderField = PiHeaderFieldId.of(VLAN_HEADER_NAME, VID);
-    PiValidFieldMatch piValidFieldMatch1 = new PiValidFieldMatch(piHeaderField, isValid1);
-    PiValidFieldMatch sameAsPiValidFieldMatch1 = new PiValidFieldMatch(piHeaderField, isValid1);
-    PiValidFieldMatch piValidFieldMatch2 = new PiValidFieldMatch(piHeaderField, isValid2);
+    private final boolean isValid1 = true;
+    private final boolean isValid2 = false;
+    private final PiMatchFieldId piMatchField = PiMatchFieldId.of(VLAN_HEADER_NAME + DOT + VID);
+    private PiValidFieldMatch piValidFieldMatch1 = new PiValidFieldMatch(piMatchField, isValid1);
+    private PiValidFieldMatch sameAsPiValidFieldMatch1 = new PiValidFieldMatch(piMatchField, isValid1);
+    private PiValidFieldMatch piValidFieldMatch2 = new PiValidFieldMatch(piMatchField, isValid2);
 
     /**
      * Checks that the PiValidFieldMatch class is immutable.
@@ -63,11 +64,8 @@
      */
     @Test
     public void testConstruction() {
-        final boolean isValid = true;
-        final PiHeaderFieldId piHeaderField = PiHeaderFieldId.of(VLAN_HEADER_NAME, VID);
-        PiValidFieldMatch piTernaryFieldMatch = new PiValidFieldMatch(piHeaderField, isValid);
-        assertThat(piTernaryFieldMatch, is(notNullValue()));
-        assertThat(piTernaryFieldMatch.isValid(), is(isValid));
-        assertThat(piTernaryFieldMatch.type(), is(PiMatchType.VALID));
+        assertThat(piValidFieldMatch1, is(notNullValue()));
+        assertThat(piValidFieldMatch1.isValid(), is(isValid1));
+        assertThat(piValidFieldMatch1.type(), is(PiMatchType.VALID));
     }
 }
diff --git a/core/common/src/main/java/org/onosproject/codec/impl/CodecManager.java b/core/common/src/main/java/org/onosproject/codec/impl/CodecManager.java
index 7a88366..13782c7 100644
--- a/core/common/src/main/java/org/onosproject/codec/impl/CodecManager.java
+++ b/core/common/src/main/java/org/onosproject/codec/impl/CodecManager.java
@@ -75,10 +75,10 @@
 import org.onosproject.net.intent.Constraint;
 import org.onosproject.net.intent.HostToHostIntent;
 import org.onosproject.net.intent.Intent;
+import org.onosproject.net.intent.MultiPointToSinglePointIntent;
 import org.onosproject.net.intent.PointToPointIntent;
 import org.onosproject.net.intent.SinglePointToMultiPointIntent;
 import org.onosproject.net.intent.util.IntentMiniSummary;
-import org.onosproject.net.intent.MultiPointToSinglePointIntent;
 import org.onosproject.net.key.DeviceKey;
 import org.onosproject.net.mcast.McastRoute;
 import org.onosproject.net.meter.Band;
@@ -87,12 +87,9 @@
 import org.onosproject.net.packet.PacketRequest;
 import org.onosproject.net.pi.model.PiActionModel;
 import org.onosproject.net.pi.model.PiActionParamModel;
-import org.onosproject.net.pi.model.PiHeaderFieldTypeModel;
-import org.onosproject.net.pi.model.PiHeaderModel;
-import org.onosproject.net.pi.model.PiHeaderTypeModel;
+import org.onosproject.net.pi.model.PiMatchFieldModel;
 import org.onosproject.net.pi.model.PiPipeconf;
 import org.onosproject.net.pi.model.PiPipelineModel;
-import org.onosproject.net.pi.model.PiTableMatchFieldModel;
 import org.onosproject.net.pi.model.PiTableModel;
 import org.onosproject.net.region.Region;
 import org.onosproject.net.statistic.Load;
@@ -186,13 +183,10 @@
         registerCodec(TransportEndpointDescription.class, new TransportEndpointDescriptionCodec());
         registerCodec(PacketRequest.class, new PacketRequestCodec());
         registerCodec(PiActionModel.class, new PiActionModelCodec());
-        registerCodec(PiHeaderModel.class, new PiHeaderModelCodec());
         registerCodec(PiPipelineModel.class, new PiPipelineModelCodec());
         registerCodec(PiPipeconf.class, new PiPipeconfCodec());
         registerCodec(PiTableModel.class, new PiTableModelCodec());
-        registerCodec(PiTableMatchFieldModel.class, new PiTableMatchFieldModelCodec());
-        registerCodec(PiHeaderFieldTypeModel.class, new PiHeaderFieldTypeModelCodec());
-        registerCodec(PiHeaderTypeModel.class, new PiHeaderTypeModelCodec());
+        registerCodec(PiMatchFieldModel.class, new PiMatchFieldModelCodec());
         registerCodec(PiActionParamModel.class, new PiActionParamModelCodec());
         log.info("Started");
     }
diff --git a/core/common/src/main/java/org/onosproject/codec/impl/FlowRuleCodec.java b/core/common/src/main/java/org/onosproject/codec/impl/FlowRuleCodec.java
index da34c5e..37a173d 100644
--- a/core/common/src/main/java/org/onosproject/codec/impl/FlowRuleCodec.java
+++ b/core/common/src/main/java/org/onosproject/codec/impl/FlowRuleCodec.java
@@ -27,7 +27,7 @@
 import org.onosproject.net.flow.IndexTableId;
 import org.onosproject.net.flow.TrafficSelector;
 import org.onosproject.net.flow.TrafficTreatment;
-import org.onosproject.net.pi.runtime.PiTableId;
+import org.onosproject.net.pi.model.PiTableId;
 
 import static com.google.common.base.Preconditions.checkNotNull;
 import static org.onlab.util.Tools.nullIsIllegal;
diff --git a/core/common/src/main/java/org/onosproject/codec/impl/PiActionModelCodec.java b/core/common/src/main/java/org/onosproject/codec/impl/PiActionModelCodec.java
index 10cef43..dd7b336 100644
--- a/core/common/src/main/java/org/onosproject/codec/impl/PiActionModelCodec.java
+++ b/core/common/src/main/java/org/onosproject/codec/impl/PiActionModelCodec.java
@@ -33,7 +33,7 @@
     @Override
     public ObjectNode encode(PiActionModel action, CodecContext context) {
         ObjectNode result = context.mapper().createObjectNode();
-        result.put(NAME, action.name());
+        result.put(NAME, action.id().toString());
         ArrayNode params = result.putArray(PARAMS);
         action.params().forEach(param -> {
             ObjectNode paramData = context.encode(param, PiActionParamModel.class);
diff --git a/core/common/src/main/java/org/onosproject/codec/impl/PiActionParamModelCodec.java b/core/common/src/main/java/org/onosproject/codec/impl/PiActionParamModelCodec.java
index ac553fe..17f797a 100644
--- a/core/common/src/main/java/org/onosproject/codec/impl/PiActionParamModelCodec.java
+++ b/core/common/src/main/java/org/onosproject/codec/impl/PiActionParamModelCodec.java
@@ -32,7 +32,7 @@
     @Override
     public ObjectNode encode(PiActionParamModel param, CodecContext context) {
         ObjectNode result = context.mapper().createObjectNode();
-        result.put(NAME, param.name());
+        result.put(NAME, param.id().toString());
         result.put(BIT_WIDTH, param.bitWidth());
         return result;
     }
diff --git a/core/common/src/main/java/org/onosproject/codec/impl/PiHeaderModelCodec.java b/core/common/src/main/java/org/onosproject/codec/impl/PiHeaderModelCodec.java
deleted file mode 100644
index 7bcd134..0000000
--- a/core/common/src/main/java/org/onosproject/codec/impl/PiHeaderModelCodec.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.codec.impl;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import org.onosproject.codec.CodecContext;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.net.pi.model.PiHeaderModel;
-import org.onosproject.net.pi.model.PiHeaderTypeModel;
-
-/**
- * Codec for PiHeaderModel.
- */
-public class PiHeaderModelCodec extends JsonCodec<PiHeaderModel> {
-    private static final String NAME = "name";
-    private static final String TYPE = "type";
-    private static final String IS_META = "isMetadata";
-    private static final String INDEX = "index";
-
-    @Override
-    public ObjectNode encode(PiHeaderModel header, CodecContext context) {
-        ObjectNode result = context.mapper().createObjectNode();
-        ObjectNode headerTypeData = context.encode(header.type(), PiHeaderTypeModel.class);
-        result.put(NAME, header.name());
-        result.set(TYPE, headerTypeData);
-        result.put(IS_META, header.isMetadata());
-        result.put(INDEX, header.index());
-        return result;
-    }
-}
diff --git a/core/common/src/main/java/org/onosproject/codec/impl/PiHeaderTypeModelCodec.java b/core/common/src/main/java/org/onosproject/codec/impl/PiHeaderTypeModelCodec.java
deleted file mode 100644
index 1065a94..0000000
--- a/core/common/src/main/java/org/onosproject/codec/impl/PiHeaderTypeModelCodec.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.codec.impl;
-
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import org.onosproject.codec.CodecContext;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.net.pi.model.PiHeaderFieldTypeModel;
-import org.onosproject.net.pi.model.PiHeaderTypeModel;
-
-/**
- * Codec for PiHeaderTypeModel.
- */
-public class PiHeaderTypeModelCodec extends JsonCodec<PiHeaderTypeModel> {
-    private static final String NAME = "name";
-    private static final String FIELDS = "fields";
-
-    @Override
-    public ObjectNode encode(PiHeaderTypeModel headerType, CodecContext context) {
-        ObjectNode result = context.mapper().createObjectNode();
-        result.put(NAME, headerType.name());
-        ArrayNode fields = result.putArray(FIELDS);
-
-        headerType.fields().forEach(field -> {
-            fields.add(context.encode(field, PiHeaderFieldTypeModel.class));
-        });
-
-        return result;
-    }
-}
diff --git a/core/common/src/main/java/org/onosproject/codec/impl/PiHeaderFieldTypeModelCodec.java b/core/common/src/main/java/org/onosproject/codec/impl/PiMatchFieldModelCodec.java
similarity index 65%
rename from core/common/src/main/java/org/onosproject/codec/impl/PiHeaderFieldTypeModelCodec.java
rename to core/common/src/main/java/org/onosproject/codec/impl/PiMatchFieldModelCodec.java
index 09a1566..6d6dad4 100644
--- a/core/common/src/main/java/org/onosproject/codec/impl/PiHeaderFieldTypeModelCodec.java
+++ b/core/common/src/main/java/org/onosproject/codec/impl/PiMatchFieldModelCodec.java
@@ -19,20 +19,19 @@
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import org.onosproject.codec.CodecContext;
 import org.onosproject.codec.JsonCodec;
-import org.onosproject.net.pi.model.PiHeaderFieldTypeModel;
+import org.onosproject.net.pi.model.PiMatchFieldModel;
 
 /**
- * Codec for PiHeaderFieldTypeModel.
+ * Codec for PiMatchFieldModel.
  */
-public class PiHeaderFieldTypeModelCodec extends JsonCodec<PiHeaderFieldTypeModel> {
-    private static final String NAME = "name";
-    private static final String BIT_WIDTH = "bitWidth";
-
+public class PiMatchFieldModelCodec extends JsonCodec<PiMatchFieldModel> {
+    private static final String MATCH_TYPE = "matchType";
+    private static final String FIELD = "field";
     @Override
-    public ObjectNode encode(PiHeaderFieldTypeModel headerFieldType, CodecContext context) {
+    public ObjectNode encode(PiMatchFieldModel matchFieldModel, CodecContext context) {
         ObjectNode result = context.mapper().createObjectNode();
-        result.put(NAME, headerFieldType.name());
-        result.put(BIT_WIDTH, headerFieldType.bitWidth());
+        result.put(MATCH_TYPE, matchFieldModel.matchType().toString());
+        result.put(FIELD, matchFieldModel.id().toString());
         return result;
     }
 }
diff --git a/core/common/src/main/java/org/onosproject/codec/impl/PiPipelineModelCodec.java b/core/common/src/main/java/org/onosproject/codec/impl/PiPipelineModelCodec.java
index 6b42c8d..28a7010 100644
--- a/core/common/src/main/java/org/onosproject/codec/impl/PiPipelineModelCodec.java
+++ b/core/common/src/main/java/org/onosproject/codec/impl/PiPipelineModelCodec.java
@@ -21,7 +21,6 @@
 import org.onosproject.codec.CodecContext;
 import org.onosproject.codec.JsonCodec;
 import org.onosproject.net.pi.model.PiActionModel;
-import org.onosproject.net.pi.model.PiHeaderModel;
 import org.onosproject.net.pi.model.PiPipelineModel;
 import org.onosproject.net.pi.model.PiTableModel;
 
@@ -29,19 +28,17 @@
  * Codec for PiPipelineModel.
  */
 public class PiPipelineModelCodec extends JsonCodec<PiPipelineModel> {
-    private static final String HEADERS = "headers";
     private static final String ACTIONS = "actions";
     private static final String TABLES = "tables";
 
     @Override
     public ObjectNode encode(PiPipelineModel pipeline, CodecContext context) {
         ObjectNode result = context.mapper().createObjectNode();
-        ArrayNode headers = result.putArray(HEADERS);
-        pipeline.headers().stream()
-                .map(header -> context.encode(header, PiHeaderModel.class))
-                .forEach(headers::add);
         ArrayNode actions = result.putArray(ACTIONS);
-        pipeline.actions().stream()
+        pipeline.tables()
+                .stream()
+                .flatMap(piTableModel -> piTableModel.actions().stream())
+                .distinct()
                 .map(action -> context.encode(action, PiActionModel.class))
                 .forEach(actions::add);
         ArrayNode tables = result.putArray(TABLES);
diff --git a/core/common/src/main/java/org/onosproject/codec/impl/PiTableMatchFieldModelCodec.java b/core/common/src/main/java/org/onosproject/codec/impl/PiTableMatchFieldModelCodec.java
deleted file mode 100644
index a94bcba..0000000
--- a/core/common/src/main/java/org/onosproject/codec/impl/PiTableMatchFieldModelCodec.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.codec.impl;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import org.onosproject.codec.CodecContext;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.net.pi.model.PiHeaderFieldTypeModel;
-import org.onosproject.net.pi.model.PiHeaderModel;
-import org.onosproject.net.pi.model.PiTableMatchFieldModel;
-
-/**
- * Codec for PiTableMatchFieldModel.
- */
-public class PiTableMatchFieldModelCodec extends JsonCodec<PiTableMatchFieldModel> {
-    private static final String MATCH_TYPE = "matchType";
-    private static final String HEADER = "header";
-    private static final String FIELD = "field";
-    @Override
-    public ObjectNode encode(PiTableMatchFieldModel tableMatchField, CodecContext context) {
-        ObjectNode result = context.mapper().createObjectNode();
-        result.put(MATCH_TYPE, tableMatchField.matchType().toString());
-        PiHeaderModel header = tableMatchField.field().header();
-        PiHeaderFieldTypeModel field = tableMatchField.field().type();
-        ObjectNode headerData = context.encode(header, PiHeaderModel.class);
-        ObjectNode headerFieldData = context.encode(field, PiHeaderFieldTypeModel.class);
-        result.set(HEADER, headerData);
-        result.set(FIELD, headerFieldData);
-        return result;
-    }
-}
diff --git a/core/common/src/main/java/org/onosproject/codec/impl/PiTableModelCodec.java b/core/common/src/main/java/org/onosproject/codec/impl/PiTableModelCodec.java
index 052e083..adf8bd7 100644
--- a/core/common/src/main/java/org/onosproject/codec/impl/PiTableModelCodec.java
+++ b/core/common/src/main/java/org/onosproject/codec/impl/PiTableModelCodec.java
@@ -20,7 +20,7 @@
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import org.onosproject.codec.CodecContext;
 import org.onosproject.codec.JsonCodec;
-import org.onosproject.net.pi.model.PiTableMatchFieldModel;
+import org.onosproject.net.pi.model.PiMatchFieldModel;
 import org.onosproject.net.pi.model.PiTableModel;
 
 /**
@@ -40,21 +40,21 @@
 
         ObjectNode result = context.mapper().createObjectNode();
 
-        result.put(NAME, table.name());
+        result.put(NAME, table.id().toString());
         result.put(MAX_SIZE, table.maxSize());
-        result.put(HAS_COUNTERS, table.hasCounters());
+        result.put(HAS_COUNTERS, table.counters().size() > 0);
         result.put(SUPPORT_AGING, table.supportsAging());
 
         ArrayNode matchFields = result.putArray(MATCH_FIELDS);
         table.matchFields().forEach(matchField -> {
             ObjectNode matchFieldData =
-                    context.encode(matchField, PiTableMatchFieldModel.class);
+                    context.encode(matchField, PiMatchFieldModel.class);
             matchFields.add(matchFieldData);
         });
 
         ArrayNode actions = result.putArray(ACTIONS);
         table.actions().forEach(action -> {
-            actions.add(action.name());
+            actions.add(action.id().toString());
         });
 
         return result;
diff --git a/core/net/src/main/java/org/onosproject/net/pi/impl/CriterionTranslatorHelper.java b/core/net/src/main/java/org/onosproject/net/pi/impl/CriterionTranslatorHelper.java
index 4e0fd16..20a2d0f 100644
--- a/core/net/src/main/java/org/onosproject/net/pi/impl/CriterionTranslatorHelper.java
+++ b/core/net/src/main/java/org/onosproject/net/pi/impl/CriterionTranslatorHelper.java
@@ -80,10 +80,10 @@
 import org.onosproject.net.pi.impl.CriterionTranslators.UdpPortCriterionTranslator;
 import org.onosproject.net.pi.impl.CriterionTranslators.VlanIdCriterionTranslator;
 import org.onosproject.net.pi.impl.CriterionTranslators.VlanPcpCriterionTranslator;
+import org.onosproject.net.pi.model.PiMatchFieldId;
 import org.onosproject.net.pi.model.PiMatchType;
 import org.onosproject.net.pi.runtime.PiExactFieldMatch;
 import org.onosproject.net.pi.runtime.PiFieldMatch;
-import org.onosproject.net.pi.runtime.PiHeaderFieldId;
 import org.onosproject.net.pi.runtime.PiLpmFieldMatch;
 import org.onosproject.net.pi.runtime.PiTernaryFieldMatch;
 
@@ -140,14 +140,14 @@
     /**
      * Translates a given criterion instance to a PiFieldMatch with the given id, match type, and bit-width.
      *
-     * @param fieldId   PI header field identifier
+     * @param fieldId   PI match field identifier
      * @param criterion criterion
      * @param matchType match type
      * @param bitWidth  size of the field match in bits
      * @return a PI field match
      * @throws PiTranslationException if the criterion cannot be translated (see exception message)
      */
-    static PiFieldMatch translateCriterion(Criterion criterion, PiHeaderFieldId fieldId, PiMatchType matchType,
+    static PiFieldMatch translateCriterion(Criterion criterion, PiMatchFieldId fieldId, PiMatchType matchType,
                                            int bitWidth)
             throws PiTranslationException {
 
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 0a4ffbb..6f61c3b 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
@@ -29,22 +29,22 @@
 import org.onosproject.net.flow.instructions.PiInstruction;
 import org.onosproject.net.pi.model.PiActionModel;
 import org.onosproject.net.pi.model.PiActionParamModel;
+import org.onosproject.net.pi.model.PiMatchFieldId;
+import org.onosproject.net.pi.model.PiMatchFieldModel;
 import org.onosproject.net.pi.model.PiPipeconf;
 import org.onosproject.net.pi.model.PiPipelineInterpreter;
 import org.onosproject.net.pi.model.PiPipelineModel;
-import org.onosproject.net.pi.model.PiTableMatchFieldModel;
+import org.onosproject.net.pi.model.PiTableId;
 import org.onosproject.net.pi.model.PiTableModel;
 import org.onosproject.net.pi.runtime.PiAction;
 import org.onosproject.net.pi.runtime.PiActionParam;
 import org.onosproject.net.pi.runtime.PiExactFieldMatch;
 import org.onosproject.net.pi.runtime.PiFieldMatch;
-import org.onosproject.net.pi.runtime.PiHeaderFieldId;
 import org.onosproject.net.pi.runtime.PiLpmFieldMatch;
 import org.onosproject.net.pi.runtime.PiMatchKey;
 import org.onosproject.net.pi.runtime.PiRangeFieldMatch;
 import org.onosproject.net.pi.runtime.PiTableAction;
 import org.onosproject.net.pi.runtime.PiTableEntry;
-import org.onosproject.net.pi.runtime.PiTableId;
 import org.onosproject.net.pi.runtime.PiTernaryFieldMatch;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -128,7 +128,7 @@
                 tableEntryBuilder.withTimeout((double) rule.timeout());
             } else {
                 log.warn("Flow rule is temporary, but table '{}' doesn't support " +
-                                 "aging, translating to permanent.", tableModel.name());
+                                 "aging, translating to permanent.", tableModel.id());
             }
 
         }
@@ -159,7 +159,7 @@
 
     private static PiTableModel getTableModel(PiTableId piTableId, PiPipelineModel pipelineModel)
             throws PiTranslationException {
-        return pipelineModel.table(piTableId.toString())
+        return pipelineModel.table(piTableId)
                 .orElseThrow(() -> new PiTranslationException(format(
                         "Not such a table in pipeline model: %s", piTableId)));
     }
@@ -221,24 +221,24 @@
     private static PiTableAction checkPiAction(PiAction piAction, PiTableModel table)
             throws PiTranslationException {
         // Table supports this action?
-        PiActionModel actionModel = table.action(piAction.id().name()).orElseThrow(
+        PiActionModel actionModel = table.action(piAction.id()).orElseThrow(
                 () -> new PiTranslationException(format("Not such action '%s' for table '%s'",
-                                                        piAction.id(), table.name())));
+                                                        piAction.id(), table.id())));
 
         // Is the number of runtime parameters correct?
         if (actionModel.params().size() != piAction.parameters().size()) {
             throw new PiTranslationException(format(
                     "Wrong number of runtime parameters for action '%s', expected %d but found %d",
-                    actionModel.name(), actionModel.params().size(), piAction.parameters().size()));
+                    actionModel.id(), actionModel.params().size(), piAction.parameters().size()));
         }
 
         // Forge a new action instance with well-sized parameters.
         // The same comment as in typeCheckFieldMatch() about duplicating field match instances applies here.
         PiAction.Builder newActionBuilder = PiAction.builder().withId(piAction.id());
         for (PiActionParam param : piAction.parameters()) {
-            PiActionParamModel paramModel = actionModel.param(param.id().name())
+            PiActionParamModel paramModel = actionModel.param(param.id())
                     .orElseThrow(() -> new PiTranslationException(format(
-                            "Not such parameter '%s' for action '%s'", param.id(), actionModel.name())));
+                            "Not such parameter '%s' for action '%s'", param.id(), actionModel)));
             try {
                 newActionBuilder.withParameter(new PiActionParam(param.id(),
                                                                  fit(param.value(), paramModel.bitWidth())));
@@ -260,16 +260,16 @@
                                                                   TrafficSelector selector, PiTableModel tableModel)
             throws PiTranslationException {
 
-        Map<PiHeaderFieldId, PiFieldMatch> fieldMatches = Maps.newHashMap();
+        Map<PiMatchFieldId, PiFieldMatch> fieldMatches = Maps.newHashMap();
 
         // If present, find a PiCriterion and get its field matches as a map. Otherwise, use an empty map.
-        Map<PiHeaderFieldId, PiFieldMatch> piCriterionFields = selector.criteria().stream()
+        Map<PiMatchFieldId, PiFieldMatch> piCriterionFields = selector.criteria().stream()
                 .filter(c -> c.type().equals(PROTOCOL_INDEPENDENT))
                 .map(c -> (PiCriterion) c)
                 .findFirst()
                 .map(PiCriterion::fieldMatches)
                 .map(c -> {
-                    Map<PiHeaderFieldId, PiFieldMatch> fieldMap = Maps.newHashMap();
+                    Map<PiMatchFieldId, PiFieldMatch> fieldMap = Maps.newHashMap();
                     c.forEach(fieldMatch -> fieldMap.put(fieldMatch.fieldId(), fieldMatch));
                     return fieldMap;
                 })
@@ -277,31 +277,20 @@
 
         Set<Criterion> translatedCriteria = Sets.newHashSet();
         Set<Criterion> ignoredCriteria = Sets.newHashSet();
-        Set<PiHeaderFieldId> usedPiCriterionFields = Sets.newHashSet();
-        Set<PiHeaderFieldId> ignoredPiCriterionFields = Sets.newHashSet();
+        Set<PiMatchFieldId> usedPiCriterionFields = Sets.newHashSet();
+        Set<PiMatchFieldId> ignoredPiCriterionFields = Sets.newHashSet();
 
-        for (PiTableMatchFieldModel fieldModel : tableModel.matchFields()) {
+        for (PiMatchFieldModel fieldModel : tableModel.matchFields()) {
 
-            PiHeaderFieldId fieldId = PiHeaderFieldId.of(fieldModel.field().header().name(),
-                                                         fieldModel.field().type().name(),
-                                                         fieldModel.field().header().index());
+            PiMatchFieldId fieldId = fieldModel.id();
 
-            // FIXME: workaround until ONOS-7066 is resolved
-            if (fieldId.id().startsWith("scalars")) {
-                String newFieldId = fieldId.id()
-                        .replace("scalars.", "")
-                        .replace("_t.", ".");
-                String[] piecies = newFieldId.split("\\.");
-                fieldId = PiHeaderFieldId.of(piecies[0], piecies[1]);
-            }
-
-            int bitWidth = fieldModel.field().type().bitWidth();
+            int bitWidth = fieldModel.bitWidth();
             int fieldByteWidth = (int) Math.ceil((double) bitWidth / 8);
 
             Optional<Criterion.Type> criterionType =
                     interpreter == null
                             ? Optional.empty()
-                            : interpreter.mapPiHeaderFieldId(fieldId);
+                            : interpreter.mapPiMatchFieldId(fieldId);
 
             Criterion criterion = criterionType.map(selector::getCriterion).orElse(null);
 
@@ -378,7 +367,7 @@
         if (skippedCriteriaJoiner.length() > 0) {
             throw new PiTranslationException(format(
                     "The following criteria cannot be translated for table '%s': %s",
-                    tableModel.name(), skippedCriteriaJoiner.toString()));
+                    tableModel.id(), skippedCriteriaJoiner.toString()));
         }
 
         // Check if all fields found in PiCriterion have been used.
@@ -389,13 +378,13 @@
         if (skippedPiFieldsJoiner.length() > 0) {
             throw new PiTranslationException(format(
                     "The following PiCriterion field matches are not supported in table '%s': %s",
-                    tableModel.name(), skippedPiFieldsJoiner.toString()));
+                    tableModel.id(), skippedPiFieldsJoiner.toString()));
         }
 
         return fieldMatches.values();
     }
 
-    private static PiFieldMatch typeCheckFieldMatch(PiFieldMatch fieldMatch, PiTableMatchFieldModel fieldModel)
+    private static PiFieldMatch typeCheckFieldMatch(PiFieldMatch fieldMatch, PiMatchFieldModel fieldModel)
             throws PiTranslationException {
 
         // Check parameter type and size
@@ -405,7 +394,7 @@
                     fieldMatch.fieldId(), fieldModel.matchType().name(), fieldMatch.type().name()));
         }
 
-        int modelBitWidth = fieldModel.field().type().bitWidth();
+        int modelBitWidth = fieldModel.bitWidth();
 
         /*
         Here we try to be robust against wrong size fields with the goal of having PiCriterion independent of the
diff --git a/core/net/src/main/java/org/onosproject/net/pi/impl/PiGroupTranslator.java b/core/net/src/main/java/org/onosproject/net/pi/impl/PiGroupTranslator.java
index 7b798c0..a682409 100644
--- a/core/net/src/main/java/org/onosproject/net/pi/impl/PiGroupTranslator.java
+++ b/core/net/src/main/java/org/onosproject/net/pi/impl/PiGroupTranslator.java
@@ -19,6 +19,7 @@
 import org.onosproject.net.Device;
 import org.onosproject.net.group.Group;
 import org.onosproject.net.group.GroupBucket;
+import org.onosproject.net.pi.model.PiActionGroupType;
 import org.onosproject.net.pi.model.PiPipeconf;
 import org.onosproject.net.pi.model.PiPipelineInterpreter;
 import org.onosproject.net.pi.runtime.PiAction;
@@ -64,7 +65,7 @@
 
         switch (group.type()) {
             case SELECT:
-                piActionGroupBuilder.withType(PiActionGroup.Type.SELECT);
+                piActionGroupBuilder.withType(PiActionGroupType.SELECT);
                 break;
             default:
                 throw new PiTranslationException(format("Group type %s not supported", group.type()));
diff --git a/core/net/src/main/java/org/onosproject/net/pi/impl/PiUtils.java b/core/net/src/main/java/org/onosproject/net/pi/impl/PiUtils.java
index aab8b40..f3270f4 100644
--- a/core/net/src/main/java/org/onosproject/net/pi/impl/PiUtils.java
+++ b/core/net/src/main/java/org/onosproject/net/pi/impl/PiUtils.java
@@ -21,7 +21,7 @@
 import org.onosproject.net.flow.TableId;
 import org.onosproject.net.pi.model.PiPipeconf;
 import org.onosproject.net.pi.model.PiPipelineInterpreter;
-import org.onosproject.net.pi.runtime.PiTableId;
+import org.onosproject.net.pi.model.PiTableId;
 import org.onosproject.net.pi.runtime.PiTranslationService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
diff --git a/core/net/src/test/java/org/onosproject/net/pi/impl/PiCriterionTranslatorsTest.java b/core/net/src/test/java/org/onosproject/net/pi/impl/PiCriterionTranslatorsTest.java
index 156be3a..1938c05 100644
--- a/core/net/src/test/java/org/onosproject/net/pi/impl/PiCriterionTranslatorsTest.java
+++ b/core/net/src/test/java/org/onosproject/net/pi/impl/PiCriterionTranslatorsTest.java
@@ -57,8 +57,8 @@
 import org.onosproject.net.flow.criteria.UdpPortCriterion;
 import org.onosproject.net.flow.criteria.VlanIdCriterion;
 import org.onosproject.net.flow.criteria.VlanPcpCriterion;
+import org.onosproject.net.pi.model.PiMatchFieldId;
 import org.onosproject.net.pi.runtime.PiExactFieldMatch;
-import org.onosproject.net.pi.runtime.PiHeaderFieldId;
 import org.onosproject.net.pi.runtime.PiLpmFieldMatch;
 import org.onosproject.net.pi.runtime.PiTernaryFieldMatch;
 
@@ -67,7 +67,9 @@
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.onosproject.net.pi.impl.CriterionTranslatorHelper.translateCriterion;
-import static org.onosproject.net.pi.model.PiMatchType.*;
+import static org.onosproject.net.pi.model.PiMatchType.EXACT;
+import static org.onosproject.net.pi.model.PiMatchType.LPM;
+import static org.onosproject.net.pi.model.PiMatchType.TERNARY;
 
 /**
  * Tests for CriterionTranslators.
@@ -75,7 +77,7 @@
 public class PiCriterionTranslatorsTest {
 
     private Random random = new Random();
-    private final PiHeaderFieldId fieldId = PiHeaderFieldId.of("foo", "bar");
+    private final PiMatchFieldId fieldId = PiMatchFieldId.of("foo.bar");
 
     @Test
     public void testEthCriterion() throws Exception {
@@ -480,4 +482,4 @@
 
         assertThat(exactMatch.value().asReadOnlyBuffer().get(), is(criterion.ipEcn()));
     }
-}
\ No newline at end of file
+}
diff --git a/core/net/src/test/java/org/onosproject/net/pi/impl/PiTranslatorServiceTest.java b/core/net/src/test/java/org/onosproject/net/pi/impl/PiTranslatorServiceTest.java
index e7e3e23..d13def7 100644
--- a/core/net/src/test/java/org/onosproject/net/pi/impl/PiTranslatorServiceTest.java
+++ b/core/net/src/test/java/org/onosproject/net/pi/impl/PiTranslatorServiceTest.java
@@ -43,6 +43,7 @@
 import org.onosproject.net.group.GroupBucket;
 import org.onosproject.net.group.GroupBuckets;
 import org.onosproject.net.group.GroupDescription;
+import org.onosproject.net.pi.model.PiActionGroupType;
 import org.onosproject.net.pi.model.PiPipeconf;
 import org.onosproject.net.pi.runtime.PiAction;
 import org.onosproject.net.pi.runtime.PiActionGroup;
@@ -169,13 +170,13 @@
                 .addEqualityGroup(entry1, entry2)
                 .testEquals();
 
-        int numMatchParams = pipeconf.pipelineModel().table(TBL_TABLE0_ID.id()).get().matchFields().size();
+        int numMatchParams = pipeconf.pipelineModel().table(TBL_TABLE0_ID).get().matchFields().size();
         // parse values stored in entry1
         PiTernaryFieldMatch inPortParam = (PiTernaryFieldMatch) entry1.matchKey().fieldMatch(HDR_IN_PORT_ID).get();
         PiTernaryFieldMatch ethDstParam = (PiTernaryFieldMatch) entry1.matchKey().fieldMatch(HDR_ETH_DST_ID).get();
         PiTernaryFieldMatch ethSrcParam = (PiTernaryFieldMatch) entry1.matchKey().fieldMatch(HDR_ETH_SRC_ID).get();
         PiTernaryFieldMatch ethTypeParam = (PiTernaryFieldMatch) entry1.matchKey().fieldMatch(HDR_ETH_TYPE_ID).get();
-        Optional<Double> expectedTimeout = pipeconf.pipelineModel().table(TBL_TABLE0_ID.id()).get().supportsAging()
+        Optional<Double> expectedTimeout = pipeconf.pipelineModel().table(TBL_TABLE0_ID).get().supportsAging()
                 ? Optional.of((double) rule1.timeout()) : Optional.empty();
 
         // check that the number of parameters in the entry is the same as the number of table keys
@@ -245,7 +246,7 @@
         assertThat("Group ID must be equal",
                    piGroup1.id().id(), is(equalTo(GROUP_ID.id())));
         assertThat("Group type must be SELECT",
-                   piGroup1.type(), is(equalTo(PiActionGroup.Type.SELECT)));
+                   piGroup1.type(), is(equalTo(PiActionGroupType.SELECT)));
         assertThat("Action profile ID must be equal",
                    piGroup1.actionProfileId(), is(equalTo(ACT_PRF_WCMP_SELECTOR_ID)));
 
diff --git a/core/store/serializers/src/main/java/org/onosproject/store/serializers/KryoNamespaces.java b/core/store/serializers/src/main/java/org/onosproject/store/serializers/KryoNamespaces.java
index 6c4ad07..793b05b 100644
--- a/core/store/serializers/src/main/java/org/onosproject/store/serializers/KryoNamespaces.java
+++ b/core/store/serializers/src/main/java/org/onosproject/store/serializers/KryoNamespaces.java
@@ -202,31 +202,40 @@
 import org.onosproject.net.packet.DefaultOutboundPacket;
 import org.onosproject.net.packet.DefaultPacketRequest;
 import org.onosproject.net.packet.PacketPriority;
+import org.onosproject.net.pi.model.PiActionGroupType;
+import org.onosproject.net.pi.model.PiActionId;
+import org.onosproject.net.pi.model.PiActionParamId;
+import org.onosproject.net.pi.model.PiActionProfileId;
+import org.onosproject.net.pi.model.PiControlMetadataId;
+import org.onosproject.net.pi.model.PiCounterId;
+import org.onosproject.net.pi.model.PiCounterType;
+import org.onosproject.net.pi.model.PiMatchFieldId;
 import org.onosproject.net.pi.model.PiMatchType;
+import org.onosproject.net.pi.model.PiMeterId;
+import org.onosproject.net.pi.model.PiMeterType;
+import org.onosproject.net.pi.model.PiPacketOperationType;
 import org.onosproject.net.pi.model.PiPipeconfId;
+import org.onosproject.net.pi.model.PiTableId;
+import org.onosproject.net.pi.model.PiTableType;
 import org.onosproject.net.pi.runtime.PiAction;
 import org.onosproject.net.pi.runtime.PiActionGroup;
 import org.onosproject.net.pi.runtime.PiActionGroupId;
 import org.onosproject.net.pi.runtime.PiActionGroupMember;
 import org.onosproject.net.pi.runtime.PiActionGroupMemberId;
-import org.onosproject.net.pi.runtime.PiActionId;
 import org.onosproject.net.pi.runtime.PiActionParam;
-import org.onosproject.net.pi.runtime.PiActionParamId;
+import org.onosproject.net.pi.runtime.PiControlMetadata;
+import org.onosproject.net.pi.runtime.PiCounterCellData;
+import org.onosproject.net.pi.runtime.PiCounterCellId;
 import org.onosproject.net.pi.runtime.PiExactFieldMatch;
 import org.onosproject.net.pi.runtime.PiFieldMatch;
-import org.onosproject.net.pi.runtime.PiActionProfileId;
 import org.onosproject.net.pi.runtime.PiGroupKey;
-import org.onosproject.net.pi.runtime.PiHeaderFieldId;
 import org.onosproject.net.pi.runtime.PiLpmFieldMatch;
 import org.onosproject.net.pi.runtime.PiMatchKey;
-import org.onosproject.net.pi.runtime.PiPacketMetadata;
-import org.onosproject.net.pi.runtime.PiPacketMetadataId;
 import org.onosproject.net.pi.runtime.PiPacketOperation;
 import org.onosproject.net.pi.runtime.PiPipeconfConfig;
 import org.onosproject.net.pi.runtime.PiRangeFieldMatch;
 import org.onosproject.net.pi.runtime.PiTableAction;
 import org.onosproject.net.pi.runtime.PiTableEntry;
-import org.onosproject.net.pi.runtime.PiTableId;
 import org.onosproject.net.pi.runtime.PiTernaryFieldMatch;
 import org.onosproject.net.pi.runtime.PiValidFieldMatch;
 import org.onosproject.net.provider.ProviderId;
@@ -601,34 +610,43 @@
             .register(DomainConstraint.class)
             .register(
                     // PI model
+                    PiActionGroupType.class,
+                    PiActionId.class,
+                    PiActionParamId.class,
+                    PiActionProfileId.class,
+                    PiControlMetadataId.class,
+                    PiCounterId.class,
+                    PiCounterType.class,
+                    PiMatchFieldId.class,
                     PiMatchType.class,
+                    PiMeterId.class,
+                    PiMeterType.class,
+                    PiPacketOperationType.class,
                     PiPipeconfId.class,
+                    PiTableId.class,
+                    PiTableType.class,
                     // PI Runtime
                     PiAction.class,
                     PiActionGroup.class,
                     PiActionGroupId.class,
                     PiActionGroupMember.class,
                     PiActionGroupMemberId.class,
-                    PiActionId.class,
                     PiActionParam.class,
-                    PiActionParamId.class,
+                    PiControlMetadata.class,
+                    PiCounterCellData.class,
+                    PiCounterCellId.class,
                     PiExactFieldMatch.class,
                     PiFieldMatch.class,
                     PiGroupKey.class,
-                    PiHeaderFieldId.class,
                     PiLpmFieldMatch.class,
                     PiMatchKey.class,
-                    PiPacketMetadata.class,
-                    PiPacketMetadataId.class,
                     PiPacketOperation.class,
                     PiPipeconfConfig.class,
                     PiRangeFieldMatch.class,
                     PiTableAction.class,
                     PiTableEntry.class,
-                    PiTableId.class,
                     PiTernaryFieldMatch.class,
                     PiValidFieldMatch.class,
-                    PiActionProfileId.class,
                     // Other
                     PiCriterion.class,
                     PiInstruction.class