[CORD-545] Adds ofdpa actions in ONOS core
Change-Id: I98edc27162d7309b9d21f2c939430608e3e85c6e
diff --git a/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionTreatmentType.java b/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionTreatmentType.java
index 01848a7..1371e42 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionTreatmentType.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionTreatmentType.java
@@ -53,6 +53,10 @@
OFDPA_SET_OVID(66),
OFDPA_SET_MPLS_L2_PORT(67),
OFDPA_SET_QOS_INDEX(68),
+ OFDPA_PUSH_L2_HEADER(69),
+ OFDPA_PUSH_CW(70),
+ OFDPA_POP_L2_HEADER(71),
+ OFDPA_POP_CW(72),
NICIRA_TUN_GPE_NP(111),
NICIRA_SET_NSH_SPI(113),
NICIRA_SET_NSH_SI(114),
diff --git a/drivers/default/src/main/java/org/onosproject/driver/extensions/Ofdpa3ExtensionTreatmentInterpreter.java b/drivers/default/src/main/java/org/onosproject/driver/extensions/Ofdpa3ExtensionTreatmentInterpreter.java
index 067e294..907111c 100644
--- a/drivers/default/src/main/java/org/onosproject/driver/extensions/Ofdpa3ExtensionTreatmentInterpreter.java
+++ b/drivers/default/src/main/java/org/onosproject/driver/extensions/Ofdpa3ExtensionTreatmentInterpreter.java
@@ -25,6 +25,8 @@
import org.projectfloodlight.openflow.protocol.OFActionType;
import org.projectfloodlight.openflow.protocol.OFFactory;
import org.projectfloodlight.openflow.protocol.action.OFAction;
+import org.projectfloodlight.openflow.protocol.action.OFActionExperimenter;
+import org.projectfloodlight.openflow.protocol.action.OFActionOfdpa;
import org.projectfloodlight.openflow.protocol.action.OFActionSetField;
import org.projectfloodlight.openflow.protocol.oxm.OFOxm;
import org.projectfloodlight.openflow.protocol.oxm.OFOxmOfdpaMplsL2Port;
@@ -43,6 +45,12 @@
public class Ofdpa3ExtensionTreatmentInterpreter extends AbstractHandlerBehaviour
implements ExtensionTreatmentInterpreter, ExtensionTreatmentResolver {
+ private static final int TYPE_OFDPA = 0x1018;
+ private static final int SUB_TYPE_PUSH_L2_HEADER = 1;
+ private static final int SUB_TYPE_POP_L2_HEADER = 2;
+ private static final int SUB_TYPE_PUSH_CW = 3;
+ private static final int SUB_TYPE_POP_CW = 4;
+
private final Logger log = LoggerFactory.getLogger(getClass());
@Override
@@ -59,6 +67,18 @@
} else if (extensionTreatmentType.equals(
ExtensionTreatmentType.ExtensionTreatmentTypes.OFDPA_SET_QOS_INDEX.type())) {
return true;
+ } else if (extensionTreatmentType.equals(
+ ExtensionTreatmentType.ExtensionTreatmentTypes.OFDPA_PUSH_L2_HEADER.type())) {
+ return true;
+ } else if (extensionTreatmentType.equals(
+ ExtensionTreatmentType.ExtensionTreatmentTypes.OFDPA_PUSH_CW.type())) {
+ return true;
+ } else if (extensionTreatmentType.equals(
+ ExtensionTreatmentType.ExtensionTreatmentTypes.OFDPA_POP_L2_HEADER.type())) {
+ return true;
+ } else if (extensionTreatmentType.equals(
+ ExtensionTreatmentType.ExtensionTreatmentTypes.OFDPA_POP_CW.type())) {
+ return true;
}
return false;
}
@@ -103,6 +123,14 @@
}
throw new UnsupportedOperationException(
"Unexpected ExtensionTreatment: " + extensionTreatment.toString());
+ } else if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.OFDPA_PUSH_L2_HEADER.type())) {
+ return factory.actions().ofdpaPushL2Header();
+ } else if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.OFDPA_PUSH_CW.type())) {
+ return factory.actions().ofdpaPushCw();
+ } else if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.OFDPA_POP_L2_HEADER.type())) {
+ return factory.actions().ofdpaPopL2Header();
+ } else if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.OFDPA_POP_CW.type())) {
+ return factory.actions().ofdpaPopCw();
}
throw new UnsupportedOperationException(
"Unexpected ExtensionTreatment: " + extensionTreatment.toString());
@@ -142,6 +170,26 @@
throw new UnsupportedOperationException(
"Driver does not support extension type " + oxm.getMatchField().id);
}
+ } else if (action.getType().equals(OFActionType.EXPERIMENTER)) {
+ OFActionExperimenter experimenter = (OFActionExperimenter) action;
+ if (Long.valueOf(experimenter.getExperimenter()).intValue() == TYPE_OFDPA) {
+ OFActionOfdpa ofdpa = (OFActionOfdpa) experimenter;
+ switch (ofdpa.getExpType()) {
+ case SUB_TYPE_PUSH_L2_HEADER:
+ return new Ofdpa3PushL2Header();
+ case SUB_TYPE_POP_L2_HEADER:
+ return new Ofdpa3PopL2Header();
+ case SUB_TYPE_PUSH_CW:
+ return new Ofdpa3PushCw();
+ case SUB_TYPE_POP_CW:
+ return new Ofdpa3PopCw();
+ default:
+ throw new UnsupportedOperationException(
+ "Unexpected OFAction: " + action.toString());
+ }
+ }
+ throw new UnsupportedOperationException(
+ "Unexpected OFAction: " + action.toString());
}
throw new UnsupportedOperationException(
"Unexpected OFAction: " + action.toString());
@@ -157,6 +205,14 @@
return new Ofdpa3SetMplsL2Port();
} else if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.OFDPA_SET_QOS_INDEX.type())) {
return new Ofdpa3SetQosIndex();
+ } else if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.OFDPA_PUSH_L2_HEADER.type())) {
+ return new Ofdpa3PushL2Header();
+ } else if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.OFDPA_PUSH_CW.type())) {
+ return new Ofdpa3PushCw();
+ } else if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.OFDPA_POP_L2_HEADER.type())) {
+ return new Ofdpa3PopL2Header();
+ } else if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.OFDPA_POP_CW.type())) {
+ return new Ofdpa3PopCw();
}
throw new UnsupportedOperationException(
"Driver does not support extension type " + type.toString());
diff --git a/drivers/default/src/main/java/org/onosproject/driver/extensions/Ofdpa3PopCw.java b/drivers/default/src/main/java/org/onosproject/driver/extensions/Ofdpa3PopCw.java
new file mode 100644
index 0000000..1dd185e
--- /dev/null
+++ b/drivers/default/src/main/java/org/onosproject/driver/extensions/Ofdpa3PopCw.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * 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.driver.extensions;
+
+import com.google.common.base.MoreObjects;
+import org.onlab.util.KryoNamespace;
+import org.onosproject.net.flow.AbstractExtension;
+import org.onosproject.net.flow.instructions.ExtensionTreatment;
+import org.onosproject.net.flow.instructions.ExtensionTreatmentType;
+
+/**
+ * Ofdpa pop cw extension instruction.
+ */
+public class Ofdpa3PopCw extends AbstractExtension implements ExtensionTreatment {
+
+ private static final KryoNamespace APPKRYO = new KryoNamespace.Builder().build();
+
+ /**
+ * Creates a new pop cw instruction.
+ */
+ public Ofdpa3PopCw() {
+
+ }
+
+ @Override
+ public ExtensionTreatmentType type() {
+ return ExtensionTreatmentType.ExtensionTreatmentTypes.OFDPA_POP_CW.type();
+ }
+
+ @Override
+ public void deserialize(byte[] data) {
+ }
+
+ @Override
+ public byte[] serialize() {
+ return APPKRYO.serialize(true);
+ }
+
+ @Override
+ public int hashCode() {
+ return 1;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof Ofdpa3PopCw) {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .toString();
+ }
+}
diff --git a/drivers/default/src/main/java/org/onosproject/driver/extensions/Ofdpa3PopL2Header.java b/drivers/default/src/main/java/org/onosproject/driver/extensions/Ofdpa3PopL2Header.java
new file mode 100644
index 0000000..03afdae
--- /dev/null
+++ b/drivers/default/src/main/java/org/onosproject/driver/extensions/Ofdpa3PopL2Header.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * 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.driver.extensions;
+
+import com.google.common.base.MoreObjects;
+import org.onlab.util.KryoNamespace;
+import org.onosproject.net.flow.AbstractExtension;
+import org.onosproject.net.flow.instructions.ExtensionTreatment;
+import org.onosproject.net.flow.instructions.ExtensionTreatmentType;
+
+/**
+ * Ofdpa pop l2 header extension instruction.
+ */
+public class Ofdpa3PopL2Header extends AbstractExtension implements ExtensionTreatment {
+
+ private static final KryoNamespace APPKRYO = new KryoNamespace.Builder().build();
+
+ /**
+ * Creates a new pop l2 header instruction.
+ */
+ public Ofdpa3PopL2Header() {
+
+ }
+
+ @Override
+ public ExtensionTreatmentType type() {
+ return ExtensionTreatmentType.ExtensionTreatmentTypes.OFDPA_POP_L2_HEADER.type();
+ }
+
+ @Override
+ public void deserialize(byte[] data) {
+ }
+
+ @Override
+ public byte[] serialize() {
+ return APPKRYO.serialize(true);
+ }
+
+ @Override
+ public int hashCode() {
+ return 1;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof Ofdpa3PopL2Header) {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .toString();
+ }
+}
diff --git a/drivers/default/src/main/java/org/onosproject/driver/extensions/Ofdpa3PushCw.java b/drivers/default/src/main/java/org/onosproject/driver/extensions/Ofdpa3PushCw.java
new file mode 100644
index 0000000..b3d999c
--- /dev/null
+++ b/drivers/default/src/main/java/org/onosproject/driver/extensions/Ofdpa3PushCw.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * 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.driver.extensions;
+
+import com.google.common.base.MoreObjects;
+import org.onlab.util.KryoNamespace;
+import org.onosproject.net.flow.AbstractExtension;
+import org.onosproject.net.flow.instructions.ExtensionTreatment;
+import org.onosproject.net.flow.instructions.ExtensionTreatmentType;
+
+/**
+ * Ofdpa push cw extension instruction.
+ */
+public class Ofdpa3PushCw extends AbstractExtension implements ExtensionTreatment {
+
+ private static final KryoNamespace APPKRYO = new KryoNamespace.Builder().build();
+
+ /**
+ * Creates a new push cw instruction.
+ */
+ public Ofdpa3PushCw() {
+
+ }
+
+ @Override
+ public ExtensionTreatmentType type() {
+ return ExtensionTreatmentType.ExtensionTreatmentTypes.OFDPA_PUSH_CW.type();
+ }
+
+ @Override
+ public void deserialize(byte[] data) {
+ }
+
+ @Override
+ public byte[] serialize() {
+ return APPKRYO.serialize(true);
+ }
+
+ @Override
+ public int hashCode() {
+ return 1;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof Ofdpa3PushCw) {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .toString();
+ }
+}
diff --git a/drivers/default/src/main/java/org/onosproject/driver/extensions/Ofdpa3PushL2Header.java b/drivers/default/src/main/java/org/onosproject/driver/extensions/Ofdpa3PushL2Header.java
new file mode 100644
index 0000000..ac09a82
--- /dev/null
+++ b/drivers/default/src/main/java/org/onosproject/driver/extensions/Ofdpa3PushL2Header.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * 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.driver.extensions;
+
+import com.google.common.base.MoreObjects;
+import org.onlab.util.KryoNamespace;
+import org.onosproject.net.flow.AbstractExtension;
+import org.onosproject.net.flow.instructions.ExtensionTreatment;
+import org.onosproject.net.flow.instructions.ExtensionTreatmentType;
+
+/**
+ * Ofdpa push l2 header extension instruction.
+ */
+public class Ofdpa3PushL2Header extends AbstractExtension implements ExtensionTreatment {
+
+ private static final KryoNamespace APPKRYO = new KryoNamespace.Builder().build();
+
+ /**
+ * Creates a new push l2 header instruction.
+ */
+ public Ofdpa3PushL2Header() {
+
+ }
+
+ @Override
+ public ExtensionTreatmentType type() {
+ return ExtensionTreatmentType.ExtensionTreatmentTypes.OFDPA_PUSH_L2_HEADER.type();
+ }
+
+ @Override
+ public void deserialize(byte[] data) {
+ }
+
+ @Override
+ public byte[] serialize() {
+ return APPKRYO.serialize(true);
+ }
+
+ @Override
+ public int hashCode() {
+ return 1;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof Ofdpa3PushL2Header) {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .toString();
+ }
+}