Committed by
Gerrit Code Review
[ONOS-3377] Add nicira extension of resubmit-table instruction to onos
Change-Id: Ic31c6c5ac2dcde493c8503204f56e1e57ff7210a
Showing
3 changed files
with
124 additions
and
1 deletions
| ... | @@ -35,7 +35,8 @@ public final class ExtensionTreatmentType { | ... | @@ -35,7 +35,8 @@ public final class ExtensionTreatmentType { |
| 35 | // TODO fix type numbers to include experimenter id | 35 | // TODO fix type numbers to include experimenter id |
| 36 | NICIRA_SET_TUNNEL_DST(0), | 36 | NICIRA_SET_TUNNEL_DST(0), |
| 37 | NICIRA_RESUBMIT(1), | 37 | NICIRA_RESUBMIT(1), |
| 38 | - NICIRA_SET_NSH_SPI(32); | 38 | + NICIRA_SET_NSH_SPI(32), |
| 39 | + NICIRA_RESUBMIT_TABLE(14); | ||
| 39 | 40 | ||
| 40 | private ExtensionTreatmentType type; | 41 | private ExtensionTreatmentType type; |
| 41 | 42 | ... | ... |
| ... | @@ -50,6 +50,10 @@ public class NiciraExtensionTreatmentInterpreter extends AbstractHandlerBehaviou | ... | @@ -50,6 +50,10 @@ public class NiciraExtensionTreatmentInterpreter extends AbstractHandlerBehaviou |
| 50 | ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_SPI.type())) { | 50 | ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_SPI.type())) { |
| 51 | return true; | 51 | return true; |
| 52 | } | 52 | } |
| 53 | + if (extensionTreatmentType.equals( | ||
| 54 | + ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_RESUBMIT_TABLE.type())) { | ||
| 55 | + return true; | ||
| 56 | + } | ||
| 53 | return false; | 57 | return false; |
| 54 | } | 58 | } |
| 55 | 59 | ||
| ... | @@ -67,6 +71,9 @@ public class NiciraExtensionTreatmentInterpreter extends AbstractHandlerBehaviou | ... | @@ -67,6 +71,9 @@ public class NiciraExtensionTreatmentInterpreter extends AbstractHandlerBehaviou |
| 67 | if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_SPI.type())) { | 71 | if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_SPI.type())) { |
| 68 | // TODO this will be implemented later | 72 | // TODO this will be implemented later |
| 69 | } | 73 | } |
| 74 | + if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_RESUBMIT_TABLE.type())) { | ||
| 75 | + // TODO this will be implemented later | ||
| 76 | + } | ||
| 70 | return null; | 77 | return null; |
| 71 | } | 78 | } |
| 72 | 79 | ||
| ... | @@ -98,6 +105,9 @@ public class NiciraExtensionTreatmentInterpreter extends AbstractHandlerBehaviou | ... | @@ -98,6 +105,9 @@ public class NiciraExtensionTreatmentInterpreter extends AbstractHandlerBehaviou |
| 98 | if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_SPI.type())) { | 105 | if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_SPI.type())) { |
| 99 | return new NiciraSetNshSpi(); | 106 | return new NiciraSetNshSpi(); |
| 100 | } | 107 | } |
| 108 | + if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_RESUBMIT_TABLE.type())) { | ||
| 109 | + return new NiciraResubmitTable(); | ||
| 110 | + } | ||
| 101 | throw new UnsupportedOperationException( | 111 | throw new UnsupportedOperationException( |
| 102 | "Driver does not support extension type " + type.toString()); | 112 | "Driver does not support extension type " + type.toString()); |
| 103 | } | 113 | } | ... | ... |
| 1 | +/* | ||
| 2 | + * Copyright 2015 Open Networking Laboratory | ||
| 3 | + * | ||
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | + * you may not use this file except in compliance with the License. | ||
| 6 | + * You may obtain a copy of the License at | ||
| 7 | + * | ||
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | + * | ||
| 10 | + * Unless required by applicable law or agreed to in writing, software | ||
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | + * See the License for the specific language governing permissions and | ||
| 14 | + * limitations under the License. | ||
| 15 | + */ | ||
| 16 | + | ||
| 17 | +package org.onosproject.driver.extensions; | ||
| 18 | + | ||
| 19 | +import com.google.common.base.MoreObjects; | ||
| 20 | + | ||
| 21 | +import org.onlab.util.KryoNamespace; | ||
| 22 | +import org.onosproject.net.PortNumber; | ||
| 23 | +import org.onosproject.net.flow.instructions.AbstractExtensionTreatment; | ||
| 24 | +import org.onosproject.net.flow.instructions.ExtensionTreatmentType; | ||
| 25 | +import org.onosproject.store.serializers.PortNumberSerializer; | ||
| 26 | + | ||
| 27 | +import java.util.ArrayList; | ||
| 28 | +import java.util.List; | ||
| 29 | +import java.util.Objects; | ||
| 30 | + | ||
| 31 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
| 32 | + | ||
| 33 | +/** | ||
| 34 | + * Nicira resubmit-table extension instruction. | ||
| 35 | + */ | ||
| 36 | +public class NiciraResubmitTable extends AbstractExtensionTreatment { | ||
| 37 | + | ||
| 38 | + //the list of the in port number(PortNumber) and the table(short) | ||
| 39 | + private List<Object> inPortAndTable = new ArrayList<Object>(); | ||
| 40 | + | ||
| 41 | + private final KryoNamespace appKryo = new KryoNamespace.Builder() | ||
| 42 | + .register(ArrayList.class) | ||
| 43 | + .register(new PortNumberSerializer(), PortNumber.class) | ||
| 44 | + .register(short.class) | ||
| 45 | + .register(byte[].class) | ||
| 46 | + .build(); | ||
| 47 | + | ||
| 48 | + /** | ||
| 49 | + * Creates a new resubmit-table instruction. | ||
| 50 | + */ | ||
| 51 | + NiciraResubmitTable() { | ||
| 52 | + inPortAndTable = null; | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + /** | ||
| 56 | + * Creates a new resubmit-table instruction with a particular inPort and table. | ||
| 57 | + * | ||
| 58 | + * @param inPortAndTable the list of in port number and table | ||
| 59 | + */ | ||
| 60 | + public NiciraResubmitTable(List<Object> inPortAndTable) { | ||
| 61 | + checkNotNull(inPortAndTable); | ||
| 62 | + this.inPortAndTable = inPortAndTable; | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + /** | ||
| 66 | + * Gets the inPortAndTable. | ||
| 67 | + * | ||
| 68 | + * @return inPortAndTable | ||
| 69 | + */ | ||
| 70 | + public List<Object> inPortAndTable() { | ||
| 71 | + return inPortAndTable; | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + @Override | ||
| 75 | + public ExtensionTreatmentType type() { | ||
| 76 | + return ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_RESUBMIT_TABLE.type(); | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + @Override | ||
| 80 | + public void deserialize(byte[] data) { | ||
| 81 | + inPortAndTable = appKryo.deserialize(data); | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + @Override | ||
| 85 | + public byte[] serialize() { | ||
| 86 | + return appKryo.serialize(inPortAndTable); | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + @Override | ||
| 90 | + public int hashCode() { | ||
| 91 | + return Objects.hash(inPortAndTable); | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | + @Override | ||
| 95 | + public boolean equals(Object obj) { | ||
| 96 | + if (this == obj) { | ||
| 97 | + return true; | ||
| 98 | + } | ||
| 99 | + if (obj instanceof NiciraResubmitTable) { | ||
| 100 | + NiciraResubmitTable that = (NiciraResubmitTable) obj; | ||
| 101 | + return Objects.equals(inPortAndTable, that.inPortAndTable); | ||
| 102 | + | ||
| 103 | + } | ||
| 104 | + return false; | ||
| 105 | + } | ||
| 106 | + | ||
| 107 | + @Override | ||
| 108 | + public String toString() { | ||
| 109 | + return MoreObjects.toStringHelper(getClass()) | ||
| 110 | + .add("inPortAndTable", inPortAndTable).toString(); | ||
| 111 | + } | ||
| 112 | +} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or login to post a comment