Carmelo Cascone
Committed by Jonathan Hart

Various BMv2 bugfixes

Change-Id: Ia5a2a1c86b8a90ad68ddb92980377f6308e200d2
...@@ -64,6 +64,8 @@ import java.util.concurrent.ConcurrentMap; ...@@ -64,6 +64,8 @@ import java.util.concurrent.ConcurrentMap;
64 import java.util.concurrent.ExecutorService; 64 import java.util.concurrent.ExecutorService;
65 import java.util.concurrent.Executors; 65 import java.util.concurrent.Executors;
66 import java.util.concurrent.TimeUnit; 66 import java.util.concurrent.TimeUnit;
67 +import java.util.concurrent.locks.Lock;
68 +import java.util.concurrent.locks.ReentrantLock;
67 import java.util.stream.Collectors; 69 import java.util.stream.Collectors;
68 import java.util.stream.Stream; 70 import java.util.stream.Stream;
69 71
...@@ -87,7 +89,7 @@ public abstract class AbstractUpgradableFabricApp { ...@@ -87,7 +89,7 @@ public abstract class AbstractUpgradableFabricApp {
87 private static final int NUM_SPINES = 3; 89 private static final int NUM_SPINES = 3;
88 private static final int FLOW_PRIORITY = 100; 90 private static final int FLOW_PRIORITY = 100;
89 91
90 - private static final int CLEANUP_SLEEP = 1000; 92 + private static final int CLEANUP_SLEEP = 2000;
91 93
92 protected final Logger log = getLogger(getClass()); 94 protected final Logger log = getLogger(getClass());
93 95
...@@ -137,10 +139,11 @@ public abstract class AbstractUpgradableFabricApp { ...@@ -137,10 +139,11 @@ public abstract class AbstractUpgradableFabricApp {
137 private Set<DeviceId> spineSwitches; 139 private Set<DeviceId> spineSwitches;
138 140
139 private Map<DeviceId, List<FlowRule>> deviceFlowRules; 141 private Map<DeviceId, List<FlowRule>> deviceFlowRules;
142 + private Map<DeviceId, Bmv2DeviceContext> previousContexts;
140 private Map<DeviceId, Boolean> contextFlags; 143 private Map<DeviceId, Boolean> contextFlags;
141 private Map<DeviceId, Boolean> ruleFlags; 144 private Map<DeviceId, Boolean> ruleFlags;
142 145
143 - private ConcurrentMap<DeviceId, Boolean> deployLocks = Maps.newConcurrentMap(); 146 + private ConcurrentMap<DeviceId, Lock> deviceLocks = Maps.newConcurrentMap();
144 147
145 /** 148 /**
146 * Creates a new BMv2 fabric app. 149 * Creates a new BMv2 fabric app.
...@@ -270,7 +273,7 @@ public abstract class AbstractUpgradableFabricApp { ...@@ -270,7 +273,7 @@ public abstract class AbstractUpgradableFabricApp {
270 public abstract List<FlowRule> generateSpineRules(DeviceId deviceId, Collection<Host> dstHosts, Topology topology) 273 public abstract List<FlowRule> generateSpineRules(DeviceId deviceId, Collection<Host> dstHosts, Topology topology)
271 throws FlowRuleGeneratorException; 274 throws FlowRuleGeneratorException;
272 275
273 - private void deployRoutine() { 276 + private void deployAllDevices() {
274 if (otherAppFound && otherApp.appActive) { 277 if (otherAppFound && otherApp.appActive) {
275 log.info("Deactivating other app..."); 278 log.info("Deactivating other app...");
276 appService.deactivate(otherApp.appId); 279 appService.deactivate(otherApp.appId);
...@@ -297,9 +300,10 @@ public abstract class AbstractUpgradableFabricApp { ...@@ -297,9 +300,10 @@ public abstract class AbstractUpgradableFabricApp {
297 DeviceId deviceId = device.id(); 300 DeviceId deviceId = device.id();
298 301
299 // Synchronize executions over the same device. 302 // Synchronize executions over the same device.
300 - deployLocks.putIfAbsent(deviceId, new Boolean(true)); 303 + Lock lock = deviceLocks.computeIfAbsent(deviceId, k -> new ReentrantLock());
301 - synchronized (deployLocks.get(deviceId)) { 304 + lock.lock();
302 305
306 + try {
303 // Set context if not already done. 307 // Set context if not already done.
304 if (!contextFlags.getOrDefault(deviceId, false)) { 308 if (!contextFlags.getOrDefault(deviceId, false)) {
305 log.info("Setting context to {} for {}...", configurationName, deviceId); 309 log.info("Setting context to {} for {}...", configurationName, deviceId);
...@@ -321,6 +325,8 @@ public abstract class AbstractUpgradableFabricApp { ...@@ -321,6 +325,8 @@ public abstract class AbstractUpgradableFabricApp {
321 ruleFlags.put(deviceId, true); 325 ruleFlags.put(deviceId, true);
322 } 326 }
323 } 327 }
328 + } finally {
329 + lock.unlock();
324 } 330 }
325 } 331 }
326 332
...@@ -421,9 +427,9 @@ public abstract class AbstractUpgradableFabricApp { ...@@ -421,9 +427,9 @@ public abstract class AbstractUpgradableFabricApp {
421 ImmutableMap.Builder<DeviceId, List<FlowRule>> mapBuilder = ImmutableMap.builder(); 427 ImmutableMap.Builder<DeviceId, List<FlowRule>> mapBuilder = ImmutableMap.builder();
422 concat(spines.stream(), leafs.stream()) 428 concat(spines.stream(), leafs.stream())
423 .map(deviceId -> ImmutableList.copyOf(newFlowRules 429 .map(deviceId -> ImmutableList.copyOf(newFlowRules
424 - .stream() 430 + .stream()
425 - .filter(fr -> fr.deviceId().equals(deviceId)) 431 + .filter(fr -> fr.deviceId().equals(deviceId))
426 - .iterator())) 432 + .iterator()))
427 .forEach(frs -> mapBuilder.put(frs.get(0).deviceId(), frs)); 433 .forEach(frs -> mapBuilder.put(frs.get(0).deviceId(), frs));
428 this.deviceFlowRules = mapBuilder.build(); 434 this.deviceFlowRules = mapBuilder.build();
429 435
...@@ -433,10 +439,9 @@ public abstract class AbstractUpgradableFabricApp { ...@@ -433,10 +439,9 @@ public abstract class AbstractUpgradableFabricApp {
433 // Avoid other executions to modify the generated flow rules. 439 // Avoid other executions to modify the generated flow rules.
434 flowRuleGenerated = true; 440 flowRuleGenerated = true;
435 441
436 - log.info("DONE! Generated {} flow rules for {} devices...", newFlowRules.size(), spines.size() + leafs.size()); 442 + log.info("Generated {} flow rules for {} devices", newFlowRules.size(), spines.size() + leafs.size());
437 443
438 - // Deploy configuration. 444 + spawnTask(this::deployAllDevices);
439 - spawnTask(this::deployRoutine);
440 } 445 }
441 446
442 /** 447 /**
......
1 -/Users/carmelo/workspace/onos-p4-dev/p4src/build/ecmp.json
...\ No newline at end of file ...\ No newline at end of file
1 +{
2 + "header_types": [
3 + {
4 + "name": "standard_metadata_t",
5 + "id": 0,
6 + "fields": [
7 + [
8 + "ingress_port",
9 + 9
10 + ],
11 + [
12 + "packet_length",
13 + 32
14 + ],
15 + [
16 + "egress_spec",
17 + 9
18 + ],
19 + [
20 + "egress_port",
21 + 9
22 + ],
23 + [
24 + "egress_instance",
25 + 32
26 + ],
27 + [
28 + "instance_type",
29 + 32
30 + ],
31 + [
32 + "clone_spec",
33 + 32
34 + ],
35 + [
36 + "_padding",
37 + 5
38 + ]
39 + ],
40 + "length_exp": null,
41 + "max_length": null
42 + },
43 + {
44 + "name": "intrinsic_metadata_t",
45 + "id": 1,
46 + "fields": [
47 + [
48 + "ingress_global_timestamp",
49 + 32
50 + ],
51 + [
52 + "lf_field_list",
53 + 32
54 + ],
55 + [
56 + "mcast_grp",
57 + 16
58 + ],
59 + [
60 + "egress_rid",
61 + 16
62 + ]
63 + ],
64 + "length_exp": null,
65 + "max_length": null
66 + },
67 + {
68 + "name": "ethernet_t",
69 + "id": 2,
70 + "fields": [
71 + [
72 + "dstAddr",
73 + 48
74 + ],
75 + [
76 + "srcAddr",
77 + 48
78 + ],
79 + [
80 + "etherType",
81 + 16
82 + ]
83 + ],
84 + "length_exp": null,
85 + "max_length": null
86 + },
87 + {
88 + "name": "ipv4_t",
89 + "id": 3,
90 + "fields": [
91 + [
92 + "version",
93 + 4
94 + ],
95 + [
96 + "ihl",
97 + 4
98 + ],
99 + [
100 + "diffserv",
101 + 8
102 + ],
103 + [
104 + "totalLen",
105 + 16
106 + ],
107 + [
108 + "identification",
109 + 16
110 + ],
111 + [
112 + "flags",
113 + 3
114 + ],
115 + [
116 + "fragOffset",
117 + 13
118 + ],
119 + [
120 + "ttl",
121 + 8
122 + ],
123 + [
124 + "protocol",
125 + 8
126 + ],
127 + [
128 + "hdrChecksum",
129 + 16
130 + ],
131 + [
132 + "srcAddr",
133 + 32
134 + ],
135 + [
136 + "dstAddr",
137 + 32
138 + ]
139 + ],
140 + "length_exp": null,
141 + "max_length": null
142 + },
143 + {
144 + "name": "tcp_t",
145 + "id": 4,
146 + "fields": [
147 + [
148 + "srcPort",
149 + 16
150 + ],
151 + [
152 + "dstPort",
153 + 16
154 + ],
155 + [
156 + "seqNo",
157 + 32
158 + ],
159 + [
160 + "ackNo",
161 + 32
162 + ],
163 + [
164 + "dataOffset",
165 + 4
166 + ],
167 + [
168 + "res",
169 + 3
170 + ],
171 + [
172 + "ecn",
173 + 3
174 + ],
175 + [
176 + "ctrl",
177 + 6
178 + ],
179 + [
180 + "window",
181 + 16
182 + ],
183 + [
184 + "checksum",
185 + 16
186 + ],
187 + [
188 + "urgentPtr",
189 + 16
190 + ]
191 + ],
192 + "length_exp": null,
193 + "max_length": null
194 + },
195 + {
196 + "name": "udp_t",
197 + "id": 5,
198 + "fields": [
199 + [
200 + "srcPort",
201 + 16
202 + ],
203 + [
204 + "dstPort",
205 + 16
206 + ],
207 + [
208 + "length_",
209 + 16
210 + ],
211 + [
212 + "checksum",
213 + 16
214 + ]
215 + ],
216 + "length_exp": null,
217 + "max_length": null
218 + },
219 + {
220 + "name": "ecmp_metadata_t",
221 + "id": 6,
222 + "fields": [
223 + [
224 + "groupId",
225 + 16
226 + ],
227 + [
228 + "selector",
229 + 16
230 + ]
231 + ],
232 + "length_exp": null,
233 + "max_length": null
234 + }
235 + ],
236 + "headers": [
237 + {
238 + "name": "standard_metadata",
239 + "id": 0,
240 + "header_type": "standard_metadata_t",
241 + "metadata": true
242 + },
243 + {
244 + "name": "intrinsic_metadata",
245 + "id": 1,
246 + "header_type": "intrinsic_metadata_t",
247 + "metadata": true
248 + },
249 + {
250 + "name": "ethernet",
251 + "id": 2,
252 + "header_type": "ethernet_t",
253 + "metadata": false
254 + },
255 + {
256 + "name": "ipv4",
257 + "id": 3,
258 + "header_type": "ipv4_t",
259 + "metadata": false
260 + },
261 + {
262 + "name": "tcp",
263 + "id": 4,
264 + "header_type": "tcp_t",
265 + "metadata": false
266 + },
267 + {
268 + "name": "udp",
269 + "id": 5,
270 + "header_type": "udp_t",
271 + "metadata": false
272 + },
273 + {
274 + "name": "ecmp_metadata",
275 + "id": 6,
276 + "header_type": "ecmp_metadata_t",
277 + "metadata": true
278 + }
279 + ],
280 + "header_stacks": [],
281 + "parsers": [
282 + {
283 + "name": "parser",
284 + "id": 0,
285 + "init_state": "start",
286 + "parse_states": [
287 + {
288 + "name": "start",
289 + "id": 0,
290 + "parser_ops": [],
291 + "transition_key": [],
292 + "transitions": [
293 + {
294 + "value": "default",
295 + "mask": null,
296 + "next_state": "parse_ethernet"
297 + }
298 + ]
299 + },
300 + {
301 + "name": "parse_ethernet",
302 + "id": 1,
303 + "parser_ops": [
304 + {
305 + "op": "extract",
306 + "parameters": [
307 + {
308 + "type": "regular",
309 + "value": "ethernet"
310 + }
311 + ]
312 + }
313 + ],
314 + "transition_key": [
315 + {
316 + "type": "field",
317 + "value": [
318 + "ethernet",
319 + "etherType"
320 + ]
321 + }
322 + ],
323 + "transitions": [
324 + {
325 + "value": "0x0800",
326 + "mask": null,
327 + "next_state": "parse_ipv4"
328 + },
329 + {
330 + "value": "default",
331 + "mask": null,
332 + "next_state": null
333 + }
334 + ]
335 + },
336 + {
337 + "name": "parse_ipv4",
338 + "id": 2,
339 + "parser_ops": [
340 + {
341 + "op": "extract",
342 + "parameters": [
343 + {
344 + "type": "regular",
345 + "value": "ipv4"
346 + }
347 + ]
348 + }
349 + ],
350 + "transition_key": [
351 + {
352 + "type": "field",
353 + "value": [
354 + "ipv4",
355 + "fragOffset"
356 + ]
357 + },
358 + {
359 + "type": "field",
360 + "value": [
361 + "ipv4",
362 + "protocol"
363 + ]
364 + }
365 + ],
366 + "transitions": [
367 + {
368 + "value": "0x000006",
369 + "mask": null,
370 + "next_state": "parse_tcp"
371 + },
372 + {
373 + "value": "0x000011",
374 + "mask": null,
375 + "next_state": "parse_udp"
376 + },
377 + {
378 + "value": "default",
379 + "mask": null,
380 + "next_state": null
381 + }
382 + ]
383 + },
384 + {
385 + "name": "parse_tcp",
386 + "id": 3,
387 + "parser_ops": [
388 + {
389 + "op": "extract",
390 + "parameters": [
391 + {
392 + "type": "regular",
393 + "value": "tcp"
394 + }
395 + ]
396 + }
397 + ],
398 + "transition_key": [],
399 + "transitions": [
400 + {
401 + "value": "default",
402 + "mask": null,
403 + "next_state": null
404 + }
405 + ]
406 + },
407 + {
408 + "name": "parse_udp",
409 + "id": 4,
410 + "parser_ops": [
411 + {
412 + "op": "extract",
413 + "parameters": [
414 + {
415 + "type": "regular",
416 + "value": "udp"
417 + }
418 + ]
419 + }
420 + ],
421 + "transition_key": [],
422 + "transitions": [
423 + {
424 + "value": "default",
425 + "mask": null,
426 + "next_state": null
427 + }
428 + ]
429 + }
430 + ]
431 + }
432 + ],
433 + "deparsers": [
434 + {
435 + "name": "deparser",
436 + "id": 0,
437 + "order": [
438 + "ethernet",
439 + "ipv4",
440 + "udp",
441 + "tcp"
442 + ]
443 + }
444 + ],
445 + "meter_arrays": [],
446 + "actions": [
447 + {
448 + "name": "_drop",
449 + "id": 0,
450 + "runtime_data": [],
451 + "primitives": [
452 + {
453 + "op": "modify_field",
454 + "parameters": [
455 + {
456 + "type": "field",
457 + "value": [
458 + "standard_metadata",
459 + "egress_spec"
460 + ]
461 + },
462 + {
463 + "type": "hexstr",
464 + "value": "0x1ff"
465 + }
466 + ]
467 + }
468 + ]
469 + },
470 + {
471 + "name": "ecmp_group",
472 + "id": 1,
473 + "runtime_data": [
474 + {
475 + "name": "groupId",
476 + "bitwidth": 16
477 + },
478 + {
479 + "name": "groupSize",
480 + "bitwidth": 16
481 + }
482 + ],
483 + "primitives": [
484 + {
485 + "op": "modify_field",
486 + "parameters": [
487 + {
488 + "type": "field",
489 + "value": [
490 + "ecmp_metadata",
491 + "groupId"
492 + ]
493 + },
494 + {
495 + "type": "runtime_data",
496 + "value": 0
497 + }
498 + ]
499 + },
500 + {
501 + "op": "modify_field_with_hash_based_offset",
502 + "parameters": [
503 + {
504 + "type": "field",
505 + "value": [
506 + "ecmp_metadata",
507 + "selector"
508 + ]
509 + },
510 + {
511 + "type": "hexstr",
512 + "value": "0x0"
513 + },
514 + {
515 + "type": "calculation",
516 + "value": "ecmp_hash"
517 + },
518 + {
519 + "type": "runtime_data",
520 + "value": 1
521 + }
522 + ]
523 + }
524 + ]
525 + },
526 + {
527 + "name": "send_to_cpu",
528 + "id": 2,
529 + "runtime_data": [],
530 + "primitives": [
531 + {
532 + "op": "modify_field",
533 + "parameters": [
534 + {
535 + "type": "field",
536 + "value": [
537 + "standard_metadata",
538 + "egress_spec"
539 + ]
540 + },
541 + {
542 + "type": "hexstr",
543 + "value": "0xff"
544 + }
545 + ]
546 + }
547 + ]
548 + },
549 + {
550 + "name": "count_packet",
551 + "id": 3,
552 + "runtime_data": [],
553 + "primitives": [
554 + {
555 + "op": "count",
556 + "parameters": [
557 + {
558 + "type": "counter_array",
559 + "value": "ingress_port_counter"
560 + },
561 + {
562 + "type": "field",
563 + "value": [
564 + "standard_metadata",
565 + "ingress_port"
566 + ]
567 + }
568 + ]
569 + },
570 + {
571 + "op": "count",
572 + "parameters": [
573 + {
574 + "type": "counter_array",
575 + "value": "egress_port_counter"
576 + },
577 + {
578 + "type": "field",
579 + "value": [
580 + "standard_metadata",
581 + "egress_spec"
582 + ]
583 + }
584 + ]
585 + }
586 + ]
587 + },
588 + {
589 + "name": "set_egress_port",
590 + "id": 4,
591 + "runtime_data": [
592 + {
593 + "name": "port",
594 + "bitwidth": 9
595 + }
596 + ],
597 + "primitives": [
598 + {
599 + "op": "modify_field",
600 + "parameters": [
601 + {
602 + "type": "field",
603 + "value": [
604 + "standard_metadata",
605 + "egress_spec"
606 + ]
607 + },
608 + {
609 + "type": "runtime_data",
610 + "value": 0
611 + }
612 + ]
613 + }
614 + ]
615 + }
616 + ],
617 + "pipelines": [
618 + {
619 + "name": "ingress",
620 + "id": 0,
621 + "init_table": "table0",
622 + "tables": [
623 + {
624 + "name": "port_count_table",
625 + "id": 0,
626 + "match_type": "exact",
627 + "type": "simple",
628 + "max_size": 16384,
629 + "with_counters": false,
630 + "direct_meters": null,
631 + "support_timeout": false,
632 + "key": [],
633 + "actions": [
634 + "count_packet"
635 + ],
636 + "next_tables": {
637 + "count_packet": null
638 + },
639 + "default_action": null,
640 + "base_default_next": null
641 + },
642 + {
643 + "name": "table0",
644 + "id": 1,
645 + "match_type": "ternary",
646 + "type": "simple",
647 + "max_size": 16384,
648 + "with_counters": true,
649 + "direct_meters": null,
650 + "support_timeout": true,
651 + "key": [
652 + {
653 + "match_type": "ternary",
654 + "target": [
655 + "standard_metadata",
656 + "ingress_port"
657 + ],
658 + "mask": null
659 + },
660 + {
661 + "match_type": "ternary",
662 + "target": [
663 + "ethernet",
664 + "dstAddr"
665 + ],
666 + "mask": null
667 + },
668 + {
669 + "match_type": "ternary",
670 + "target": [
671 + "ethernet",
672 + "srcAddr"
673 + ],
674 + "mask": null
675 + },
676 + {
677 + "match_type": "ternary",
678 + "target": [
679 + "ethernet",
680 + "etherType"
681 + ],
682 + "mask": null
683 + }
684 + ],
685 + "actions": [
686 + "set_egress_port",
687 + "ecmp_group",
688 + "send_to_cpu",
689 + "_drop"
690 + ],
691 + "next_tables": {
692 + "set_egress_port": "_condition_0",
693 + "ecmp_group": "ecmp_group_table",
694 + "send_to_cpu": "_condition_0",
695 + "_drop": "_condition_0"
696 + },
697 + "default_action": null,
698 + "base_default_next": "_condition_0"
699 + },
700 + {
701 + "name": "ecmp_group_table",
702 + "id": 2,
703 + "match_type": "exact",
704 + "type": "simple",
705 + "max_size": 16384,
706 + "with_counters": true,
707 + "direct_meters": null,
708 + "support_timeout": false,
709 + "key": [
710 + {
711 + "match_type": "exact",
712 + "target": [
713 + "ecmp_metadata",
714 + "groupId"
715 + ],
716 + "mask": null
717 + },
718 + {
719 + "match_type": "exact",
720 + "target": [
721 + "ecmp_metadata",
722 + "selector"
723 + ],
724 + "mask": null
725 + }
726 + ],
727 + "actions": [
728 + "set_egress_port"
729 + ],
730 + "next_tables": {
731 + "set_egress_port": "_condition_0"
732 + },
733 + "default_action": null,
734 + "base_default_next": "_condition_0"
735 + }
736 + ],
737 + "conditionals": [
738 + {
739 + "name": "_condition_0",
740 + "id": 0,
741 + "expression": {
742 + "type": "expression",
743 + "value": {
744 + "op": "<",
745 + "left": {
746 + "type": "field",
747 + "value": [
748 + "standard_metadata",
749 + "egress_spec"
750 + ]
751 + },
752 + "right": {
753 + "type": "hexstr",
754 + "value": "0xfe"
755 + }
756 + }
757 + },
758 + "true_next": "port_count_table",
759 + "false_next": null
760 + }
761 + ]
762 + },
763 + {
764 + "name": "egress",
765 + "id": 1,
766 + "init_table": null,
767 + "tables": [],
768 + "conditionals": []
769 + }
770 + ],
771 + "calculations": [
772 + {
773 + "name": "ecmp_hash",
774 + "id": 0,
775 + "input": [
776 + {
777 + "type": "field",
778 + "value": [
779 + "ipv4",
780 + "srcAddr"
781 + ]
782 + },
783 + {
784 + "type": "field",
785 + "value": [
786 + "ipv4",
787 + "dstAddr"
788 + ]
789 + },
790 + {
791 + "type": "field",
792 + "value": [
793 + "ipv4",
794 + "protocol"
795 + ]
796 + },
797 + {
798 + "type": "field",
799 + "value": [
800 + "tcp",
801 + "srcPort"
802 + ]
803 + },
804 + {
805 + "type": "field",
806 + "value": [
807 + "tcp",
808 + "dstPort"
809 + ]
810 + },
811 + {
812 + "type": "field",
813 + "value": [
814 + "udp",
815 + "srcPort"
816 + ]
817 + },
818 + {
819 + "type": "field",
820 + "value": [
821 + "udp",
822 + "dstPort"
823 + ]
824 + }
825 + ],
826 + "algo": "bmv2_hash"
827 + }
828 + ],
829 + "checksums": [],
830 + "learn_lists": [],
831 + "field_lists": [],
832 + "counter_arrays": [
833 + {
834 + "name": "ingress_port_counter",
835 + "id": 0,
836 + "is_direct": false,
837 + "size": 254
838 + },
839 + {
840 + "name": "egress_port_counter",
841 + "id": 1,
842 + "is_direct": false,
843 + "size": 254
844 + },
845 + {
846 + "name": "table0_counter",
847 + "id": 2,
848 + "is_direct": true,
849 + "binding": "table0"
850 + },
851 + {
852 + "name": "ecmp_group_table_counter",
853 + "id": 3,
854 + "is_direct": true,
855 + "binding": "ecmp_group_table"
856 + }
857 + ],
858 + "register_arrays": [],
859 + "force_arith": [
860 + [
861 + "standard_metadata",
862 + "ingress_port"
863 + ],
864 + [
865 + "standard_metadata",
866 + "packet_length"
867 + ],
868 + [
869 + "standard_metadata",
870 + "egress_spec"
871 + ],
872 + [
873 + "standard_metadata",
874 + "egress_port"
875 + ],
876 + [
877 + "standard_metadata",
878 + "egress_instance"
879 + ],
880 + [
881 + "standard_metadata",
882 + "instance_type"
883 + ],
884 + [
885 + "standard_metadata",
886 + "clone_spec"
887 + ],
888 + [
889 + "standard_metadata",
890 + "_padding"
891 + ],
892 + [
893 + "intrinsic_metadata",
894 + "ingress_global_timestamp"
895 + ],
896 + [
897 + "intrinsic_metadata",
898 + "lf_field_list"
899 + ],
900 + [
901 + "intrinsic_metadata",
902 + "mcast_grp"
903 + ],
904 + [
905 + "intrinsic_metadata",
906 + "egress_rid"
907 + ]
908 + ]
909 +}
...\ No newline at end of file ...\ No newline at end of file
...@@ -105,7 +105,7 @@ public class WcmpFabricApp extends AbstractUpgradableFabricApp { ...@@ -105,7 +105,7 @@ public class WcmpFabricApp extends AbstractUpgradableFabricApp {
105 } 105 }
106 return true; 106 return true;
107 } catch (Bmv2RuntimeException e) { 107 } catch (Bmv2RuntimeException e) {
108 - log.error("Unable to init device {}: {}", deviceId, e.explain()); 108 + log.debug("Exception while initializing device {}: {}", deviceId, e.explain());
109 return false; 109 return false;
110 } 110 }
111 } 111 }
......
1 -/Users/carmelo/workspace/onos-p4-dev/p4src/build/wcmp.json
...\ No newline at end of file ...\ No newline at end of file
1 +{
2 + "header_types": [
3 + {
4 + "name": "standard_metadata_t",
5 + "id": 0,
6 + "fields": [
7 + [
8 + "ingress_port",
9 + 9
10 + ],
11 + [
12 + "packet_length",
13 + 32
14 + ],
15 + [
16 + "egress_spec",
17 + 9
18 + ],
19 + [
20 + "egress_port",
21 + 9
22 + ],
23 + [
24 + "egress_instance",
25 + 32
26 + ],
27 + [
28 + "instance_type",
29 + 32
30 + ],
31 + [
32 + "clone_spec",
33 + 32
34 + ],
35 + [
36 + "_padding",
37 + 5
38 + ]
39 + ],
40 + "length_exp": null,
41 + "max_length": null
42 + },
43 + {
44 + "name": "intrinsic_metadata_t",
45 + "id": 1,
46 + "fields": [
47 + [
48 + "ingress_global_timestamp",
49 + 32
50 + ],
51 + [
52 + "lf_field_list",
53 + 32
54 + ],
55 + [
56 + "mcast_grp",
57 + 16
58 + ],
59 + [
60 + "egress_rid",
61 + 16
62 + ]
63 + ],
64 + "length_exp": null,
65 + "max_length": null
66 + },
67 + {
68 + "name": "ethernet_t",
69 + "id": 2,
70 + "fields": [
71 + [
72 + "dstAddr",
73 + 48
74 + ],
75 + [
76 + "srcAddr",
77 + 48
78 + ],
79 + [
80 + "etherType",
81 + 16
82 + ]
83 + ],
84 + "length_exp": null,
85 + "max_length": null
86 + },
87 + {
88 + "name": "ipv4_t",
89 + "id": 3,
90 + "fields": [
91 + [
92 + "version",
93 + 4
94 + ],
95 + [
96 + "ihl",
97 + 4
98 + ],
99 + [
100 + "diffserv",
101 + 8
102 + ],
103 + [
104 + "totalLen",
105 + 16
106 + ],
107 + [
108 + "identification",
109 + 16
110 + ],
111 + [
112 + "flags",
113 + 3
114 + ],
115 + [
116 + "fragOffset",
117 + 13
118 + ],
119 + [
120 + "ttl",
121 + 8
122 + ],
123 + [
124 + "protocol",
125 + 8
126 + ],
127 + [
128 + "hdrChecksum",
129 + 16
130 + ],
131 + [
132 + "srcAddr",
133 + 32
134 + ],
135 + [
136 + "dstAddr",
137 + 32
138 + ]
139 + ],
140 + "length_exp": null,
141 + "max_length": null
142 + },
143 + {
144 + "name": "tcp_t",
145 + "id": 4,
146 + "fields": [
147 + [
148 + "srcPort",
149 + 16
150 + ],
151 + [
152 + "dstPort",
153 + 16
154 + ],
155 + [
156 + "seqNo",
157 + 32
158 + ],
159 + [
160 + "ackNo",
161 + 32
162 + ],
163 + [
164 + "dataOffset",
165 + 4
166 + ],
167 + [
168 + "res",
169 + 3
170 + ],
171 + [
172 + "ecn",
173 + 3
174 + ],
175 + [
176 + "ctrl",
177 + 6
178 + ],
179 + [
180 + "window",
181 + 16
182 + ],
183 + [
184 + "checksum",
185 + 16
186 + ],
187 + [
188 + "urgentPtr",
189 + 16
190 + ]
191 + ],
192 + "length_exp": null,
193 + "max_length": null
194 + },
195 + {
196 + "name": "udp_t",
197 + "id": 5,
198 + "fields": [
199 + [
200 + "srcPort",
201 + 16
202 + ],
203 + [
204 + "dstPort",
205 + 16
206 + ],
207 + [
208 + "length_",
209 + 16
210 + ],
211 + [
212 + "checksum",
213 + 16
214 + ]
215 + ],
216 + "length_exp": null,
217 + "max_length": null
218 + },
219 + {
220 + "name": "wcmp_meta_t",
221 + "id": 6,
222 + "fields": [
223 + [
224 + "groupId",
225 + 16
226 + ],
227 + [
228 + "numBits",
229 + 8
230 + ],
231 + [
232 + "selector",
233 + 64
234 + ]
235 + ],
236 + "length_exp": null,
237 + "max_length": null
238 + }
239 + ],
240 + "headers": [
241 + {
242 + "name": "standard_metadata",
243 + "id": 0,
244 + "header_type": "standard_metadata_t",
245 + "metadata": true
246 + },
247 + {
248 + "name": "intrinsic_metadata",
249 + "id": 1,
250 + "header_type": "intrinsic_metadata_t",
251 + "metadata": true
252 + },
253 + {
254 + "name": "ethernet",
255 + "id": 2,
256 + "header_type": "ethernet_t",
257 + "metadata": false
258 + },
259 + {
260 + "name": "ipv4",
261 + "id": 3,
262 + "header_type": "ipv4_t",
263 + "metadata": false
264 + },
265 + {
266 + "name": "tcp",
267 + "id": 4,
268 + "header_type": "tcp_t",
269 + "metadata": false
270 + },
271 + {
272 + "name": "udp",
273 + "id": 5,
274 + "header_type": "udp_t",
275 + "metadata": false
276 + },
277 + {
278 + "name": "wcmp_meta",
279 + "id": 6,
280 + "header_type": "wcmp_meta_t",
281 + "metadata": true
282 + }
283 + ],
284 + "header_stacks": [],
285 + "parsers": [
286 + {
287 + "name": "parser",
288 + "id": 0,
289 + "init_state": "start",
290 + "parse_states": [
291 + {
292 + "name": "start",
293 + "id": 0,
294 + "parser_ops": [],
295 + "transition_key": [],
296 + "transitions": [
297 + {
298 + "value": "default",
299 + "mask": null,
300 + "next_state": "parse_ethernet"
301 + }
302 + ]
303 + },
304 + {
305 + "name": "parse_ethernet",
306 + "id": 1,
307 + "parser_ops": [
308 + {
309 + "op": "extract",
310 + "parameters": [
311 + {
312 + "type": "regular",
313 + "value": "ethernet"
314 + }
315 + ]
316 + }
317 + ],
318 + "transition_key": [
319 + {
320 + "type": "field",
321 + "value": [
322 + "ethernet",
323 + "etherType"
324 + ]
325 + }
326 + ],
327 + "transitions": [
328 + {
329 + "value": "0x0800",
330 + "mask": null,
331 + "next_state": "parse_ipv4"
332 + },
333 + {
334 + "value": "default",
335 + "mask": null,
336 + "next_state": null
337 + }
338 + ]
339 + },
340 + {
341 + "name": "parse_ipv4",
342 + "id": 2,
343 + "parser_ops": [
344 + {
345 + "op": "extract",
346 + "parameters": [
347 + {
348 + "type": "regular",
349 + "value": "ipv4"
350 + }
351 + ]
352 + }
353 + ],
354 + "transition_key": [
355 + {
356 + "type": "field",
357 + "value": [
358 + "ipv4",
359 + "fragOffset"
360 + ]
361 + },
362 + {
363 + "type": "field",
364 + "value": [
365 + "ipv4",
366 + "protocol"
367 + ]
368 + }
369 + ],
370 + "transitions": [
371 + {
372 + "value": "0x000006",
373 + "mask": null,
374 + "next_state": "parse_tcp"
375 + },
376 + {
377 + "value": "0x000011",
378 + "mask": null,
379 + "next_state": "parse_udp"
380 + },
381 + {
382 + "value": "default",
383 + "mask": null,
384 + "next_state": null
385 + }
386 + ]
387 + },
388 + {
389 + "name": "parse_tcp",
390 + "id": 3,
391 + "parser_ops": [
392 + {
393 + "op": "extract",
394 + "parameters": [
395 + {
396 + "type": "regular",
397 + "value": "tcp"
398 + }
399 + ]
400 + }
401 + ],
402 + "transition_key": [],
403 + "transitions": [
404 + {
405 + "value": "default",
406 + "mask": null,
407 + "next_state": null
408 + }
409 + ]
410 + },
411 + {
412 + "name": "parse_udp",
413 + "id": 4,
414 + "parser_ops": [
415 + {
416 + "op": "extract",
417 + "parameters": [
418 + {
419 + "type": "regular",
420 + "value": "udp"
421 + }
422 + ]
423 + }
424 + ],
425 + "transition_key": [],
426 + "transitions": [
427 + {
428 + "value": "default",
429 + "mask": null,
430 + "next_state": null
431 + }
432 + ]
433 + }
434 + ]
435 + }
436 + ],
437 + "deparsers": [
438 + {
439 + "name": "deparser",
440 + "id": 0,
441 + "order": [
442 + "ethernet",
443 + "ipv4",
444 + "tcp",
445 + "udp"
446 + ]
447 + }
448 + ],
449 + "meter_arrays": [],
450 + "actions": [
451 + {
452 + "name": "set_egress_port",
453 + "id": 0,
454 + "runtime_data": [
455 + {
456 + "name": "port",
457 + "bitwidth": 9
458 + }
459 + ],
460 + "primitives": [
461 + {
462 + "op": "modify_field",
463 + "parameters": [
464 + {
465 + "type": "field",
466 + "value": [
467 + "standard_metadata",
468 + "egress_spec"
469 + ]
470 + },
471 + {
472 + "type": "runtime_data",
473 + "value": 0
474 + }
475 + ]
476 + }
477 + ]
478 + },
479 + {
480 + "name": "_drop",
481 + "id": 1,
482 + "runtime_data": [],
483 + "primitives": [
484 + {
485 + "op": "modify_field",
486 + "parameters": [
487 + {
488 + "type": "field",
489 + "value": [
490 + "standard_metadata",
491 + "egress_spec"
492 + ]
493 + },
494 + {
495 + "type": "hexstr",
496 + "value": "0x1ff"
497 + }
498 + ]
499 + }
500 + ]
501 + },
502 + {
503 + "name": "send_to_cpu",
504 + "id": 2,
505 + "runtime_data": [],
506 + "primitives": [
507 + {
508 + "op": "modify_field",
509 + "parameters": [
510 + {
511 + "type": "field",
512 + "value": [
513 + "standard_metadata",
514 + "egress_spec"
515 + ]
516 + },
517 + {
518 + "type": "hexstr",
519 + "value": "0xff"
520 + }
521 + ]
522 + }
523 + ]
524 + },
525 + {
526 + "name": "wcmp_group",
527 + "id": 3,
528 + "runtime_data": [
529 + {
530 + "name": "groupId",
531 + "bitwidth": 16
532 + }
533 + ],
534 + "primitives": [
535 + {
536 + "op": "modify_field",
537 + "parameters": [
538 + {
539 + "type": "field",
540 + "value": [
541 + "wcmp_meta",
542 + "groupId"
543 + ]
544 + },
545 + {
546 + "type": "runtime_data",
547 + "value": 0
548 + }
549 + ]
550 + },
551 + {
552 + "op": "modify_field_with_hash_based_offset",
553 + "parameters": [
554 + {
555 + "type": "field",
556 + "value": [
557 + "wcmp_meta",
558 + "numBits"
559 + ]
560 + },
561 + {
562 + "type": "hexstr",
563 + "value": "0x2"
564 + },
565 + {
566 + "type": "calculation",
567 + "value": "wcmp_hash"
568 + },
569 + {
570 + "type": "hexstr",
571 + "value": "0x3e"
572 + }
573 + ]
574 + }
575 + ]
576 + },
577 + {
578 + "name": "wcmp_set_selector",
579 + "id": 4,
580 + "runtime_data": [],
581 + "primitives": [
582 + {
583 + "op": "modify_field",
584 + "parameters": [
585 + {
586 + "type": "field",
587 + "value": [
588 + "wcmp_meta",
589 + "selector"
590 + ]
591 + },
592 + {
593 + "type": "expression",
594 + "value": {
595 + "type": "expression",
596 + "value": {
597 + "op": "<<",
598 + "left": {
599 + "type": "expression",
600 + "value": {
601 + "op": "-",
602 + "left": {
603 + "type": "expression",
604 + "value": {
605 + "op": "<<",
606 + "left": {
607 + "type": "hexstr",
608 + "value": "0x1"
609 + },
610 + "right": {
611 + "type": "field",
612 + "value": [
613 + "wcmp_meta",
614 + "numBits"
615 + ]
616 + }
617 + }
618 + },
619 + "right": {
620 + "type": "hexstr",
621 + "value": "0x1"
622 + }
623 + }
624 + },
625 + "right": {
626 + "type": "expression",
627 + "value": {
628 + "op": "-",
629 + "left": {
630 + "type": "hexstr",
631 + "value": "0x40"
632 + },
633 + "right": {
634 + "type": "field",
635 + "value": [
636 + "wcmp_meta",
637 + "numBits"
638 + ]
639 + }
640 + }
641 + }
642 + }
643 + }
644 + }
645 + ]
646 + }
647 + ]
648 + },
649 + {
650 + "name": "count_packet",
651 + "id": 5,
652 + "runtime_data": [],
653 + "primitives": [
654 + {
655 + "op": "count",
656 + "parameters": [
657 + {
658 + "type": "counter_array",
659 + "value": "ingress_port_counter"
660 + },
661 + {
662 + "type": "field",
663 + "value": [
664 + "standard_metadata",
665 + "ingress_port"
666 + ]
667 + }
668 + ]
669 + },
670 + {
671 + "op": "count",
672 + "parameters": [
673 + {
674 + "type": "counter_array",
675 + "value": "egress_port_counter"
676 + },
677 + {
678 + "type": "field",
679 + "value": [
680 + "standard_metadata",
681 + "egress_spec"
682 + ]
683 + }
684 + ]
685 + }
686 + ]
687 + }
688 + ],
689 + "pipelines": [
690 + {
691 + "name": "ingress",
692 + "id": 0,
693 + "init_table": "table0",
694 + "tables": [
695 + {
696 + "name": "port_count_table",
697 + "id": 0,
698 + "match_type": "exact",
699 + "type": "simple",
700 + "max_size": 16384,
701 + "with_counters": false,
702 + "direct_meters": null,
703 + "support_timeout": false,
704 + "key": [],
705 + "actions": [
706 + "count_packet"
707 + ],
708 + "next_tables": {
709 + "count_packet": null
710 + },
711 + "default_action": null,
712 + "base_default_next": null
713 + },
714 + {
715 + "name": "table0",
716 + "id": 1,
717 + "match_type": "ternary",
718 + "type": "simple",
719 + "max_size": 16384,
720 + "with_counters": true,
721 + "direct_meters": null,
722 + "support_timeout": true,
723 + "key": [
724 + {
725 + "match_type": "ternary",
726 + "target": [
727 + "standard_metadata",
728 + "ingress_port"
729 + ],
730 + "mask": null
731 + },
732 + {
733 + "match_type": "ternary",
734 + "target": [
735 + "ethernet",
736 + "dstAddr"
737 + ],
738 + "mask": null
739 + },
740 + {
741 + "match_type": "ternary",
742 + "target": [
743 + "ethernet",
744 + "srcAddr"
745 + ],
746 + "mask": null
747 + },
748 + {
749 + "match_type": "ternary",
750 + "target": [
751 + "ethernet",
752 + "etherType"
753 + ],
754 + "mask": null
755 + }
756 + ],
757 + "actions": [
758 + "set_egress_port",
759 + "wcmp_group",
760 + "send_to_cpu",
761 + "_drop"
762 + ],
763 + "next_tables": {
764 + "set_egress_port": "_condition_0",
765 + "wcmp_group": "wcmp_set_selector_table",
766 + "send_to_cpu": "_condition_0",
767 + "_drop": "_condition_0"
768 + },
769 + "default_action": null,
770 + "base_default_next": "_condition_0"
771 + },
772 + {
773 + "name": "wcmp_set_selector_table",
774 + "id": 2,
775 + "match_type": "exact",
776 + "type": "simple",
777 + "max_size": 16384,
778 + "with_counters": false,
779 + "direct_meters": null,
780 + "support_timeout": false,
781 + "key": [],
782 + "actions": [
783 + "wcmp_set_selector"
784 + ],
785 + "next_tables": {
786 + "wcmp_set_selector": "wcmp_group_table"
787 + },
788 + "default_action": null,
789 + "base_default_next": "_condition_0"
790 + },
791 + {
792 + "name": "wcmp_group_table",
793 + "id": 3,
794 + "match_type": "lpm",
795 + "type": "simple",
796 + "max_size": 16384,
797 + "with_counters": true,
798 + "direct_meters": null,
799 + "support_timeout": false,
800 + "key": [
801 + {
802 + "match_type": "exact",
803 + "target": [
804 + "wcmp_meta",
805 + "groupId"
806 + ],
807 + "mask": null
808 + },
809 + {
810 + "match_type": "lpm",
811 + "target": [
812 + "wcmp_meta",
813 + "selector"
814 + ],
815 + "mask": null
816 + }
817 + ],
818 + "actions": [
819 + "set_egress_port"
820 + ],
821 + "next_tables": {
822 + "set_egress_port": "_condition_0"
823 + },
824 + "default_action": null,
825 + "base_default_next": "_condition_0"
826 + }
827 + ],
828 + "conditionals": [
829 + {
830 + "name": "_condition_0",
831 + "id": 0,
832 + "expression": {
833 + "type": "expression",
834 + "value": {
835 + "op": "<",
836 + "left": {
837 + "type": "field",
838 + "value": [
839 + "standard_metadata",
840 + "egress_spec"
841 + ]
842 + },
843 + "right": {
844 + "type": "hexstr",
845 + "value": "0xfe"
846 + }
847 + }
848 + },
849 + "true_next": "port_count_table",
850 + "false_next": null
851 + }
852 + ]
853 + },
854 + {
855 + "name": "egress",
856 + "id": 1,
857 + "init_table": null,
858 + "tables": [],
859 + "conditionals": []
860 + }
861 + ],
862 + "calculations": [
863 + {
864 + "name": "wcmp_hash",
865 + "id": 0,
866 + "input": [
867 + {
868 + "type": "field",
869 + "value": [
870 + "ipv4",
871 + "srcAddr"
872 + ]
873 + },
874 + {
875 + "type": "field",
876 + "value": [
877 + "ipv4",
878 + "dstAddr"
879 + ]
880 + },
881 + {
882 + "type": "field",
883 + "value": [
884 + "ipv4",
885 + "protocol"
886 + ]
887 + },
888 + {
889 + "type": "field",
890 + "value": [
891 + "tcp",
892 + "srcPort"
893 + ]
894 + },
895 + {
896 + "type": "field",
897 + "value": [
898 + "tcp",
899 + "dstPort"
900 + ]
901 + },
902 + {
903 + "type": "field",
904 + "value": [
905 + "udp",
906 + "srcPort"
907 + ]
908 + },
909 + {
910 + "type": "field",
911 + "value": [
912 + "udp",
913 + "dstPort"
914 + ]
915 + }
916 + ],
917 + "algo": "bmv2_hash"
918 + }
919 + ],
920 + "checksums": [],
921 + "learn_lists": [],
922 + "field_lists": [],
923 + "counter_arrays": [
924 + {
925 + "name": "ingress_port_counter",
926 + "id": 0,
927 + "is_direct": false,
928 + "size": 254
929 + },
930 + {
931 + "name": "egress_port_counter",
932 + "id": 1,
933 + "is_direct": false,
934 + "size": 254
935 + },
936 + {
937 + "name": "table0_counter",
938 + "id": 2,
939 + "is_direct": true,
940 + "binding": "table0"
941 + },
942 + {
943 + "name": "wcmp_group_table_counter",
944 + "id": 3,
945 + "is_direct": true,
946 + "binding": "wcmp_group_table"
947 + }
948 + ],
949 + "register_arrays": [],
950 + "force_arith": [
951 + [
952 + "standard_metadata",
953 + "ingress_port"
954 + ],
955 + [
956 + "standard_metadata",
957 + "packet_length"
958 + ],
959 + [
960 + "standard_metadata",
961 + "egress_spec"
962 + ],
963 + [
964 + "standard_metadata",
965 + "egress_port"
966 + ],
967 + [
968 + "standard_metadata",
969 + "egress_instance"
970 + ],
971 + [
972 + "standard_metadata",
973 + "instance_type"
974 + ],
975 + [
976 + "standard_metadata",
977 + "clone_spec"
978 + ],
979 + [
980 + "standard_metadata",
981 + "_padding"
982 + ],
983 + [
984 + "intrinsic_metadata",
985 + "ingress_global_timestamp"
986 + ],
987 + [
988 + "intrinsic_metadata",
989 + "lf_field_list"
990 + ],
991 + [
992 + "intrinsic_metadata",
993 + "mcast_grp"
994 + ],
995 + [
996 + "intrinsic_metadata",
997 + "egress_rid"
998 + ]
999 + ]
1000 +}
...\ No newline at end of file ...\ No newline at end of file
...@@ -18,6 +18,7 @@ package org.onosproject.drivers.bmv2; ...@@ -18,6 +18,7 @@ package org.onosproject.drivers.bmv2;
18 18
19 import com.google.common.collect.ImmutableList; 19 import com.google.common.collect.ImmutableList;
20 import com.google.common.collect.Lists; 20 import com.google.common.collect.Lists;
21 +import org.onlab.osgi.ServiceNotFoundException;
21 import org.onlab.packet.ChassisId; 22 import org.onlab.packet.ChassisId;
22 import org.onosproject.bmv2.api.runtime.Bmv2DeviceAgent; 23 import org.onosproject.bmv2.api.runtime.Bmv2DeviceAgent;
23 import org.onosproject.bmv2.api.runtime.Bmv2RuntimeException; 24 import org.onosproject.bmv2.api.runtime.Bmv2RuntimeException;
...@@ -54,12 +55,13 @@ public class Bmv2DeviceDescriptionDiscovery extends AbstractHandlerBehaviour imp ...@@ -54,12 +55,13 @@ public class Bmv2DeviceDescriptionDiscovery extends AbstractHandlerBehaviour imp
54 private Bmv2Controller controller; 55 private Bmv2Controller controller;
55 56
56 private boolean init() { 57 private boolean init() {
57 - controller = handler().get(Bmv2Controller.class); 58 + try {
58 - if (controller == null) { 59 + controller = handler().get(Bmv2Controller.class);
59 - log.warn("Failed to get a BMv2 controller"); 60 + return true;
61 + } catch (ServiceNotFoundException e) {
62 + log.warn(e.getMessage());
60 return false; 63 return false;
61 } 64 }
62 - return true;
63 } 65 }
64 66
65 @Override 67 @Override
......
...@@ -19,6 +19,7 @@ package org.onosproject.drivers.bmv2; ...@@ -19,6 +19,7 @@ package org.onosproject.drivers.bmv2;
19 import com.google.common.collect.Lists; 19 import com.google.common.collect.Lists;
20 import com.google.common.collect.Maps; 20 import com.google.common.collect.Maps;
21 import org.apache.commons.lang3.tuple.Pair; 21 import org.apache.commons.lang3.tuple.Pair;
22 +import org.onlab.osgi.ServiceNotFoundException;
22 import org.onosproject.bmv2.api.context.Bmv2Configuration; 23 import org.onosproject.bmv2.api.context.Bmv2Configuration;
23 import org.onosproject.bmv2.api.context.Bmv2DeviceContext; 24 import org.onosproject.bmv2.api.context.Bmv2DeviceContext;
24 import org.onosproject.bmv2.api.context.Bmv2FlowRuleTranslator; 25 import org.onosproject.bmv2.api.context.Bmv2FlowRuleTranslator;
...@@ -70,22 +71,15 @@ public class Bmv2FlowRuleProgrammable extends AbstractHandlerBehaviour implement ...@@ -70,22 +71,15 @@ public class Bmv2FlowRuleProgrammable extends AbstractHandlerBehaviour implement
70 private Bmv2DeviceContextService contextService; 71 private Bmv2DeviceContextService contextService;
71 72
72 private boolean init() { 73 private boolean init() {
73 - controller = handler().get(Bmv2Controller.class); 74 + try {
74 - tableEntryService = handler().get(Bmv2TableEntryService.class); 75 + controller = handler().get(Bmv2Controller.class);
75 - contextService = handler().get(Bmv2DeviceContextService.class); 76 + tableEntryService = handler().get(Bmv2TableEntryService.class);
76 - if (controller == null) { 77 + contextService = handler().get(Bmv2DeviceContextService.class);
77 - log.warn("Failed to get a BMv2 controller"); 78 + return true;
78 - return false; 79 + } catch (ServiceNotFoundException e) {
79 - } 80 + log.warn(e.getMessage());
80 - if (tableEntryService == null) {
81 - log.warn("Failed to get a BMv2 table entry service");
82 - return false;
83 - }
84 - if (contextService == null) {
85 - log.warn("Failed to get a BMv2 device context service");
86 return false; 81 return false;
87 } 82 }
88 - return true;
89 } 83 }
90 84
91 @Override 85 @Override
...@@ -140,9 +134,14 @@ public class Bmv2FlowRuleProgrammable extends AbstractHandlerBehaviour implement ...@@ -140,9 +134,14 @@ public class Bmv2FlowRuleProgrammable extends AbstractHandlerBehaviour implement
140 Bmv2FlowRuleWrapper frWrapper = tableEntryService.lookup(entryRef); 134 Bmv2FlowRuleWrapper frWrapper = tableEntryService.lookup(entryRef);
141 135
142 if (frWrapper == null) { 136 if (frWrapper == null) {
143 - log.warn("missing reference from table entry service, BUG? " + 137 + log.debug("Missing reference from table entry service. Deleting it. BUG? " +
144 "deviceId={}, tableName={}, matchKey={}", 138 "deviceId={}, tableName={}, matchKey={}",
145 deviceId, table.name(), entryRef.matchKey()); 139 deviceId, table.name(), entryRef.matchKey());
140 + try {
141 + doRemove(deviceAgent, table.name(), parsedEntry.entryId(), parsedEntry.matchKey());
142 + } catch (Bmv2RuntimeException e) {
143 + log.warn("Unable to remove inconsistent flow rule: {}", e.explain());
144 + }
146 continue; // next entry 145 continue; // next entry
147 } 146 }
148 147
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
16 16
17 package org.onosproject.drivers.bmv2; 17 package org.onosproject.drivers.bmv2;
18 18
19 +import org.onlab.osgi.ServiceNotFoundException;
19 import org.onlab.util.ImmutableByteSequence; 20 import org.onlab.util.ImmutableByteSequence;
20 import org.onosproject.bmv2.api.runtime.Bmv2DeviceAgent; 21 import org.onosproject.bmv2.api.runtime.Bmv2DeviceAgent;
21 import org.onosproject.bmv2.api.runtime.Bmv2RuntimeException; 22 import org.onosproject.bmv2.api.runtime.Bmv2RuntimeException;
...@@ -78,9 +79,11 @@ public class Bmv2PacketProgrammable extends AbstractHandlerBehaviour implements ...@@ -78,9 +79,11 @@ public class Bmv2PacketProgrammable extends AbstractHandlerBehaviour implements
78 79
79 DeviceId deviceId = handler().data().deviceId(); 80 DeviceId deviceId = handler().data().deviceId();
80 81
81 - Bmv2Controller controller = handler().get(Bmv2Controller.class); 82 + Bmv2Controller controller;
82 - if (controller == null) { 83 + try {
83 - log.error("Failed to get BMv2 controller"); 84 + controller = handler().get(Bmv2Controller.class);
85 + } catch (ServiceNotFoundException e) {
86 + log.warn(e.getMessage());
84 return; 87 return;
85 } 88 }
86 89
......
...@@ -189,16 +189,17 @@ public class Bmv2DeviceProvider extends AbstractDeviceProvider { ...@@ -189,16 +189,17 @@ public class Bmv2DeviceProvider extends AbstractDeviceProvider {
189 (!Objects.equals(thisDescription, lastDescription) || 189 (!Objects.equals(thisDescription, lastDescription) ||
190 !Objects.equals(thisDescription.annotations(), lastDescription.annotations())); 190 !Objects.equals(thisDescription.annotations(), lastDescription.annotations()));
191 if (descriptionChanged || !deviceService.isAvailable(did)) { 191 if (descriptionChanged || !deviceService.isAvailable(did)) {
192 - if (contextService.getContext(did) == null) { 192 + if (deviceService.getDevice(did) == null) {
193 // Device is a first timer. 193 // Device is a first timer.
194 log.info("Setting DEFAULT context for {}", did); 194 log.info("Setting DEFAULT context for {}", did);
195 + // It is important to do this before connecting the device so other
196 + // services won't find a null context.
195 contextService.setContext(did, contextService.defaultContext()); 197 contextService.setContext(did, contextService.defaultContext());
196 - } else {
197 - resetDeviceState(did);
198 - initPortCounters(did);
199 - providerService.deviceConnected(did, thisDescription);
200 - updatePortsAndStats(did);
201 } 198 }
199 + resetDeviceState(did);
200 + initPortCounters(did);
201 + providerService.deviceConnected(did, thisDescription);
202 + updatePortsAndStats(did);
202 } 203 }
203 return thisDescription; 204 return thisDescription;
204 } else { 205 } else {
...@@ -272,7 +273,7 @@ public class Bmv2DeviceProvider extends AbstractDeviceProvider { ...@@ -272,7 +273,7 @@ public class Bmv2DeviceProvider extends AbstractDeviceProvider {
272 if (deviceService.isAvailable(did)) { 273 if (deviceService.isAvailable(did)) {
273 providerService.deviceDisconnected(did); 274 providerService.deviceDisconnected(did);
274 } 275 }
275 - activeDevices.put(did, null); 276 + activeDevices.remove(did);
276 } 277 }
277 278
278 /** 279 /**
...@@ -333,7 +334,7 @@ public class Bmv2DeviceProvider extends AbstractDeviceProvider { ...@@ -333,7 +334,7 @@ public class Bmv2DeviceProvider extends AbstractDeviceProvider {
333 } 334 }
334 335
335 /** 336 /**
336 - * Task that periodically trigger device probes to check for device status and update port informations. 337 + * Task that periodically trigger device probes to check for device status and update port information.
337 */ 338 */
338 private class DevicePoller implements TimerTask { 339 private class DevicePoller implements TimerTask {
339 340
......