Praseed Balakrishnan

Removing hardcoded MA for optical.

...@@ -11,24 +11,12 @@ import org.projectfloodlight.openflow.protocol.OFCircuitPortsReply; ...@@ -11,24 +11,12 @@ import org.projectfloodlight.openflow.protocol.OFCircuitPortsReply;
11 import org.projectfloodlight.openflow.protocol.OFCircuitPortsRequest; 11 import org.projectfloodlight.openflow.protocol.OFCircuitPortsRequest;
12 import org.projectfloodlight.openflow.protocol.OFDescStatsReply; 12 import org.projectfloodlight.openflow.protocol.OFDescStatsReply;
13 import org.projectfloodlight.openflow.protocol.OFErrorMsg; 13 import org.projectfloodlight.openflow.protocol.OFErrorMsg;
14 -import org.projectfloodlight.openflow.protocol.OFMatchV3;
15 import org.projectfloodlight.openflow.protocol.OFMessage; 14 import org.projectfloodlight.openflow.protocol.OFMessage;
16 -import org.projectfloodlight.openflow.protocol.OFOxmList;
17 import org.projectfloodlight.openflow.protocol.OFPortDesc; 15 import org.projectfloodlight.openflow.protocol.OFPortDesc;
18 import org.projectfloodlight.openflow.protocol.OFPortDescStatsReply; 16 import org.projectfloodlight.openflow.protocol.OFPortDescStatsReply;
19 import org.projectfloodlight.openflow.protocol.OFPortOptical; 17 import org.projectfloodlight.openflow.protocol.OFPortOptical;
20 import org.projectfloodlight.openflow.protocol.OFStatsReply; 18 import org.projectfloodlight.openflow.protocol.OFStatsReply;
21 import org.projectfloodlight.openflow.protocol.OFStatsType; 19 import org.projectfloodlight.openflow.protocol.OFStatsType;
22 -import org.projectfloodlight.openflow.protocol.action.OFAction;
23 -import org.projectfloodlight.openflow.protocol.action.OFActionCircuit;
24 -import org.projectfloodlight.openflow.protocol.instruction.OFInstruction;
25 -import org.projectfloodlight.openflow.protocol.oxm.OFOxmInPort;
26 -import org.projectfloodlight.openflow.protocol.oxm.OFOxmOchSigid;
27 -import org.projectfloodlight.openflow.protocol.oxm.OFOxmOchSigidBasic;
28 -import org.projectfloodlight.openflow.protocol.oxm.OFOxmOchSigtype;
29 -import org.projectfloodlight.openflow.types.CircuitSignalID;
30 -import org.projectfloodlight.openflow.types.OFPort;
31 -import org.projectfloodlight.openflow.types.U8;
32 import org.slf4j.Logger; 20 import org.slf4j.Logger;
33 import org.slf4j.LoggerFactory; 21 import org.slf4j.LoggerFactory;
34 22
...@@ -131,12 +119,6 @@ public class OFOpticalSwitchImplLINC13 extends AbstractOpenFlowSwitch { ...@@ -131,12 +119,6 @@ public class OFOpticalSwitchImplLINC13 extends AbstractOpenFlowSwitch {
131 (OFCircuitPortsReply) m); 119 (OFCircuitPortsReply) m);
132 driverHandshakeComplete.set(true); 120 driverHandshakeComplete.set(true);
133 } 121 }
134 - /*try {
135 - testMA();
136 - testReverseMA();
137 - } catch (IOException e) {
138 - e.printStackTrace();
139 - }*/
140 break; 122 break;
141 default: 123 default:
142 log.warn("Received message {} during switch-driver " + 124 log.warn("Received message {} during switch-driver " +
...@@ -190,7 +172,6 @@ public class OFOpticalSwitchImplLINC13 extends AbstractOpenFlowSwitch { ...@@ -190,7 +172,6 @@ public class OFOpticalSwitchImplLINC13 extends AbstractOpenFlowSwitch {
190 this.write(Collections.<OFMessage>singletonList(circuitPortsRequest)); 172 this.write(Collections.<OFMessage>singletonList(circuitPortsRequest));
191 } 173 }
192 174
193 -
194 @Override 175 @Override
195 public List<OFPortDesc> getPorts() { 176 public List<OFPortDesc> getPorts() {
196 List<OFPortDesc> portEntries = new ArrayList<>(); 177 List<OFPortDesc> portEntries = new ArrayList<>();
...@@ -201,358 +182,6 @@ public class OFOpticalSwitchImplLINC13 extends AbstractOpenFlowSwitch { ...@@ -201,358 +182,6 @@ public class OFOpticalSwitchImplLINC13 extends AbstractOpenFlowSwitch {
201 return Collections.unmodifiableList(portEntries); 182 return Collections.unmodifiableList(portEntries);
202 } 183 }
203 184
204 -
205 - public static final U8 SIGNAL_TYPE = U8.of((short) 10);
206 - private void testMA() throws IOException {
207 - log.debug("LINC OE *** Testing MA ");
208 - short lambda = 1;
209 - if (getId() == 0x0000ffffffffff01L) {
210 - final int inport = 10;
211 - final int outport = 20;
212 - //Circuit signal id
213 - CircuitSignalID sigID = getSignalID(lambda);
214 -
215 - OFOxmOchSigidBasic ofOxmOchSigidBasic =
216 - factory().oxms().ochSigidBasic(sigID);
217 -
218 -
219 - //Match Port
220 - OFOxmInPort fieldPort = factory().oxms()
221 - .inPort(OFPort.of(inport));
222 - OFMatchV3 matchPort =
223 - factory()
224 - .buildMatchV3().
225 - setOxmList(OFOxmList.of(fieldPort)).build();
226 -
227 -
228 - // Set Action outport ,sigType and sigID
229 - List<OFAction> actionList = new ArrayList<>();
230 - OFAction actionOutPort =
231 - factory().actions().output(OFPort.of(outport),
232 - 0xffff);
233 -
234 - OFActionCircuit actionCircuit = factory()
235 - .actions()
236 - .circuit(ofOxmOchSigidBasic);
237 -
238 - actionList.add(actionCircuit);
239 - actionList.add(actionOutPort);
240 -
241 - OFInstruction instructionAction =
242 - factory().instructions().buildApplyActions()
243 - .setActions(actionList)
244 - .build();
245 - List<OFInstruction> instructions =
246 - Collections.singletonList(instructionAction);
247 -
248 - OFMessage opticalFlowEntry =
249 - factory().buildFlowAdd()
250 - .setMatch(matchPort)
251 - .setPriority(100)
252 - .setInstructions(instructions)
253 - .setXid(getNextTransactionId())
254 - .build();
255 - log.debug("Adding optical flow in sw {}", getStringId());
256 - List<OFMessage> msglist = new ArrayList<>(1);
257 - msglist.add(opticalFlowEntry);
258 - write(msglist);
259 - sendBarrier(true);
260 - } else if (getId() == 0x0000ffffffffff03L) {
261 - final int inport = 30;
262 - final int outport = 31;
263 - //Circuit signal id
264 - CircuitSignalID sigID = getSignalID(lambda);
265 -
266 - OFOxmOchSigid fieldSigIDMatch = factory().oxms().ochSigid(sigID);
267 - OFOxmOchSigtype fieldSigType = factory()
268 - .oxms()
269 - .ochSigtype(SIGNAL_TYPE);
270 -
271 - OFOxmOchSigidBasic ofOxmOchSigidBasic =
272 - factory().oxms().ochSigidBasic(sigID);
273 -
274 - //Match Port,SigType,SigID
275 - OFOxmInPort fieldPort = factory()
276 - .oxms()
277 - .inPort(OFPort.of(inport));
278 - OFMatchV3 matchPort = factory()
279 - .buildMatchV3()
280 - .setOxmList(OFOxmList.of(fieldPort,
281 - fieldSigIDMatch,
282 - fieldSigType
283 - ))
284 - .build();
285 -
286 - // Set Action outport ,SigType, sigID
287 - List<OFAction> actionList = new ArrayList<>();
288 - OFAction actionOutPort =
289 - factory().actions().output(OFPort.of(outport),
290 - 0xffff);
291 -
292 - OFActionCircuit actionCircuit = factory()
293 - .actions()
294 - .circuit(ofOxmOchSigidBasic);
295 -
296 -
297 -
298 - //actionList.add(setActionSigType);
299 - actionList.add(actionCircuit);
300 - actionList.add(actionOutPort);
301 -
302 - OFInstruction instructionAction =
303 - factory().instructions().buildApplyActions()
304 - .setActions(actionList)
305 - .build();
306 - List<OFInstruction> instructions =
307 - Collections.singletonList(instructionAction);
308 -
309 - OFMessage opticalFlowEntry =
310 - factory().buildFlowAdd()
311 - .setMatch(matchPort)
312 - .setPriority(100)
313 - .setInstructions(instructions)
314 - .setXid(getNextTransactionId())
315 - .build();
316 - log.debug("Adding optical flow in sw {}", getStringId());
317 - List<OFMessage> msglist = new ArrayList<>(1);
318 - msglist.add(opticalFlowEntry);
319 - write(msglist);
320 - sendBarrier(true);
321 -
322 - } else if (getId() == 0x0000ffffffffff02L) {
323 - final int inport = 21;
324 - final int outport = 11;
325 - //Circuit signal id
326 - CircuitSignalID sigID = getSignalID(lambda);
327 -
328 - OFOxmOchSigid fieldSigIDMatch = factory().oxms().ochSigid(sigID);
329 - OFOxmOchSigtype fieldSigType = factory()
330 - .oxms()
331 - .ochSigtype(SIGNAL_TYPE);
332 -
333 -
334 - //Match Port, sig type and sig id
335 - OFOxmInPort fieldPort = factory()
336 - .oxms()
337 - .inPort(OFPort.of(inport));
338 - OFMatchV3 matchPort =
339 - factory().buildMatchV3()
340 - .setOxmList(OFOxmList.of(fieldPort,
341 - fieldSigIDMatch,
342 - fieldSigType
343 - ))
344 - .build();
345 -
346 - // Set Action outport
347 - List<OFAction> actionList = new ArrayList<>();
348 - OFAction actionOutPort =
349 - factory().actions().output(OFPort.of(outport),
350 - 0xffff);
351 -
352 - actionList.add(actionOutPort);
353 -
354 - OFInstruction instructionAction =
355 - factory().instructions().buildApplyActions()
356 - .setActions(actionList)
357 - .build();
358 - List<OFInstruction> instructions =
359 - Collections.singletonList(instructionAction);
360 -
361 - OFMessage opticalFlowEntry =
362 - factory().buildFlowAdd()
363 - .setMatch(matchPort)
364 - .setPriority(100)
365 - .setInstructions(instructions)
366 - .setXid(getNextTransactionId())
367 - .build();
368 - log.debug("Adding optical flow in sw {}", getStringId());
369 - List<OFMessage> msglist = new ArrayList<>(1);
370 - msglist.add(opticalFlowEntry);
371 - write(msglist);
372 - sendBarrier(true);
373 - }
374 -
375 - }
376 - private void testReverseMA() throws IOException {
377 - log.debug("LINC OE *** Testing MA ");
378 - short lambda = 1;
379 - if (getId() == 0x0000ffffffffff02L) {
380 - final int inport = 11;
381 - final int outport = 21;
382 - //Circuit signal id
383 - CircuitSignalID sigID = getSignalID(lambda);
384 -
385 - OFOxmOchSigidBasic ofOxmOchSigidBasic =
386 - factory().oxms().ochSigidBasic(sigID);
387 -
388 - //Match Port
389 - OFOxmInPort fieldPort = factory().oxms()
390 - .inPort(OFPort.of(inport));
391 - OFMatchV3 matchPort =
392 - factory()
393 - .buildMatchV3().
394 - setOxmList(OFOxmList.of(fieldPort)).build();
395 -
396 -
397 - // Set Action outport ,sigType and sigID
398 - List<OFAction> actionList = new ArrayList<>();
399 - OFAction actionOutPort =
400 - factory().actions().output(OFPort.of(outport),
401 - 0xffff);
402 -
403 - OFActionCircuit actionCircuit = factory()
404 - .actions()
405 - .circuit(ofOxmOchSigidBasic);
406 - actionList.add(actionCircuit);
407 - actionList.add(actionOutPort);
408 -
409 - OFInstruction instructionAction =
410 - factory().instructions().buildApplyActions()
411 - .setActions(actionList)
412 - .build();
413 - List<OFInstruction> instructions =
414 - Collections.singletonList(instructionAction);
415 -
416 - OFMessage opticalFlowEntry =
417 - factory().buildFlowAdd()
418 - .setMatch(matchPort)
419 - .setPriority(100)
420 - .setInstructions(instructions)
421 - .setXid(getNextTransactionId())
422 - .build();
423 - log.debug("Adding optical flow in sw {}", getStringId());
424 - List<OFMessage> msglist = new ArrayList<>(1);
425 - msglist.add(opticalFlowEntry);
426 - write(msglist);
427 - sendBarrier(true);
428 - } else if (getId() == 0x0000ffffffffff03L) {
429 - final int inport = 31;
430 - final int outport = 30;
431 - //Circuit signal id
432 - CircuitSignalID sigID = getSignalID(lambda);
433 -
434 - OFOxmOchSigid fieldSigIDMatch = factory().oxms().ochSigid(sigID);
435 - OFOxmOchSigtype fieldSigType = factory()
436 - .oxms()
437 - .ochSigtype(SIGNAL_TYPE);
438 -
439 - OFOxmOchSigidBasic ofOxmOchSigidBasic =
440 - factory().oxms().ochSigidBasic(sigID);
441 -
442 - //Match Port,SigType,SigID
443 - OFOxmInPort fieldPort = factory()
444 - .oxms()
445 - .inPort(OFPort.of(inport));
446 - OFMatchV3 matchPort = factory()
447 - .buildMatchV3()
448 - .setOxmList(OFOxmList.of(fieldPort,
449 - fieldSigIDMatch,
450 - fieldSigType
451 - ))
452 - .build();
453 -
454 - // Set Action outport ,SigType, sigID
455 - List<OFAction> actionList = new ArrayList<>();
456 - OFAction actionOutPort =
457 - factory().actions().output(OFPort.of(outport),
458 - 0xffff);
459 - OFActionCircuit actionCircuit = factory()
460 - .actions()
461 - .circuit(ofOxmOchSigidBasic);
462 -
463 - actionList.add(actionCircuit);
464 - actionList.add(actionOutPort);
465 -
466 - OFInstruction instructionAction =
467 - factory().instructions().buildApplyActions()
468 - .setActions(actionList)
469 - .build();
470 - List<OFInstruction> instructions =
471 - Collections.singletonList(instructionAction);
472 -
473 - OFMessage opticalFlowEntry =
474 - factory().buildFlowAdd()
475 - .setMatch(matchPort)
476 - .setPriority(100)
477 - .setInstructions(instructions)
478 - .setXid(getNextTransactionId())
479 - .build();
480 - log.debug("Adding optical flow in sw {}", getStringId());
481 - List<OFMessage> msglist = new ArrayList<>(1);
482 - msglist.add(opticalFlowEntry);
483 - write(msglist);
484 - sendBarrier(true);
485 -
486 - } else if (getId() == 0x0000ffffffffff01L) {
487 - final int inport = 20;
488 - final int outport = 10;
489 - //Circuit signal id
490 - CircuitSignalID sigID = getSignalID(lambda);
491 -
492 - OFOxmOchSigid fieldSigIDMatch = factory().oxms().ochSigid(sigID);
493 - OFOxmOchSigtype fieldSigType = factory()
494 - .oxms()
495 - .ochSigtype(SIGNAL_TYPE);
496 -
497 -
498 - //Match Port, sig type and sig id
499 - OFOxmInPort fieldPort = factory()
500 - .oxms()
501 - .inPort(OFPort.of(inport));
502 - OFMatchV3 matchPort =
503 - factory().buildMatchV3()
504 - .setOxmList(OFOxmList.of(fieldPort,
505 - fieldSigIDMatch,
506 - fieldSigType
507 - ))
508 - .build();
509 -
510 - // Set Action outport
511 - List<OFAction> actionList = new ArrayList<>();
512 - OFAction actionOutPort =
513 - factory().actions().output(OFPort.of(outport),
514 - 0xffff);
515 -
516 - actionList.add(actionOutPort);
517 -
518 - OFInstruction instructionAction =
519 - factory().instructions().buildApplyActions()
520 - .setActions(actionList)
521 - .build();
522 - List<OFInstruction> instructions =
523 - Collections.singletonList(instructionAction);
524 -
525 - OFMessage opticalFlowEntry =
526 - factory().buildFlowAdd()
527 - .setMatch(matchPort)
528 - .setPriority(100)
529 - .setInstructions(instructions)
530 - .setXid(getNextTransactionId())
531 - .build();
532 - log.debug("Adding optical flow in sw {}", getStringId());
533 - List<OFMessage> msglist = new ArrayList<>(1);
534 - msglist.add(opticalFlowEntry);
535 - write(msglist);
536 - sendBarrier(true);
537 - }
538 -
539 - }
540 -
541 -
542 - // Todo remove - for testing purpose only
543 - private static CircuitSignalID getSignalID(short lambda) {
544 - byte myGrid = 1;
545 - byte myCs = 2;
546 - short myCn = lambda;
547 - short mySw = 1;
548 -
549 - CircuitSignalID signalID = new CircuitSignalID(myGrid,
550 - myCs,
551 - myCn,
552 - mySw);
553 - return signalID;
554 - }
555 -
556 private void sendBarrier(boolean finalBarrier) throws IOException { 185 private void sendBarrier(boolean finalBarrier) throws IOException {
557 int xid = getNextTransactionId(); 186 int xid = getNextTransactionId();
558 if (finalBarrier) { 187 if (finalBarrier) {
......