[ONOS-4245] Support resubmit experimenter action for nicira driver

Change-Id: I7beac62d5c23fb8e2fe7d7d23947c55fbb849064
diff --git a/drivers/default/src/main/java/org/onosproject/driver/extensions/NiciraExtensionTreatmentInterpreter.java b/drivers/default/src/main/java/org/onosproject/driver/extensions/NiciraExtensionTreatmentInterpreter.java
index 923dcde..9ea3750 100644
--- a/drivers/default/src/main/java/org/onosproject/driver/extensions/NiciraExtensionTreatmentInterpreter.java
+++ b/drivers/default/src/main/java/org/onosproject/driver/extensions/NiciraExtensionTreatmentInterpreter.java
@@ -17,6 +17,7 @@
 package org.onosproject.driver.extensions;
 
 import org.onlab.packet.Ip4Address;
+import org.onosproject.net.PortNumber;
 import org.onosproject.net.behaviour.ExtensionTreatmentResolver;
 import org.onosproject.net.driver.AbstractHandlerBehaviour;
 import org.onosproject.net.flow.instructions.ExtensionTreatment;
@@ -28,6 +29,7 @@
 import org.projectfloodlight.openflow.protocol.action.OFActionExperimenter;
 import org.projectfloodlight.openflow.protocol.action.OFActionNicira;
 import org.projectfloodlight.openflow.protocol.action.OFActionNiciraMove;
+import org.projectfloodlight.openflow.protocol.action.OFActionNiciraResubmit;
 import org.projectfloodlight.openflow.protocol.action.OFActionSetField;
 import org.projectfloodlight.openflow.protocol.oxm.OFOxm;
 import org.projectfloodlight.openflow.protocol.oxm.OFOxmTunnelIpv4Dst;
@@ -40,12 +42,14 @@
         implements ExtensionTreatmentInterpreter, ExtensionTreatmentResolver {
 
     private static final int TYPE_NICIRA = 0x2320;
-    private static final int SUB_TYPE_MOVE = 6;
     private static final int SRC_ARP_SHA = 0x00012206;
     private static final int SRC_ARP_SPA = 0x00002004;
     private static final int SRC_ETH = 0x00000406;
     private static final int SRC_IP = 0x00000e04;
 
+    private static final int SUB_TYPE_RESUBMIT = 1;
+    private static final int SUB_TYPE_MOVE = 6;
+
     @Override
     public boolean supported(ExtensionTreatmentType extensionTreatmentType) {
         if (extensionTreatmentType.equals(
@@ -175,26 +179,33 @@
             if (Long.valueOf(experimenter.getExperimenter())
                     .intValue() == TYPE_NICIRA) {
                 OFActionNicira nicira = (OFActionNicira) experimenter;
-                if (nicira.getSubtype() == SUB_TYPE_MOVE) {
-                    OFActionNiciraMove moveAction = (OFActionNiciraMove) nicira;
-                    switch (Long.valueOf(moveAction.getSrc()).intValue()) {
-                    case SRC_ARP_SHA:
-                        return NiciraMoveTreatmentFactory
-                                .createNiciraMovArpShaToTha();
-                    case SRC_ETH:
-                        return NiciraMoveTreatmentFactory
-                                .createNiciraMovEthSrcToDst();
-                    case SRC_IP:
-                        return NiciraMoveTreatmentFactory
-                                .createNiciraMovIpSrcToDst();
-                    case SRC_ARP_SPA:
-                        return NiciraMoveTreatmentFactory
-                                .createNiciraMovArpSpaToTpa();
+                switch (nicira.getSubtype()) {
+                    case SUB_TYPE_MOVE:
+                        OFActionNiciraMove moveAction = (OFActionNiciraMove) nicira;
+                        switch (Long.valueOf(moveAction.getSrc()).intValue()) {
+                            case SRC_ARP_SHA:
+                                return NiciraMoveTreatmentFactory
+                                        .createNiciraMovArpShaToTha();
+                            case SRC_ETH:
+                                return NiciraMoveTreatmentFactory
+                                        .createNiciraMovEthSrcToDst();
+                            case SRC_IP:
+                                return NiciraMoveTreatmentFactory
+                                        .createNiciraMovIpSrcToDst();
+                            case SRC_ARP_SPA:
+                                return NiciraMoveTreatmentFactory
+                                        .createNiciraMovArpSpaToTpa();
+                            default:
+                                throw new UnsupportedOperationException("Driver does not support move from "
+                                        + moveAction.getSrc() + " to "
+                                        + moveAction.getDst());
+                        }
+                    case SUB_TYPE_RESUBMIT:
+                        OFActionNiciraResubmit resubmitAction = (OFActionNiciraResubmit) nicira;
+                        return new NiciraResubmit(PortNumber.portNumber(resubmitAction.getInPort()));
                     default:
-                        throw new UnsupportedOperationException("Driver does not support move from "
-                                + moveAction.getSrc() + " to "
-                                + moveAction.getDst());
-                    }
+                        throw new UnsupportedOperationException("Driver does not support extension subtype "
+                                + nicira.getSubtype());
                 }
             }
         }
diff --git a/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowEntryBuilder.java b/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowEntryBuilder.java
index 7fb0eac..b75954f 100644
--- a/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowEntryBuilder.java
+++ b/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowEntryBuilder.java
@@ -344,11 +344,8 @@
                                 lookupGridType(circuitSignalID.getGridType()),
                                 lookupChannelSpacing(circuitSignalID.getChannelSpacing()),
                                 circuitSignalID.getChannelNumber(), circuitSignalID.getSpectralWidth())));
-                    }  else if (exp.getExperimenter() == 0x2320) {
-                        if (treatmentInterpreter != null) {
-                            builder.extension(treatmentInterpreter.mapAction(exp),
-                                    deviceId);
-                        }
+                    } else if (treatmentInterpreter != null) {
+                        builder.extension(treatmentInterpreter.mapAction(exp), deviceId);
                     } else {
                         log.warn("Unsupported OFActionExperimenter {}", exp.getExperimenter());
                     }