[CORD-545] Adds ofdpa actions in ONOS core

Change-Id: I98edc27162d7309b9d21f2c939430608e3e85c6e
This commit is contained in:
Pier Ventre 2016-10-22 15:45:36 -07:00 committed by Thomas Vachuska
parent f7d2a2606b
commit ee4a8f21f2
6 changed files with 356 additions and 0 deletions

View File

@ -53,6 +53,10 @@ public final class ExtensionTreatmentType {
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),

View File

@ -25,6 +25,8 @@ import org.onosproject.openflow.controller.ExtensionTreatmentInterpreter;
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 @@ import org.slf4j.LoggerFactory;
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 @@ public class Ofdpa3ExtensionTreatmentInterpreter extends AbstractHandlerBehaviou
} 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 @@ public class Ofdpa3ExtensionTreatmentInterpreter extends AbstractHandlerBehaviou
}
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 @@ public class Ofdpa3ExtensionTreatmentInterpreter extends AbstractHandlerBehaviou
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 @@ public class Ofdpa3ExtensionTreatmentInterpreter extends AbstractHandlerBehaviou
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());

View File

@ -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();
}
}

View File

@ -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();
}
}

View File

@ -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();
}
}

View File

@ -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();
}
}