Michele Santuari
Committed by Gerrit Code Review

corsa support intent

Change-Id: I6eaa46d1ef39405defa3b0661e94d1cf285db332
...@@ -33,7 +33,10 @@ import org.onosproject.net.flow.DefaultTrafficTreatment; ...@@ -33,7 +33,10 @@ import org.onosproject.net.flow.DefaultTrafficTreatment;
33 import org.onosproject.net.flow.TrafficSelector; 33 import org.onosproject.net.flow.TrafficSelector;
34 import org.onosproject.net.flow.TrafficTreatment; 34 import org.onosproject.net.flow.TrafficTreatment;
35 import org.onosproject.net.flowobjective.DefaultForwardingObjective; 35 import org.onosproject.net.flowobjective.DefaultForwardingObjective;
36 +import org.onosproject.net.flowobjective.DefaultNextObjective;
37 +import org.onosproject.net.flowobjective.FlowObjectiveService;
36 import org.onosproject.net.flowobjective.ForwardingObjective; 38 import org.onosproject.net.flowobjective.ForwardingObjective;
39 +import org.onosproject.net.flowobjective.NextObjective;
37 import org.onosproject.net.flowobjective.Objective; 40 import org.onosproject.net.flowobjective.Objective;
38 import org.onosproject.net.intent.FlowObjectiveIntent; 41 import org.onosproject.net.intent.FlowObjectiveIntent;
39 import org.onosproject.net.intent.Intent; 42 import org.onosproject.net.intent.Intent;
...@@ -58,6 +61,9 @@ public class LinkCollectionIntentFlowObjectivesCompiler implements IntentCompile ...@@ -58,6 +61,9 @@ public class LinkCollectionIntentFlowObjectivesCompiler implements IntentCompile
58 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 61 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
59 protected CoreService coreService; 62 protected CoreService coreService;
60 63
64 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
65 + protected FlowObjectiveService flowObjectiveService;
66 +
61 private ApplicationId appId; 67 private ApplicationId appId;
62 68
63 @Activate 69 @Activate
...@@ -133,16 +139,22 @@ public class LinkCollectionIntentFlowObjectivesCompiler implements IntentCompile ...@@ -133,16 +139,22 @@ public class LinkCollectionIntentFlowObjectivesCompiler implements IntentCompile
133 treatment = defaultTreatment; 139 treatment = defaultTreatment;
134 } 140 }
135 141
136 - Objective objective = DefaultForwardingObjective.builder() 142 + NextObjective nextObjective = DefaultNextObjective.builder()
143 + .withId(flowObjectiveService.allocateNextId())
144 + .addTreatment(treatment)
145 + .withType(NextObjective.Type.SIMPLE)
146 + .fromApp(appId)
147 + .makePermanent().add();
148 + objectives.add(nextObjective);
149 +
150 + objectives.add(DefaultForwardingObjective.builder()
137 .withSelector(selector) 151 .withSelector(selector)
138 - .withTreatment(treatment) 152 + .nextStep(nextObjective.id())
139 .withPriority(intent.priority()) 153 .withPriority(intent.priority())
140 .fromApp(appId) 154 .fromApp(appId)
141 .makePermanent() 155 .makePermanent()
142 .withFlag(ForwardingObjective.Flag.SPECIFIC) 156 .withFlag(ForwardingObjective.Flag.SPECIFIC)
143 - .add(); 157 + .add());
144 -
145 - objectives.add(objective);
146 } 158 }
147 159
148 return objectives; 160 return objectives;
......
...@@ -15,9 +15,7 @@ ...@@ -15,9 +15,7 @@
15 */ 15 */
16 package org.onosproject.net.intent.impl.compiler; 16 package org.onosproject.net.intent.impl.compiler;
17 17
18 -import java.util.LinkedList; 18 +import com.google.common.collect.ImmutableList;
19 -import java.util.List;
20 -
21 import org.apache.felix.scr.annotations.Activate; 19 import org.apache.felix.scr.annotations.Activate;
22 import org.apache.felix.scr.annotations.Component; 20 import org.apache.felix.scr.annotations.Component;
23 import org.apache.felix.scr.annotations.Deactivate; 21 import org.apache.felix.scr.annotations.Deactivate;
...@@ -32,7 +30,10 @@ import org.onosproject.net.flow.DefaultTrafficTreatment; ...@@ -32,7 +30,10 @@ import org.onosproject.net.flow.DefaultTrafficTreatment;
32 import org.onosproject.net.flow.TrafficSelector; 30 import org.onosproject.net.flow.TrafficSelector;
33 import org.onosproject.net.flow.TrafficTreatment; 31 import org.onosproject.net.flow.TrafficTreatment;
34 import org.onosproject.net.flowobjective.DefaultForwardingObjective; 32 import org.onosproject.net.flowobjective.DefaultForwardingObjective;
33 +import org.onosproject.net.flowobjective.DefaultNextObjective;
34 +import org.onosproject.net.flowobjective.FlowObjectiveService;
35 import org.onosproject.net.flowobjective.ForwardingObjective; 35 import org.onosproject.net.flowobjective.ForwardingObjective;
36 +import org.onosproject.net.flowobjective.NextObjective;
36 import org.onosproject.net.flowobjective.Objective; 37 import org.onosproject.net.flowobjective.Objective;
37 import org.onosproject.net.intent.FlowObjectiveIntent; 38 import org.onosproject.net.intent.FlowObjectiveIntent;
38 import org.onosproject.net.intent.Intent; 39 import org.onosproject.net.intent.Intent;
...@@ -41,7 +42,8 @@ import org.onosproject.net.intent.PathIntent; ...@@ -41,7 +42,8 @@ import org.onosproject.net.intent.PathIntent;
41 import org.onosproject.net.resource.ResourceService; 42 import org.onosproject.net.resource.ResourceService;
42 import org.slf4j.Logger; 43 import org.slf4j.Logger;
43 44
44 -import com.google.common.collect.ImmutableList; 45 +import java.util.LinkedList;
46 +import java.util.List;
45 47
46 import static org.slf4j.LoggerFactory.getLogger; 48 import static org.slf4j.LoggerFactory.getLogger;
47 49
...@@ -62,6 +64,9 @@ public class PathIntentFlowObjectiveCompiler ...@@ -62,6 +64,9 @@ public class PathIntentFlowObjectiveCompiler
62 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 64 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
63 protected ResourceService resourceService; 65 protected ResourceService resourceService;
64 66
67 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
68 + protected FlowObjectiveService flowObjectiveService;
69 +
65 private ApplicationId appId; 70 private ApplicationId appId;
66 71
67 @Activate 72 @Activate
...@@ -111,16 +116,26 @@ public class PathIntentFlowObjectiveCompiler ...@@ -111,16 +116,26 @@ public class PathIntentFlowObjectiveCompiler
111 } else { 116 } else {
112 treatmentBuilder = DefaultTrafficTreatment.builder(); 117 treatmentBuilder = DefaultTrafficTreatment.builder();
113 } 118 }
119 +
114 TrafficTreatment treatment = treatmentBuilder.setOutput(egress.port()).build(); 120 TrafficTreatment treatment = treatmentBuilder.setOutput(egress.port()).build();
115 121
122 + NextObjective nextObjective = DefaultNextObjective.builder()
123 + .withId(flowObjectiveService.allocateNextId())
124 + .addTreatment(treatment)
125 + .withType(NextObjective.Type.SIMPLE)
126 + .fromApp(appId)
127 + .makePermanent().add();
128 + objectives.add(nextObjective);
129 + devices.add(ingress.deviceId());
130 +
116 objectives.add(DefaultForwardingObjective.builder() 131 objectives.add(DefaultForwardingObjective.builder()
117 - .withSelector(selector) 132 + .withSelector(selector)
118 - .withTreatment(treatment) 133 + .nextStep(nextObjective.id())
119 - .withPriority(priority) 134 + .withPriority(priority)
120 - .fromApp(appId) 135 + .fromApp(appId)
121 - .makePermanent() 136 + .makePermanent()
122 - .withFlag(ForwardingObjective.Flag.SPECIFIC) 137 + .withFlag(ForwardingObjective.Flag.SPECIFIC)
123 - .add()); 138 + .add());
124 devices.add(ingress.deviceId()); 139 devices.add(ingress.deviceId());
125 } 140 }
126 } 141 }
......
...@@ -20,6 +20,7 @@ import com.google.common.cache.Cache; ...@@ -20,6 +20,7 @@ import com.google.common.cache.Cache;
20 import com.google.common.cache.CacheBuilder; 20 import com.google.common.cache.CacheBuilder;
21 import com.google.common.cache.RemovalCause; 21 import com.google.common.cache.RemovalCause;
22 import com.google.common.cache.RemovalNotification; 22 import com.google.common.cache.RemovalNotification;
23 +import com.google.common.collect.ImmutableSet;
23 import org.onlab.osgi.ServiceDirectory; 24 import org.onlab.osgi.ServiceDirectory;
24 import org.onlab.packet.Ethernet; 25 import org.onlab.packet.Ethernet;
25 import org.onlab.util.KryoNamespace; 26 import org.onlab.util.KryoNamespace;
...@@ -347,7 +348,7 @@ public abstract class AbstractCorsaPipeline extends AbstractHandlerBehaviour imp ...@@ -347,7 +348,7 @@ public abstract class AbstractCorsaPipeline extends AbstractHandlerBehaviour imp
347 fail(fwd, ObjectiveError.UNKNOWN); 348 fail(fwd, ObjectiveError.UNKNOWN);
348 log.warn("Unknown forwarding flag {}", fwd.flag()); 349 log.warn("Unknown forwarding flag {}", fwd.flag());
349 } 350 }
350 - return Collections.emptySet(); 351 + return ImmutableSet.of();
351 } 352 }
352 353
353 private Collection<FlowRule> processSpecific(ForwardingObjective fwd) { 354 private Collection<FlowRule> processSpecific(ForwardingObjective fwd) {
...@@ -366,14 +367,14 @@ public abstract class AbstractCorsaPipeline extends AbstractHandlerBehaviour imp ...@@ -366,14 +367,14 @@ public abstract class AbstractCorsaPipeline extends AbstractHandlerBehaviour imp
366 } 367 }
367 368
368 fail(fwd, ObjectiveError.UNSUPPORTED); 369 fail(fwd, ObjectiveError.UNSUPPORTED);
369 - return Collections.emptySet(); 370 + return ImmutableSet.of();
370 } 371 }
371 372
372 protected Collection<FlowRule> processSpecificSwitch(ForwardingObjective fwd) { 373 protected Collection<FlowRule> processSpecificSwitch(ForwardingObjective fwd) {
373 /* Not supported by until CorsaPipelineV3 */ 374 /* Not supported by until CorsaPipelineV3 */
374 log.warn("Vlan switching not supported in ovs-corsa driver"); 375 log.warn("Vlan switching not supported in ovs-corsa driver");
375 fail(fwd, ObjectiveError.UNSUPPORTED); 376 fail(fwd, ObjectiveError.UNSUPPORTED);
376 - return Collections.emptySet(); 377 + return ImmutableSet.of();
377 } 378 }
378 379
379 private Collection<FlowRule> processVersatile(ForwardingObjective fwd) { 380 private Collection<FlowRule> processVersatile(ForwardingObjective fwd) {
...@@ -385,7 +386,7 @@ public abstract class AbstractCorsaPipeline extends AbstractHandlerBehaviour imp ...@@ -385,7 +386,7 @@ public abstract class AbstractCorsaPipeline extends AbstractHandlerBehaviour imp
385 if (ethType == null) { 386 if (ethType == null) {
386 log.error("Versatile forwarding objective must include ethType"); 387 log.error("Versatile forwarding objective must include ethType");
387 fail(fwd, ObjectiveError.UNKNOWN); 388 fail(fwd, ObjectiveError.UNKNOWN);
388 - return Collections.emptySet(); 389 + return ImmutableSet.of();
389 } 390 }
390 Builder rule = DefaultFlowRule.builder() 391 Builder rule = DefaultFlowRule.builder()
391 .forDevice(deviceId) 392 .forDevice(deviceId)
...@@ -404,7 +405,7 @@ public abstract class AbstractCorsaPipeline extends AbstractHandlerBehaviour imp ...@@ -404,7 +405,7 @@ public abstract class AbstractCorsaPipeline extends AbstractHandlerBehaviour imp
404 } 405 }
405 log.warn("Driver does not support given versatile forwarding objective"); 406 log.warn("Driver does not support given versatile forwarding objective");
406 fail(fwd, ObjectiveError.UNSUPPORTED); 407 fail(fwd, ObjectiveError.UNSUPPORTED);
407 - return Collections.emptySet(); 408 + return ImmutableSet.of();
408 } 409 }
409 410
410 protected abstract Collection<FlowRule> processArpTraffic(ForwardingObjective fwd, Builder rule); 411 protected abstract Collection<FlowRule> processArpTraffic(ForwardingObjective fwd, Builder rule);
...@@ -430,9 +431,13 @@ public abstract class AbstractCorsaPipeline extends AbstractHandlerBehaviour imp ...@@ -430,9 +431,13 @@ public abstract class AbstractCorsaPipeline extends AbstractHandlerBehaviour imp
430 if (group == null) { 431 if (group == null) {
431 log.warn("The group left!"); 432 log.warn("The group left!");
432 fail(fwd, ObjectiveError.GROUPMISSING); 433 fail(fwd, ObjectiveError.GROUPMISSING);
433 - return Collections.emptySet(); 434 + return ImmutableSet.of();
434 } 435 }
435 tb.group(group.id()); 436 tb.group(group.id());
437 + } else {
438 + log.error("Missing NextObjective ID for ForwardingObjective {}", fwd.id());
439 + fail(fwd, ObjectiveError.BADPARAMS);
440 + return ImmutableSet.of();
436 } 441 }
437 Builder ruleBuilder = DefaultFlowRule.builder() 442 Builder ruleBuilder = DefaultFlowRule.builder()
438 .fromApp(fwd.appId()) 443 .fromApp(fwd.appId())
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
15 */ 15 */
16 package org.onosproject.drivers.corsa; 16 package org.onosproject.drivers.corsa;
17 17
18 +import com.google.common.collect.ImmutableSet;
18 import org.onlab.packet.Ethernet; 19 import org.onlab.packet.Ethernet;
19 import org.onlab.packet.MacAddress; 20 import org.onlab.packet.MacAddress;
20 import org.onlab.packet.VlanId; 21 import org.onlab.packet.VlanId;
...@@ -129,24 +130,24 @@ public class CorsaPipelineV3 extends AbstractCorsaPipeline { ...@@ -129,24 +130,24 @@ public class CorsaPipelineV3 extends AbstractCorsaPipeline {
129 @Override 130 @Override
130 protected Collection<FlowRule> processArpTraffic(ForwardingObjective fwd, Builder rule) { 131 protected Collection<FlowRule> processArpTraffic(ForwardingObjective fwd, Builder rule) {
131 //TODO 132 //TODO
132 - return Collections.emptyList(); 133 + return ImmutableSet.of();
133 } 134 }
134 135
135 @Override 136 @Override
136 protected Collection<FlowRule> processLinkDiscovery(ForwardingObjective fwd, Builder rule) { 137 protected Collection<FlowRule> processLinkDiscovery(ForwardingObjective fwd, Builder rule) {
137 //TODO 138 //TODO
138 - return Collections.emptyList(); 139 + return ImmutableSet.of();
139 } 140 }
140 141
141 @Override 142 @Override
142 protected Collection<FlowRule> processIpTraffic(ForwardingObjective fwd, Builder rule) { 143 protected Collection<FlowRule> processIpTraffic(ForwardingObjective fwd, Builder rule) {
143 //TODO 144 //TODO
144 - return Collections.emptyList(); 145 + return ImmutableSet.of();
145 } 146 }
146 147
147 @Override 148 @Override
148 protected Builder processEthFiler(FilteringObjective filt, EthCriterion eth, PortCriterion port) { 149 protected Builder processEthFiler(FilteringObjective filt, EthCriterion eth, PortCriterion port) {
149 - log.debug("adding rule for MAC: {}", eth.mac()); 150 + log.debug("adding rule for MAC: {}", eth.mac());
150 TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); 151 TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
151 TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); 152 TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
152 selector.matchEthDst(eth.mac()); 153 selector.matchEthDst(eth.mac());
...@@ -338,7 +339,7 @@ public class CorsaPipelineV3 extends AbstractCorsaPipeline { ...@@ -338,7 +339,7 @@ public class CorsaPipelineV3 extends AbstractCorsaPipeline {
338 processFlowRule(install, rule, "Provisioned ether type table ip"); 339 processFlowRule(install, rule, "Provisioned ether type table ip");
339 } 340 }
340 341
341 - private void processFibTable(boolean install) { 342 + protected void processFibTable(boolean install) {
342 /* Default action */ 343 /* Default action */
343 processTableMissDrop(install, FIB_TABLE, "Provisioned fib drop"); 344 processTableMissDrop(install, FIB_TABLE, "Provisioned fib drop");
344 } 345 }
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
16 16
17 package org.onosproject.drivers.corsa; 17 package org.onosproject.drivers.corsa;
18 18
19 +import com.google.common.collect.ImmutableSet;
19 import org.onlab.packet.Ethernet; 20 import org.onlab.packet.Ethernet;
20 import org.onlab.packet.IPv4; 21 import org.onlab.packet.IPv4;
21 import org.onlab.packet.VlanId; 22 import org.onlab.packet.VlanId;
...@@ -28,6 +29,8 @@ import org.onosproject.net.flow.TrafficTreatment; ...@@ -28,6 +29,8 @@ import org.onosproject.net.flow.TrafficTreatment;
28 import org.onosproject.net.flow.criteria.Criterion; 29 import org.onosproject.net.flow.criteria.Criterion;
29 import org.onosproject.net.flow.criteria.IPCriterion; 30 import org.onosproject.net.flow.criteria.IPCriterion;
30 import org.onosproject.net.flow.criteria.IPProtocolCriterion; 31 import org.onosproject.net.flow.criteria.IPProtocolCriterion;
32 +import org.onosproject.net.flow.instructions.Instructions;
33 +import org.onosproject.net.flow.instructions.L2ModificationInstruction;
31 import org.onosproject.net.flowobjective.ForwardingObjective; 34 import org.onosproject.net.flowobjective.ForwardingObjective;
32 import org.onosproject.net.flowobjective.ObjectiveError; 35 import org.onosproject.net.flowobjective.ObjectiveError;
33 import org.slf4j.Logger; 36 import org.slf4j.Logger;
...@@ -36,6 +39,10 @@ import java.util.Collection; ...@@ -36,6 +39,10 @@ import java.util.Collection;
36 import java.util.Collections; 39 import java.util.Collections;
37 40
38 import static org.onosproject.net.flow.FlowRule.Builder; 41 import static org.onosproject.net.flow.FlowRule.Builder;
42 +import static org.onosproject.net.flow.instructions.L2ModificationInstruction.L2SubType.ETH_DST;
43 +import static org.onosproject.net.flow.instructions.L2ModificationInstruction.L2SubType.ETH_SRC;
44 +import static org.onosproject.net.flow.instructions.L2ModificationInstruction.L2SubType.VLAN_ID;
45 +import static org.onosproject.net.flow.instructions.L2ModificationInstruction.L2SubType.VLAN_POP;
39 import static org.slf4j.LoggerFactory.getLogger; 46 import static org.slf4j.LoggerFactory.getLogger;
40 47
41 public class CorsaPipelineV39 extends CorsaPipelineV3 { 48 public class CorsaPipelineV39 extends CorsaPipelineV3 {
...@@ -55,13 +62,13 @@ public class CorsaPipelineV39 extends CorsaPipelineV3 { ...@@ -55,13 +62,13 @@ public class CorsaPipelineV39 extends CorsaPipelineV3 {
55 processL3IFMacDATable(true); //Table 5 62 processL3IFMacDATable(true); //Table 5
56 processEtherTable(true); //Table 6 63 processEtherTable(true); //Table 6
57 //TODO: to be implemented for intents 64 //TODO: to be implemented for intents
58 - //processFibTable(true); //Table 7 65 + processFibTable(true); //Table 7
59 //processLocalTable(true); //Table 9 66 //processLocalTable(true); //Table 9
60 } 67 }
61 68
62 @Override 69 @Override
63 protected void processVlanCheckTable(boolean install) { 70 protected void processVlanCheckTable(boolean install) {
64 - //FIXME: error 71 + //current device pipeline reports errors, but it is a bug
65 processTableMissGoTo(true, VLAN_CHECK_TABLE, VLAN_MAC_XLATE_TABLE, "Provisioned vlan tagged"); 72 processTableMissGoTo(true, VLAN_CHECK_TABLE, VLAN_MAC_XLATE_TABLE, "Provisioned vlan tagged");
66 //Tag untagged packets 73 //Tag untagged packets
67 processUntaggedPackets(install); 74 processUntaggedPackets(install);
...@@ -197,7 +204,7 @@ public class CorsaPipelineV39 extends CorsaPipelineV3 { ...@@ -197,7 +204,7 @@ public class CorsaPipelineV39 extends CorsaPipelineV3 {
197 if (ipSrc != null) { 204 if (ipSrc != null) {
198 log.warn("Driver does not currently handle matching Src IP"); 205 log.warn("Driver does not currently handle matching Src IP");
199 fail(fwd, ObjectiveError.UNSUPPORTED); 206 fail(fwd, ObjectiveError.UNSUPPORTED);
200 - return Collections.emptySet(); 207 + return ImmutableSet.of();
201 } 208 }
202 IPCriterion ipDst = (IPCriterion) fwd.selector() 209 IPCriterion ipDst = (IPCriterion) fwd.selector()
203 .getCriterion(Criterion.Type.IPV4_DST); 210 .getCriterion(Criterion.Type.IPV4_DST);
...@@ -205,7 +212,7 @@ public class CorsaPipelineV39 extends CorsaPipelineV3 { ...@@ -205,7 +212,7 @@ public class CorsaPipelineV39 extends CorsaPipelineV3 {
205 log.error("Driver handles Dst IP matching as specific forwarding " 212 log.error("Driver handles Dst IP matching as specific forwarding "
206 + "objective, not versatile"); 213 + "objective, not versatile");
207 fail(fwd, ObjectiveError.UNSUPPORTED); 214 fail(fwd, ObjectiveError.UNSUPPORTED);
208 - return Collections.emptySet(); 215 + return ImmutableSet.of();
209 } 216 }
210 IPProtocolCriterion ipProto = (IPProtocolCriterion) fwd.selector() 217 IPProtocolCriterion ipProto = (IPProtocolCriterion) fwd.selector()
211 .getCriterion(Criterion.Type.IP_PROTO); 218 .getCriterion(Criterion.Type.IP_PROTO);
...@@ -213,8 +220,33 @@ public class CorsaPipelineV39 extends CorsaPipelineV3 { ...@@ -213,8 +220,33 @@ public class CorsaPipelineV39 extends CorsaPipelineV3 {
213 log.warn("Driver automatically punts all packets reaching the " 220 log.warn("Driver automatically punts all packets reaching the "
214 + "LOCAL table to the controller"); 221 + "LOCAL table to the controller");
215 pass(fwd); 222 pass(fwd);
216 - return Collections.emptySet(); 223 + return ImmutableSet.of();
217 } 224 }
218 - return Collections.emptySet(); 225 + return ImmutableSet.of();
226 + }
227 +
228 + @Override
229 + protected TrafficTreatment processNextTreatment(TrafficTreatment treatment) {
230 + TrafficTreatment.Builder tb = DefaultTrafficTreatment.builder();
231 + tb.add(Instructions.popVlan());
232 + treatment.immediate().stream()
233 + .filter(i -> {
234 + switch (i.type()) {
235 + case L2MODIFICATION:
236 + L2ModificationInstruction l2i = (L2ModificationInstruction) i;
237 + if (l2i.subtype() == VLAN_ID ||
238 + l2i.subtype() == VLAN_POP ||
239 + l2i.subtype() == VLAN_POP ||
240 + l2i.subtype() == ETH_DST ||
241 + l2i.subtype() == ETH_SRC) {
242 + return true;
243 + }
244 + case OUTPUT:
245 + return true;
246 + default:
247 + return false;
248 + }
249 + }).forEach(i -> tb.add(i));
250 + return tb.build();
219 } 251 }
220 } 252 }
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
42 impl="org.onosproject.drivers.corsa.CorsaSwitchHandshaker"/> 42 impl="org.onosproject.drivers.corsa.CorsaSwitchHandshaker"/>
43 </driver> 43 </driver>
44 <driver name="corsa-v39" 44 <driver name="corsa-v39"
45 - manufacturer="Corsa" hwVersion="CDP6420-A00" swVersion="corsa-ovs-datapath 1.4.88"> 45 + manufacturer="Corsa" hwVersion="CDP6420-A00" swVersion="corsa-ovs-datapath 1.4.97">
46 <behaviour api="org.onosproject.net.behaviour.Pipeliner" 46 <behaviour api="org.onosproject.net.behaviour.Pipeliner"
47 impl="org.onosproject.drivers.corsa.CorsaPipelineV39"/> 47 impl="org.onosproject.drivers.corsa.CorsaPipelineV39"/>
48 <behaviour api="org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver" 48 <behaviour api="org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver"
......
...@@ -15,7 +15,12 @@ ...@@ -15,7 +15,12 @@
15 */ 15 */
16 package org.onosproject.driver.pipeline; 16 package org.onosproject.driver.pipeline;
17 17
18 +import com.google.common.cache.Cache;
19 +import com.google.common.cache.CacheBuilder;
20 +import com.google.common.cache.RemovalCause;
21 +import com.google.common.cache.RemovalNotification;
18 import org.onlab.osgi.ServiceDirectory; 22 import org.onlab.osgi.ServiceDirectory;
23 +import org.onlab.util.KryoNamespace;
19 import org.onosproject.net.DeviceId; 24 import org.onosproject.net.DeviceId;
20 import org.onosproject.net.behaviour.NextGroup; 25 import org.onosproject.net.behaviour.NextGroup;
21 import org.onosproject.net.behaviour.Pipeliner; 26 import org.onosproject.net.behaviour.Pipeliner;
...@@ -30,17 +35,20 @@ import org.onosproject.net.flow.FlowRuleOperationsContext; ...@@ -30,17 +35,20 @@ import org.onosproject.net.flow.FlowRuleOperationsContext;
30 import org.onosproject.net.flow.FlowRuleService; 35 import org.onosproject.net.flow.FlowRuleService;
31 import org.onosproject.net.flow.TrafficSelector; 36 import org.onosproject.net.flow.TrafficSelector;
32 import org.onosproject.net.flow.TrafficTreatment; 37 import org.onosproject.net.flow.TrafficTreatment;
33 -import org.onosproject.net.flow.instructions.Instructions;
34 import org.onosproject.net.flowobjective.FilteringObjective; 38 import org.onosproject.net.flowobjective.FilteringObjective;
39 +import org.onosproject.net.flowobjective.FlowObjectiveStore;
35 import org.onosproject.net.flowobjective.ForwardingObjective; 40 import org.onosproject.net.flowobjective.ForwardingObjective;
36 import org.onosproject.net.flowobjective.NextObjective; 41 import org.onosproject.net.flowobjective.NextObjective;
37 import org.onosproject.net.flowobjective.Objective; 42 import org.onosproject.net.flowobjective.Objective;
38 import org.onosproject.net.flowobjective.ObjectiveError; 43 import org.onosproject.net.flowobjective.ObjectiveError;
44 +import org.onosproject.net.group.DefaultGroupKey;
45 +import org.onosproject.net.group.GroupKey;
39 import org.slf4j.Logger; 46 import org.slf4j.Logger;
40 47
41 -import static org.slf4j.LoggerFactory.getLogger;
42 -
43 import java.util.List; 48 import java.util.List;
49 +import java.util.concurrent.TimeUnit;
50 +
51 +import static org.slf4j.LoggerFactory.getLogger;
44 52
45 /** 53 /**
46 * Simple single table pipeline abstraction. 54 * Simple single table pipeline abstraction.
...@@ -51,14 +59,36 @@ public class DefaultSingleTablePipeline extends AbstractHandlerBehaviour impleme ...@@ -51,14 +59,36 @@ public class DefaultSingleTablePipeline extends AbstractHandlerBehaviour impleme
51 59
52 private ServiceDirectory serviceDirectory; 60 private ServiceDirectory serviceDirectory;
53 private FlowRuleService flowRuleService; 61 private FlowRuleService flowRuleService;
62 + private FlowObjectiveStore flowObjectiveStore;
54 private DeviceId deviceId; 63 private DeviceId deviceId;
55 64
65 + private Cache<Integer, NextObjective> pendingNext;
66 +
67 + private KryoNamespace appKryo = new KryoNamespace.Builder()
68 + .register(GroupKey.class)
69 + .register(DefaultGroupKey.class)
70 + .register(SingleGroup.class)
71 + .register(byte[].class)
72 + .build();
73 +
74 +
56 @Override 75 @Override
57 public void init(DeviceId deviceId, PipelinerContext context) { 76 public void init(DeviceId deviceId, PipelinerContext context) {
58 this.serviceDirectory = context.directory(); 77 this.serviceDirectory = context.directory();
59 this.deviceId = deviceId; 78 this.deviceId = deviceId;
60 79
61 flowRuleService = serviceDirectory.get(FlowRuleService.class); 80 flowRuleService = serviceDirectory.get(FlowRuleService.class);
81 + flowObjectiveStore = serviceDirectory.get(FlowObjectiveStore.class);
82 +
83 + pendingNext = CacheBuilder.newBuilder()
84 + .expireAfterWrite(20, TimeUnit.SECONDS)
85 + .removalListener((RemovalNotification<Integer, NextObjective> notification) -> {
86 + if (notification.getCause() == RemovalCause.EXPIRED) {
87 + notification.getValue().context()
88 + .ifPresent(c -> c.onError(notification.getValue(),
89 + ObjectiveError.FLOWINSTALLATIONFAILED));
90 + }
91 + }).build();
62 } 92 }
63 93
64 @Override 94 @Override
...@@ -109,33 +139,48 @@ public class DefaultSingleTablePipeline extends AbstractHandlerBehaviour impleme ...@@ -109,33 +139,48 @@ public class DefaultSingleTablePipeline extends AbstractHandlerBehaviour impleme
109 139
110 @Override 140 @Override
111 public void forward(ForwardingObjective fwd) { 141 public void forward(ForwardingObjective fwd) {
112 - // Deal with SPECIFIC and VERSATILE in the same manner.
113 TrafficSelector selector = fwd.selector(); 142 TrafficSelector selector = fwd.selector();
114 - TrafficTreatment treatment = fwd.treatment();
115 - if ((fwd.treatment().deferred().size() == 0) &&
116 - (fwd.treatment().immediate().size() == 0) &&
117 - (fwd.treatment().tableTransition() == null) &&
118 - (!fwd.treatment().clearedDeferred())) {
119 - TrafficTreatment.Builder flowTreatment = DefaultTrafficTreatment.builder();
120 - flowTreatment.add(Instructions.createNoAction());
121 - treatment = flowTreatment.build();
122 - }
123 143
124 - FlowRule.Builder ruleBuilder = DefaultFlowRule.builder() 144 + if (fwd.treatment() != null) {
125 - .forDevice(deviceId) 145 + // Deal with SPECIFIC and VERSATILE in the same manner.
126 - .withSelector(selector) 146 + FlowRule.Builder ruleBuilder = DefaultFlowRule.builder()
127 - .withTreatment(treatment) 147 + .forDevice(deviceId)
128 - .fromApp(fwd.appId()) 148 + .withSelector(selector)
129 - .withPriority(fwd.priority()); 149 + .fromApp(fwd.appId())
150 + .withPriority(fwd.priority())
151 + .withTreatment(fwd.treatment());
152 +
153 + if (fwd.permanent()) {
154 + ruleBuilder.makePermanent();
155 + } else {
156 + ruleBuilder.makeTemporary(fwd.timeout());
157 + }
158 + installObjective(ruleBuilder, fwd);
130 159
131 - if (fwd.permanent()) {
132 - ruleBuilder.makePermanent();
133 } else { 160 } else {
134 - ruleBuilder.makeTemporary(fwd.timeout()); 161 + NextObjective nextObjective = pendingNext.getIfPresent(fwd.nextId());
162 + if (nextObjective != null) {
163 + pendingNext.invalidate(fwd.nextId());
164 + nextObjective.next().forEach(treat -> {
165 + FlowRule.Builder ruleBuilder = DefaultFlowRule.builder()
166 + .forDevice(deviceId)
167 + .withSelector(selector)
168 + .fromApp(fwd.appId())
169 + .withPriority(fwd.priority())
170 + .withTreatment(treat);
171 +
172 + if (fwd.permanent()) {
173 + ruleBuilder.makePermanent();
174 + } else {
175 + ruleBuilder.makeTemporary(fwd.timeout());
176 + }
177 + installObjective(ruleBuilder, fwd);
178 + });
179 + } else {
180 + fwd.context().ifPresent(c -> c.onError(fwd,
181 + ObjectiveError.GROUPMISSING));
182 + }
135 } 183 }
136 -
137 - installObjective(ruleBuilder, fwd);
138 -
139 } 184 }
140 185
141 private void installObjective(FlowRule.Builder ruleBuilder, Objective objective) { 186 private void installObjective(FlowRule.Builder ruleBuilder, Objective objective) {
...@@ -168,6 +213,10 @@ public class DefaultSingleTablePipeline extends AbstractHandlerBehaviour impleme ...@@ -168,6 +213,10 @@ public class DefaultSingleTablePipeline extends AbstractHandlerBehaviour impleme
168 213
169 @Override 214 @Override
170 public void next(NextObjective nextObjective) { 215 public void next(NextObjective nextObjective) {
216 +
217 + pendingNext.put(nextObjective.id(), nextObjective);
218 + flowObjectiveStore.putNextGroup(nextObjective.id(),
219 + new SingleGroup(new DefaultGroupKey(appKryo.serialize(nextObjective.id()))));
171 } 220 }
172 221
173 @Override 222 @Override
...@@ -176,4 +225,22 @@ public class DefaultSingleTablePipeline extends AbstractHandlerBehaviour impleme ...@@ -176,4 +225,22 @@ public class DefaultSingleTablePipeline extends AbstractHandlerBehaviour impleme
176 return null; 225 return null;
177 } 226 }
178 227
228 + private class SingleGroup implements NextGroup {
229 +
230 + private final GroupKey key;
231 +
232 + public SingleGroup(GroupKey key) {
233 + this.key = key;
234 + }
235 +
236 + public GroupKey key() {
237 + return key;
238 + }
239 +
240 + @Override
241 + public byte[] data() {
242 + return appKryo.serialize(key);
243 + }
244 +
245 + }
179 } 246 }
......