Marc De Leenheer
Committed by Gerrit Code Review

Add OCh signal type to optical path intent.

Revert changes to LINC-OE specialized flowmod handling.

Change-Id: Ic4f333a44b7cd8a3111bfcba87ea909943eec56d
...@@ -21,9 +21,9 @@ package org.onosproject.net; ...@@ -21,9 +21,9 @@ package org.onosproject.net;
21 */ 21 */
22 public enum OchSignalType { 22 public enum OchSignalType {
23 /** 23 /**
24 - * Represents fix grid. 24 + * Represents fixed grid.
25 */ 25 */
26 - FIX_GRID, 26 + FIXED_GRID,
27 27
28 /** 28 /**
29 * Represents flex grid. 29 * Represents flex grid.
......
...@@ -389,6 +389,7 @@ public final class Criteria { ...@@ -389,6 +389,7 @@ public final class Criteria {
389 * @param sigType optical signal type (8 bits unsigned integer) 389 * @param sigType optical signal type (8 bits unsigned integer)
390 * @return match criterion 390 * @return match criterion
391 */ 391 */
392 + @Deprecated
392 public static Criterion matchOpticalSignalType(short sigType) { 393 public static Criterion matchOpticalSignalType(short sigType) {
393 return new OpticalSignalTypeCriterion(sigType, Type.OCH_SIGTYPE); 394 return new OpticalSignalTypeCriterion(sigType, Type.OCH_SIGTYPE);
394 } 395 }
......
...@@ -23,6 +23,7 @@ import static com.google.common.base.MoreObjects.toStringHelper; ...@@ -23,6 +23,7 @@ import static com.google.common.base.MoreObjects.toStringHelper;
23 * Implementation of optical signal type criterion (8 bits unsigned 23 * Implementation of optical signal type criterion (8 bits unsigned
24 * integer). 24 * integer).
25 */ 25 */
26 +@Deprecated
26 public final class OpticalSignalTypeCriterion implements Criterion { 27 public final class OpticalSignalTypeCriterion implements Criterion {
27 private static final short MASK = 0xff; 28 private static final short MASK = 0xff;
28 private final short signalType; // Signal type value: 8 bits 29 private final short signalType; // Signal type value: 8 bits
......
...@@ -18,6 +18,7 @@ package org.onosproject.net.intent; ...@@ -18,6 +18,7 @@ package org.onosproject.net.intent;
18 import org.onosproject.core.ApplicationId; 18 import org.onosproject.core.ApplicationId;
19 import org.onosproject.net.ConnectPoint; 19 import org.onosproject.net.ConnectPoint;
20 import org.onosproject.net.OchSignal; 20 import org.onosproject.net.OchSignal;
21 +import org.onosproject.net.OchSignalType;
21 import org.onosproject.net.Path; 22 import org.onosproject.net.Path;
22 23
23 import com.google.common.base.MoreObjects; 24 import com.google.common.base.MoreObjects;
...@@ -31,6 +32,7 @@ public final class OpticalPathIntent extends Intent { ...@@ -31,6 +32,7 @@ public final class OpticalPathIntent extends Intent {
31 private final ConnectPoint dst; 32 private final ConnectPoint dst;
32 private final Path path; 33 private final Path path;
33 private final OchSignal lambda; 34 private final OchSignal lambda;
35 + private final OchSignalType signalType;
34 36
35 private OpticalPathIntent(ApplicationId appId, 37 private OpticalPathIntent(ApplicationId appId,
36 Key key, 38 Key key,
...@@ -38,12 +40,14 @@ public final class OpticalPathIntent extends Intent { ...@@ -38,12 +40,14 @@ public final class OpticalPathIntent extends Intent {
38 ConnectPoint dst, 40 ConnectPoint dst,
39 Path path, 41 Path path,
40 OchSignal lambda, 42 OchSignal lambda,
43 + OchSignalType signalType,
41 int priority) { 44 int priority) {
42 super(appId, key, ImmutableSet.copyOf(path.links()), priority); 45 super(appId, key, ImmutableSet.copyOf(path.links()), priority);
43 this.src = checkNotNull(src); 46 this.src = checkNotNull(src);
44 this.dst = checkNotNull(dst); 47 this.dst = checkNotNull(dst);
45 this.path = checkNotNull(path); 48 this.path = checkNotNull(path);
46 this.lambda = checkNotNull(lambda); 49 this.lambda = checkNotNull(lambda);
50 + this.signalType = checkNotNull(signalType);
47 } 51 }
48 52
49 protected OpticalPathIntent() { 53 protected OpticalPathIntent() {
...@@ -51,6 +55,7 @@ public final class OpticalPathIntent extends Intent { ...@@ -51,6 +55,7 @@ public final class OpticalPathIntent extends Intent {
51 this.dst = null; 55 this.dst = null;
52 this.path = null; 56 this.path = null;
53 this.lambda = null; 57 this.lambda = null;
58 + this.signalType = null;
54 } 59 }
55 60
56 /** 61 /**
...@@ -71,6 +76,7 @@ public final class OpticalPathIntent extends Intent { ...@@ -71,6 +76,7 @@ public final class OpticalPathIntent extends Intent {
71 private ConnectPoint dst; 76 private ConnectPoint dst;
72 private Path path; 77 private Path path;
73 private OchSignal lambda; 78 private OchSignal lambda;
79 + private OchSignalType signalType;
74 Key key; 80 Key key;
75 81
76 @Override 82 @Override
...@@ -133,6 +139,17 @@ public final class OpticalPathIntent extends Intent { ...@@ -133,6 +139,17 @@ public final class OpticalPathIntent extends Intent {
133 } 139 }
134 140
135 /** 141 /**
142 + * Sets the optical signal type for the intent that will be built.
143 + *
144 + * @param signalType the optical signal type
145 + * @return this builder
146 + */
147 + public Builder signalType(OchSignalType signalType) {
148 + this.signalType = signalType;
149 + return this;
150 + }
151 +
152 + /**
136 * Builds an optical path intent from the accumulated parameters. 153 * Builds an optical path intent from the accumulated parameters.
137 * 154 *
138 * @return optical path intent 155 * @return optical path intent
...@@ -146,6 +163,7 @@ public final class OpticalPathIntent extends Intent { ...@@ -146,6 +163,7 @@ public final class OpticalPathIntent extends Intent {
146 dst, 163 dst,
147 path, 164 path,
148 lambda, 165 lambda,
166 + signalType,
149 priority 167 priority
150 ); 168 );
151 } 169 }
...@@ -168,6 +186,10 @@ public final class OpticalPathIntent extends Intent { ...@@ -168,6 +186,10 @@ public final class OpticalPathIntent extends Intent {
168 return lambda; 186 return lambda;
169 } 187 }
170 188
189 + public OchSignalType signalType() {
190 + return signalType;
191 + }
192 +
171 @Override 193 @Override
172 public String toString() { 194 public String toString() {
173 return MoreObjects.toStringHelper(getClass()) 195 return MoreObjects.toStringHelper(getClass())
...@@ -179,6 +201,7 @@ public final class OpticalPathIntent extends Intent { ...@@ -179,6 +201,7 @@ public final class OpticalPathIntent extends Intent {
179 .add("egressPort", dst) 201 .add("egressPort", dst)
180 .add("path", path) 202 .add("path", path)
181 .add("lambda", lambda) 203 .add("lambda", lambda)
204 + .add("signalType", signalType)
182 .toString(); 205 .toString();
183 } 206 }
184 } 207 }
......
...@@ -221,8 +221,8 @@ public class CriteriaTest { ...@@ -221,8 +221,8 @@ public class CriteriaTest {
221 Criterion sameAsMatchLambda1 = Criteria.matchLambda(lambda1); 221 Criterion sameAsMatchLambda1 = Criteria.matchLambda(lambda1);
222 Criterion matchLambda2 = Criteria.matchLambda(lambda2); 222 Criterion matchLambda2 = Criteria.matchLambda(lambda2);
223 223
224 - Criterion matchOchSignalType1 = Criteria.matchOchSignalType(OchSignalType.FIX_GRID); 224 + Criterion matchOchSignalType1 = Criteria.matchOchSignalType(OchSignalType.FIXED_GRID);
225 - Criterion sameAsMatchOchSignalType1 = Criteria.matchOchSignalType(OchSignalType.FIX_GRID); 225 + Criterion sameAsMatchOchSignalType1 = Criteria.matchOchSignalType(OchSignalType.FIXED_GRID);
226 Criterion matchOchSignalType2 = Criteria.matchOchSignalType(OchSignalType.FLEX_GRID); 226 Criterion matchOchSignalType2 = Criteria.matchOchSignalType(OchSignalType.FLEX_GRID);
227 227
228 Criterion matchIndexedLambda1 = Criteria.matchLambda(Lambda.indexedLambda(1)); 228 Criterion matchIndexedLambda1 = Criteria.matchLambda(Lambda.indexedLambda(1));
......
...@@ -18,7 +18,7 @@ package org.onosproject.net.intent; ...@@ -18,7 +18,7 @@ package org.onosproject.net.intent;
18 import org.hamcrest.Matchers; 18 import org.hamcrest.Matchers;
19 import org.junit.Before; 19 import org.junit.Before;
20 import org.junit.Test; 20 import org.junit.Test;
21 -import org.onosproject.net.OchSignal; 21 +import org.onosproject.net.OchSignalType;
22 import org.onosproject.net.Path; 22 import org.onosproject.net.Path;
23 23
24 import com.google.common.testing.EqualsTester; 24 import com.google.common.testing.EqualsTester;
...@@ -39,7 +39,6 @@ public class OpticalPathIntentTest extends AbstractIntentTest { ...@@ -39,7 +39,6 @@ public class OpticalPathIntentTest extends AbstractIntentTest {
39 OpticalPathIntent intent1; 39 OpticalPathIntent intent1;
40 OpticalPathIntent intent2; 40 OpticalPathIntent intent2;
41 Path defaultPath; 41 Path defaultPath;
42 - OchSignal lambda;
43 42
44 @Before 43 @Before
45 public void opticalPathIntentTestSetUp() { 44 public void opticalPathIntentTestSetUp() {
...@@ -50,6 +49,7 @@ public class OpticalPathIntentTest extends AbstractIntentTest { ...@@ -50,6 +49,7 @@ public class OpticalPathIntentTest extends AbstractIntentTest {
50 .dst(connectPoint("two", 2)) 49 .dst(connectPoint("two", 2))
51 .path(defaultPath) 50 .path(defaultPath)
52 .lambda(createLambda()) 51 .lambda(createLambda())
52 + .signalType(OchSignalType.FIXED_GRID)
53 .priority(PRIORITY) 53 .priority(PRIORITY)
54 .build(); 54 .build();
55 55
...@@ -59,6 +59,7 @@ public class OpticalPathIntentTest extends AbstractIntentTest { ...@@ -59,6 +59,7 @@ public class OpticalPathIntentTest extends AbstractIntentTest {
59 .dst(connectPoint("one", 2)) 59 .dst(connectPoint("one", 2))
60 .path(defaultPath) 60 .path(defaultPath)
61 .lambda(createLambda()) 61 .lambda(createLambda())
62 + .signalType(OchSignalType.FIXED_GRID)
62 .priority(PRIORITY) 63 .priority(PRIORITY)
63 .build(); 64 .build();
64 } 65 }
...@@ -83,7 +84,7 @@ public class OpticalPathIntentTest extends AbstractIntentTest { ...@@ -83,7 +84,7 @@ public class OpticalPathIntentTest extends AbstractIntentTest {
83 } 84 }
84 85
85 /** 86 /**
86 - * Checks that the optical path ntent objects are created correctly. 87 + * Checks that the optical path intent objects are created correctly.
87 */ 88 */
88 @Test 89 @Test
89 public void testContents() { 90 public void testContents() {
......
...@@ -31,6 +31,7 @@ import org.onosproject.net.GridType; ...@@ -31,6 +31,7 @@ import org.onosproject.net.GridType;
31 import org.onosproject.net.Link; 31 import org.onosproject.net.Link;
32 import org.onosproject.net.OchPort; 32 import org.onosproject.net.OchPort;
33 import org.onosproject.net.OchSignal; 33 import org.onosproject.net.OchSignal;
34 +import org.onosproject.net.OchSignalType;
34 import org.onosproject.net.OmsPort; 35 import org.onosproject.net.OmsPort;
35 import org.onosproject.net.Path; 36 import org.onosproject.net.Path;
36 import org.onosproject.net.Port; 37 import org.onosproject.net.Port;
...@@ -127,6 +128,8 @@ public class OpticalConnectivityIntentCompiler implements IntentCompiler<Optical ...@@ -127,6 +128,8 @@ public class OpticalConnectivityIntentCompiler implements IntentCompiler<Optical
127 // Create installable optical path intent 128 // Create installable optical path intent
128 LambdaResourceAllocation lambdaAlloc = getWavelength(path, linkAllocs); 129 LambdaResourceAllocation lambdaAlloc = getWavelength(path, linkAllocs);
129 OchSignal ochSignal = getOchSignal(lambdaAlloc, omsPort.minFrequency(), omsPort.grid()); 130 OchSignal ochSignal = getOchSignal(lambdaAlloc, omsPort.minFrequency(), omsPort.grid());
131 + // Only support fixed grid for now
132 + OchSignalType signalType = OchSignalType.FIXED_GRID;
130 133
131 Intent newIntent = OpticalPathIntent.builder() 134 Intent newIntent = OpticalPathIntent.builder()
132 .appId(intent.appId()) 135 .appId(intent.appId())
...@@ -134,6 +137,7 @@ public class OpticalConnectivityIntentCompiler implements IntentCompiler<Optical ...@@ -134,6 +137,7 @@ public class OpticalConnectivityIntentCompiler implements IntentCompiler<Optical
134 .dst(intent.getDst()) 137 .dst(intent.getDst())
135 .path(path) 138 .path(path)
136 .lambda(ochSignal) 139 .lambda(ochSignal)
140 + .signalType(signalType)
137 .build(); 141 .build();
138 142
139 return ImmutableList.of(newIntent); 143 return ImmutableList.of(newIntent);
......
...@@ -103,6 +103,7 @@ public class OpticalPathIntentCompiler implements IntentCompiler<OpticalPathInte ...@@ -103,6 +103,7 @@ public class OpticalPathIntentCompiler implements IntentCompiler<OpticalPathInte
103 current = link.dst(); 103 current = link.dst();
104 selectorBuilder.matchInPort(link.dst().port()); 104 selectorBuilder.matchInPort(link.dst().port());
105 selectorBuilder.add(Criteria.matchLambda(intent.lambda())); 105 selectorBuilder.add(Criteria.matchLambda(intent.lambda()));
106 + selectorBuilder.add(Criteria.matchOchSignalType(intent.signalType()));
106 } 107 }
107 108
108 // Build the egress ROADM rule 109 // Build the egress ROADM rule
......
...@@ -26,6 +26,7 @@ import org.onosproject.net.ConnectPoint; ...@@ -26,6 +26,7 @@ import org.onosproject.net.ConnectPoint;
26 import org.onosproject.net.DefaultLink; 26 import org.onosproject.net.DefaultLink;
27 import org.onosproject.net.DefaultPath; 27 import org.onosproject.net.DefaultPath;
28 import org.onosproject.net.Link; 28 import org.onosproject.net.Link;
29 +import org.onosproject.net.OchSignalType;
29 import org.onosproject.net.flow.DefaultTrafficSelector; 30 import org.onosproject.net.flow.DefaultTrafficSelector;
30 import org.onosproject.net.flow.DefaultTrafficTreatment; 31 import org.onosproject.net.flow.DefaultTrafficTreatment;
31 import org.onosproject.net.flow.FlowRule; 32 import org.onosproject.net.flow.FlowRule;
...@@ -95,6 +96,7 @@ public class OpticalPathIntentCompilerTest { ...@@ -95,6 +96,7 @@ public class OpticalPathIntentCompilerTest {
95 .dst(d3p1) 96 .dst(d3p1)
96 .path(new DefaultPath(PID, links, hops)) 97 .path(new DefaultPath(PID, links, hops))
97 .lambda(createLambda()) 98 .lambda(createLambda())
99 + .signalType(OchSignalType.FIXED_GRID)
98 .build(); 100 .build();
99 intentExtensionService = createMock(IntentExtensionService.class); 101 intentExtensionService = createMock(IntentExtensionService.class);
100 intentExtensionService.registerCompiler(OpticalPathIntent.class, sut); 102 intentExtensionService.registerCompiler(OpticalPathIntent.class, sut);
......
...@@ -24,62 +24,30 @@ import org.onosproject.openflow.controller.driver.SwitchDriverSubHandshakeNotSta ...@@ -24,62 +24,30 @@ import org.onosproject.openflow.controller.driver.SwitchDriverSubHandshakeNotSta
24 import org.projectfloodlight.openflow.protocol.OFCircuitPortStatus; 24 import org.projectfloodlight.openflow.protocol.OFCircuitPortStatus;
25 import org.projectfloodlight.openflow.protocol.OFCircuitPortsReply; 25 import org.projectfloodlight.openflow.protocol.OFCircuitPortsReply;
26 import org.projectfloodlight.openflow.protocol.OFCircuitPortsRequest; 26 import org.projectfloodlight.openflow.protocol.OFCircuitPortsRequest;
27 -import org.projectfloodlight.openflow.protocol.OFFactories;
28 -import org.projectfloodlight.openflow.protocol.OFFactory;
29 -import org.projectfloodlight.openflow.protocol.OFFlowMod;
30 -import org.projectfloodlight.openflow.protocol.OFFlowModCommand;
31 -import org.projectfloodlight.openflow.protocol.OFInstructionType;
32 import org.projectfloodlight.openflow.protocol.OFMessage; 27 import org.projectfloodlight.openflow.protocol.OFMessage;
33 import org.projectfloodlight.openflow.protocol.OFObject; 28 import org.projectfloodlight.openflow.protocol.OFObject;
34 import org.projectfloodlight.openflow.protocol.OFPortDesc; 29 import org.projectfloodlight.openflow.protocol.OFPortDesc;
35 import org.projectfloodlight.openflow.protocol.OFStatsReply; 30 import org.projectfloodlight.openflow.protocol.OFStatsReply;
36 import org.projectfloodlight.openflow.protocol.OFStatsType; 31 import org.projectfloodlight.openflow.protocol.OFStatsType;
37 -import org.projectfloodlight.openflow.protocol.OFType;
38 -import org.projectfloodlight.openflow.protocol.OFVersion;
39 -import org.projectfloodlight.openflow.protocol.action.OFAction;
40 -import org.projectfloodlight.openflow.protocol.action.OFActionCircuit;
41 -import org.projectfloodlight.openflow.protocol.instruction.OFInstruction;
42 -import org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions;
43 -import org.projectfloodlight.openflow.protocol.match.Match;
44 -import org.projectfloodlight.openflow.protocol.match.MatchField;
45 -import org.projectfloodlight.openflow.protocol.OFActionType;
46 -import org.projectfloodlight.openflow.types.CircuitSignalID;
47 -import org.projectfloodlight.openflow.types.OFPort;
48 -import org.projectfloodlight.openflow.types.U8;
49 32
50 import com.google.common.collect.ImmutableList; 33 import com.google.common.collect.ImmutableList;
51 import com.google.common.collect.ImmutableSet; 34 import com.google.common.collect.ImmutableSet;
52 35
53 import java.io.IOException; 36 import java.io.IOException;
54 -import java.util.Collections;
55 import java.util.List; 37 import java.util.List;
56 -import java.util.Map;
57 -import java.util.ArrayList;
58 import java.util.Set; 38 import java.util.Set;
59 -import java.util.BitSet;
60 -import java.util.stream.Collectors;
61 import java.util.concurrent.atomic.AtomicBoolean; 39 import java.util.concurrent.atomic.AtomicBoolean;
62 -import java.util.concurrent.ConcurrentMap;
63 -import java.util.concurrent.ConcurrentHashMap;
64 -
65 -import static org.projectfloodlight.openflow.protocol.OFFlowMod.Builder;
66 40
67 /** 41 /**
68 * LINC-OE Optical Emulator switch class. 42 * LINC-OE Optical Emulator switch class.
69 */ 43 */
70 public class OFOpticalSwitchImplLINC13 44 public class OFOpticalSwitchImplLINC13
71 extends AbstractOpenFlowSwitch implements OpenFlowOpticalSwitch { 45 extends AbstractOpenFlowSwitch implements OpenFlowOpticalSwitch {
72 - // default number of lambdas, assuming 50GHz channels.
73 - private static final int NUM_CHLS = 80;
74 - private final OFFactory factory = OFFactories.getFactory(OFVersion.OF_13);
75 46
76 private final AtomicBoolean driverHandshakeComplete = new AtomicBoolean(false); 47 private final AtomicBoolean driverHandshakeComplete = new AtomicBoolean(false);
77 private long barrierXidToWaitFor = -1; 48 private long barrierXidToWaitFor = -1;
78 49
79 private OFCircuitPortsReply wPorts; 50 private OFCircuitPortsReply wPorts;
80 - // book-keeping maps for allocated Linc-OE lambdas
81 - protected final ConcurrentMap<OFPort, BitSet> portChannelMap = new ConcurrentHashMap<>();
82 - protected final ConcurrentMap<Match, Integer> matchMap = new ConcurrentHashMap<>();
83 51
84 @Override 52 @Override
85 public void startDriverHandshake() { 53 public void startDriverHandshake() {
...@@ -201,139 +169,4 @@ public class OFOpticalSwitchImplLINC13 ...@@ -201,139 +169,4 @@ public class OFOpticalSwitchImplLINC13
201 public Set<PortDescPropertyType> getPortTypes() { 169 public Set<PortDescPropertyType> getPortTypes() {
202 return ImmutableSet.of(PortDescPropertyType.OPTICAL_TRANSPORT); 170 return ImmutableSet.of(PortDescPropertyType.OPTICAL_TRANSPORT);
203 } 171 }
204 -
205 - @Override
206 - public OFMessage prepareMessage(OFMessage msg) {
207 - if (OFVersion.OF_13 != msg.getVersion() || msg.getType() != OFType.FLOW_MOD) {
208 - return msg;
209 - }
210 - OFFlowMod fm = (OFFlowMod) msg;
211 - Match match = fm.getMatch();
212 - // Don't touch FlowMods that aren't Optical-related.
213 - if (match.get(MatchField.OCH_SIGTYPE) == null) {
214 - return msg;
215 - }
216 -
217 - OFMessage newFM;
218 - Builder builder = null;
219 - List<OFAction> actions = new ArrayList<>();
220 - if (fm.getCommand() == OFFlowModCommand.ADD) {
221 - builder = factory.buildFlowAdd();
222 - int lambda = allocateLambda(match.get(MatchField.IN_PORT), match);
223 - CircuitSignalID sigid = new CircuitSignalID((byte) 1, (byte) 2, (short) lambda, (short) 1);
224 - List<OFInstruction> instructions = fm.getInstructions();
225 -
226 - newFM = buildFlowMod(builder, fm, buildMatch(match, sigid), buildActions(instructions, sigid));
227 - } else if (fm.getCommand() == OFFlowModCommand.DELETE) {
228 - builder = factory.buildFlowDelete();
229 - int lambda = freeLambda(match.get(MatchField.IN_PORT), match);
230 - CircuitSignalID sigid = new CircuitSignalID((byte) 1, (byte) 2, (short) lambda, (short) 1);
231 -
232 - newFM = buildFlowMod(builder, fm, buildMatch(match, sigid), actions);
233 - } else {
234 - newFM = msg;
235 - }
236 - log.debug("new FM = {}", newFM);
237 - return newFM;
238 - }
239 -
240 - // fetch the next available channel as the flat lambda value, or the lambda
241 - // associated with a port/match combination
242 - private int allocateLambda(OFPort port, Match match) {
243 - Integer lambda = null;
244 - synchronized (this) {
245 - BitSet channels = portChannelMap.getOrDefault(port, new BitSet(NUM_CHLS + 1));
246 - lambda = matchMap.get(match);
247 - if (lambda == null) {
248 - // TODO : double check behavior when bitset is full
249 - // Linc lambdas start at 1.
250 - lambda = channels.nextClearBit(1);
251 - channels.set(lambda);
252 - portChannelMap.put(port, channels);
253 - matchMap.put(match, lambda);
254 - }
255 - }
256 - return lambda;
257 - }
258 -
259 - // free lambda that was mapped to Port/Match combination and return its
260 - // value to caller.
261 - private int freeLambda(OFPort port, Match match) {
262 - synchronized (this) {
263 - Integer lambda = matchMap.get(match);
264 - if (lambda != null) {
265 - portChannelMap.get(port).clear(lambda);
266 - return lambda;
267 - }
268 - // 1 is a sane-ish default for Linc.
269 - return 1;
270 - }
271 - }
272 -
273 - // build matches - *tons of assumptions are made here based on Linc-OE's behavior.*
274 - // gridType = 1 (DWDM)
275 - // channelSpacing = 2 (50GHz)
276 - // spectralWidth = 1 (fixed grid default value)
277 - private Match buildMatch(Match original, CircuitSignalID sigid) {
278 - Match.Builder mBuilder = factory.buildMatch();
279 -
280 - original.getMatchFields().forEach(mf -> {
281 - String name = mf.getName();
282 - if (MatchField.OCH_SIGID.getName().equals(name)) {
283 - mBuilder.setExact(MatchField.OCH_SIGID, sigid);
284 - } else if (MatchField.OCH_SIGTYPE.getName().equals(name)) {
285 - mBuilder.setExact(MatchField.OCH_SIGTYPE, U8.of((short) 1));
286 - } else if (MatchField.IN_PORT.getName().equals(name)) {
287 - mBuilder.setExact(MatchField.IN_PORT, original.get(MatchField.IN_PORT));
288 - }
289 - });
290 -
291 - return mBuilder.build();
292 - }
293 -
294 - private List<OFAction> buildActions(List<OFInstruction> iList, CircuitSignalID sigid) {
295 - Map<OFInstructionType, OFInstruction> instructions = iList.stream()
296 - .collect(Collectors.toMap(OFInstruction::getType, inst -> inst));
297 -
298 - OFInstruction inst = instructions.get(OFInstructionType.APPLY_ACTIONS);
299 - if (inst == null) {
300 - return Collections.emptyList();
301 - }
302 -
303 - List<OFAction> actions = new ArrayList<>();
304 - OFInstructionApplyActions iaa = (OFInstructionApplyActions) inst;
305 - if (iaa.getActions() == null) {
306 - return actions;
307 - }
308 - iaa.getActions().forEach(action -> {
309 - if (OFActionType.EXPERIMENTER == action.getType()) {
310 - OFActionCircuit.Builder cBuilder = factory.actions().buildCircuit()
311 - .setField(factory.oxms()
312 - .buildOchSigid()
313 - .setValue(sigid)
314 - .build());
315 - actions.add(cBuilder.build());
316 - } else {
317 - actions.add(action);
318 - }
319 - });
320 - return actions;
321 - }
322 -
323 - private OFMessage buildFlowMod(Builder builder, OFFlowMod fm, Match m, List<OFAction> act) {
324 - return builder
325 - .setXid(fm.getXid())
326 - .setCookie(fm.getCookie())
327 - .setCookieMask(fm.getCookieMask())
328 - .setTableId(fm.getTableId())
329 - .setIdleTimeout(fm.getIdleTimeout())
330 - .setHardTimeout(fm.getHardTimeout())
331 - .setBufferId(fm.getBufferId())
332 - .setOutPort(fm.getOutPort())
333 - .setOutGroup(fm.getOutGroup())
334 - .setFlags(fm.getFlags())
335 - .setMatch(m)
336 - .setActions(act)
337 - .build();
338 - }
339 } 172 }
......
...@@ -148,16 +148,4 @@ public interface OpenFlowSwitch { ...@@ -148,16 +148,4 @@ public interface OpenFlowSwitch {
148 * @return string representation of the connection to the device 148 * @return string representation of the connection to the device
149 */ 149 */
150 String channelId(); 150 String channelId();
151 -
152 - /**
153 - * Prepares a message to be sent, if necessary. Default is to do nothing,
154 - * since most Devices do not need to pre-process a message that's about to
155 - * be sent.
156 - *
157 - * @param msg The message to prepare for sending
158 - * @return the prepared OFMessage
159 - */
160 - default OFMessage prepareMessage(OFMessage msg) {
161 - return msg;
162 - }
163 } 151 }
......
...@@ -97,7 +97,7 @@ public abstract class AbstractOpenFlowSwitch extends AbstractHandlerBehaviour ...@@ -97,7 +97,7 @@ public abstract class AbstractOpenFlowSwitch extends AbstractHandlerBehaviour
97 @Override 97 @Override
98 public final void sendMsg(OFMessage m) { 98 public final void sendMsg(OFMessage m) {
99 if (role == RoleState.MASTER && channel.isWritable()) { 99 if (role == RoleState.MASTER && channel.isWritable()) {
100 - channel.write(Collections.singletonList(prepareMessage(m))); 100 + channel.write(Collections.singletonList(m));
101 } 101 }
102 } 102 }
103 103
......
...@@ -40,7 +40,7 @@ import org.onosproject.net.flow.criteria.Icmpv6TypeCriterion; ...@@ -40,7 +40,7 @@ import org.onosproject.net.flow.criteria.Icmpv6TypeCriterion;
40 import org.onosproject.net.flow.criteria.MetadataCriterion; 40 import org.onosproject.net.flow.criteria.MetadataCriterion;
41 import org.onosproject.net.flow.criteria.MplsCriterion; 41 import org.onosproject.net.flow.criteria.MplsCriterion;
42 import org.onosproject.net.flow.criteria.OchSignalCriterion; 42 import org.onosproject.net.flow.criteria.OchSignalCriterion;
43 -import org.onosproject.net.flow.criteria.OpticalSignalTypeCriterion; 43 +import org.onosproject.net.flow.criteria.OchSignalTypeCriterion;
44 import org.onosproject.net.flow.criteria.PortCriterion; 44 import org.onosproject.net.flow.criteria.PortCriterion;
45 import org.onosproject.net.flow.criteria.SctpPortCriterion; 45 import org.onosproject.net.flow.criteria.SctpPortCriterion;
46 import org.onosproject.net.flow.criteria.TcpPortCriterion; 46 import org.onosproject.net.flow.criteria.TcpPortCriterion;
...@@ -388,10 +388,9 @@ public abstract class FlowModBuilder { ...@@ -388,10 +388,9 @@ public abstract class FlowModBuilder {
388 } 388 }
389 break; 389 break;
390 case OCH_SIGTYPE: 390 case OCH_SIGTYPE:
391 - OpticalSignalTypeCriterion sc = 391 + OchSignalTypeCriterion sc = (OchSignalTypeCriterion) c;
392 - (OpticalSignalTypeCriterion) c; 392 + byte signalType = FlowModBuilderHelper.convertOchSignalType(sc.signalType());
393 - mBuilder.setExact(MatchField.OCH_SIGTYPE, 393 + mBuilder.setExact(MatchField.OCH_SIGTYPE, U8.of(signalType));
394 - U8.of(sc.signalType()));
395 break; 394 break;
396 case ARP_OP: 395 case ARP_OP:
397 case ARP_SHA: 396 case ARP_SHA:
......
...@@ -17,6 +17,7 @@ package org.onosproject.provider.of.flow.impl; ...@@ -17,6 +17,7 @@ package org.onosproject.provider.of.flow.impl;
17 17
18 import org.onosproject.net.ChannelSpacing; 18 import org.onosproject.net.ChannelSpacing;
19 import org.onosproject.net.GridType; 19 import org.onosproject.net.GridType;
20 +import org.onosproject.net.OchSignalType;
20 import org.slf4j.Logger; 21 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory; 22 import org.slf4j.LoggerFactory;
22 23
...@@ -87,4 +88,22 @@ final class FlowModBuilderHelper { ...@@ -87,4 +88,22 @@ final class FlowModBuilderHelper {
87 throw new UnsupportedChannelSpacingException(spacing); 88 throw new UnsupportedChannelSpacingException(spacing);
88 } 89 }
89 } 90 }
91 +
92 + /**
93 + * Converts a {@link OchSignalType} to the corresponding byte value.
94 + *
95 + * @param signalType optical signal type
96 + * @return byte value corresponding to the specified OCh signal type
97 + */
98 + static byte convertOchSignalType(OchSignalType signalType) {
99 + switch (signalType) {
100 + case FIXED_GRID:
101 + return (byte) 1;
102 + case FLEX_GRID:
103 + return (byte) 2;
104 + default:
105 + log.info("OchSignalType {} is not supported", signalType);
106 + return (byte) 0;
107 + }
108 + }
90 } 109 }
......
...@@ -67,7 +67,7 @@ from mininet.link import Link, Intf ...@@ -67,7 +67,7 @@ from mininet.link import Link, Intf
67 from mininet.cli import CLI 67 from mininet.cli import CLI
68 68
69 # Sleep time and timeout values in seconds 69 # Sleep time and timeout values in seconds
70 -SLEEP_TIME = .5 70 +SLEEP_TIME = 2
71 TIMEOUT = 60 71 TIMEOUT = 60
72 72
73 class OpticalSwitch(Switch): 73 class OpticalSwitch(Switch):
......