Michele Santuari
Committed by Gerrit Code Review

initial flows for corsa pipeline v39

- initial flows configuration
- moved to a dedicated folder
- refactoring super classes

Change-Id: Ie7452aed35d7947ca5f7246dd06fcbb87b2971b5
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<!--
3 + ~ Copyright 2014-2016 Open Networking Laboratory
4 + ~
5 + ~ Licensed under the Apache License, Version 2.0 (the "License");
6 + ~ you may not use this file except in compliance with the License.
7 + ~ You may obtain a copy of the License at
8 + ~
9 + ~ http://www.apache.org/licenses/LICENSE-2.0
10 + ~
11 + ~ Unless required by applicable law or agreed to in writing, software
12 + ~ distributed under the License is distributed on an "AS IS" BASIS,
13 + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 + ~ See the License for the specific language governing permissions and
15 + ~ limitations under the License.
16 + -->
17 +
18 +<project xmlns="http://maven.apache.org/POM/4.0.0"
19 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
20 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
21 + <parent>
22 + <artifactId>onos-drivers-general</artifactId>
23 + <groupId>org.onosproject</groupId>
24 + <version>1.6.0-SNAPSHOT</version>
25 + </parent>
26 + <modelVersion>4.0.0</modelVersion>
27 +
28 + <artifactId>onos-drivers-corsa</artifactId>
29 + <packaging>bundle</packaging>
30 +
31 + <description>Corsa device drivers</description>
32 +
33 + <properties>
34 + <onos.app.name>org.onosproject.drivers.corsa</onos.app.name>
35 + <onos.app.origin>ON.Lab</onos.app.origin>
36 + <onos.app.title>Corsa Device Drivers</onos.app.title>
37 + <onos.app.category>Drivers</onos.app.category>
38 + <onos.app.url>http://onosproject.org</onos.app.url>
39 + <onos.app.requires>
40 + org.onosproject.openflow
41 + </onos.app.requires>
42 + </properties>
43 +
44 + <dependencies>
45 + <dependency>
46 + <groupId>org.onosproject</groupId>
47 + <artifactId>onos-of-api</artifactId>
48 + </dependency>
49 + <dependency>
50 + <groupId>org.onosproject</groupId>
51 + <artifactId>openflowj</artifactId>
52 + </dependency>
53 + </dependencies>
54 +
55 +</project>
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2014-2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.drivers.corsa;
18 +
19 +import org.apache.felix.scr.annotations.Component;
20 +import org.onosproject.net.driver.AbstractDriverLoader;
21 +
22 +/**
23 + * Loader for Corsa device drivers.
24 + */
25 +@Component(immediate = true)
26 +public class CorsaDriversLoader extends AbstractDriverLoader {
27 + public CorsaDriversLoader() {
28 + super("/corsa-drivers.xml");
29 + }
30 +}
...@@ -13,9 +13,7 @@ ...@@ -13,9 +13,7 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 -package org.onosproject.driver.pipeline; 16 +package org.onosproject.drivers.corsa;
17 -
18 -import static org.slf4j.LoggerFactory.getLogger;
19 17
20 import org.onlab.packet.Ethernet; 18 import org.onlab.packet.Ethernet;
21 import org.onosproject.net.flow.DefaultFlowRule; 19 import org.onosproject.net.flow.DefaultFlowRule;
...@@ -26,18 +24,15 @@ import org.onosproject.net.flow.FlowRuleOperations; ...@@ -26,18 +24,15 @@ import org.onosproject.net.flow.FlowRuleOperations;
26 import org.onosproject.net.flow.FlowRuleOperationsContext; 24 import org.onosproject.net.flow.FlowRuleOperationsContext;
27 import org.onosproject.net.flow.TrafficSelector; 25 import org.onosproject.net.flow.TrafficSelector;
28 import org.onosproject.net.flow.TrafficTreatment; 26 import org.onosproject.net.flow.TrafficTreatment;
29 -import org.onosproject.net.flowobjective.ForwardingObjective;
30 -import org.onosproject.net.flowobjective.ObjectiveError;
31 import org.slf4j.Logger; 27 import org.slf4j.Logger;
32 28
33 -import java.util.Collection; 29 +import static org.slf4j.LoggerFactory.getLogger;
34 -import java.util.Collections;
35 30
36 /** 31 /**
37 * Driver for Corsa TTP. 32 * Driver for Corsa TTP.
38 * 33 *
39 */ 34 */
40 -public class CorsaPipeline extends OVSCorsaPipeline { 35 +public class CorsaPipelineV1 extends OvsCorsaPipeline {
41 36
42 private final Logger log = getLogger(getClass()); 37 private final Logger log = getLogger(getClass());
43 38
...@@ -76,13 +71,4 @@ public class CorsaPipeline extends OVSCorsaPipeline { ...@@ -76,13 +71,4 @@ public class CorsaPipeline extends OVSCorsaPipeline {
76 } 71 }
77 })); 72 }));
78 } 73 }
79 -
80 - @Override
81 - protected Collection<FlowRule> processSpecificSwitch(ForwardingObjective fwd) {
82 - /* Not supported by until CorsaPipelineV3 */
83 - log.warn("Vlan switching not supported in corsa-v1 driver");
84 - fail(fwd, ObjectiveError.UNSUPPORTED);
85 - return Collections.emptySet();
86 - }
87 -
88 } 74 }
......
1 +/*
2 + * Copyright 2014-2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.drivers.corsa;
18 +
19 +import org.onlab.packet.Ethernet;
20 +import org.onlab.packet.IPv4;
21 +import org.onlab.packet.VlanId;
22 +import org.onosproject.net.flow.DefaultFlowRule;
23 +import org.onosproject.net.flow.DefaultTrafficSelector;
24 +import org.onosproject.net.flow.DefaultTrafficTreatment;
25 +import org.onosproject.net.flow.FlowRule;
26 +import org.onosproject.net.flow.TrafficSelector;
27 +import org.onosproject.net.flow.TrafficTreatment;
28 +import org.onosproject.net.flow.criteria.Criterion;
29 +import org.onosproject.net.flow.criteria.IPCriterion;
30 +import org.onosproject.net.flow.criteria.IPProtocolCriterion;
31 +import org.onosproject.net.flowobjective.ForwardingObjective;
32 +import org.onosproject.net.flowobjective.ObjectiveError;
33 +import org.slf4j.Logger;
34 +
35 +import java.util.Collection;
36 +import java.util.Collections;
37 +
38 +import static org.onosproject.net.flow.FlowRule.Builder;
39 +import static org.slf4j.LoggerFactory.getLogger;
40 +
41 +public class CorsaPipelineV39 extends CorsaPipelineV3 {
42 +
43 + private final Logger log = getLogger(getClass());
44 +
45 + private static final Short NATIVE_VLAN = 4095;
46 +
47 + @Override
48 + public void initializePipeline() {
49 +
50 + processMeterTable(true); //Meter Table
51 + processPortBasedProtoTable(true);
52 + processVlanCheckTable(true); //Table 1
53 + processVlanMacXlateTable(true); //Table 2
54 + processVlanCircuitTable(true); //Table 3
55 + processL3IFMacDATable(true); //Table 5
56 + processEtherTable(true); //Table 6
57 + //TODO: to be implemented for intents
58 + //processFibTable(true); //Table 7
59 + //processLocalTable(true); //Table 9
60 + }
61 +
62 + @Override
63 + protected void processVlanCheckTable(boolean install) {
64 + //FIXME: error
65 + processTableMissGoTo(true, VLAN_CHECK_TABLE, VLAN_MAC_XLATE_TABLE, "Provisioned vlan tagged");
66 + //Tag untagged packets
67 + processUntaggedPackets(install);
68 +
69 + }
70 +
71 + private void processUntaggedPackets(boolean install) {
72 +
73 + deviceService.getPorts(deviceId).forEach(port -> {
74 + if (!port.number().isLogical()) {
75 +
76 + TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder()
77 + .pushVlan().setVlanId(VlanId.vlanId(NATIVE_VLAN))
78 + .transition(VLAN_MAC_XLATE_TABLE);
79 +
80 + TrafficSelector.Builder selector = DefaultTrafficSelector.builder()
81 + .matchVlanId(VlanId.NONE)
82 + .matchInPort(port.number());
83 +
84 + Builder rule = DefaultFlowRule.builder()
85 + .forDevice(deviceId)
86 + .withTreatment(treatment.build())
87 + .withSelector(selector.build())
88 + .withPriority(CONTROLLER_PRIORITY)
89 + .fromApp(appId)
90 + .makePermanent()
91 + .forTable(VLAN_CHECK_TABLE);
92 +
93 + processFlowRule(install, rule.build(), "Provisioned vlan untagged packet table");
94 + }
95 + });
96 + }
97 +
98 + @Override
99 + protected void processVlanCircuitTable(boolean install) {
100 + //Default action
101 + processTableMissDrop(install, VLAN_CIRCUIT_TABLE, "Provisioned vlan circuit table drop");
102 + //FIXME: it should be done only per port based when intent is installed
103 + //Manage untagged packets
104 + processRouterPacket(install);
105 + }
106 +
107 + private void processRouterPacket(boolean install) {
108 +
109 + deviceService.getPorts(deviceId).forEach(port -> {
110 + if (!port.number().isLogical()) {
111 + TrafficSelector.Builder selector = DefaultTrafficSelector.builder()
112 + .matchVlanId(VlanId.vlanId(NATIVE_VLAN))
113 + .matchInPort(port.number());
114 +
115 + TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder()
116 + .setVlanPcp((byte) 0)
117 + .setQueue(0)
118 + .meter(defaultMeterId)
119 + .transition(L3_IF_MAC_DA_TABLE);
120 +
121 + FlowRule rule = DefaultFlowRule.builder()
122 + .forDevice(deviceId)
123 + .withSelector(selector.build())
124 + .withTreatment(treatment.build())
125 + .withPriority(CONTROLLER_PRIORITY)
126 + .fromApp(appId)
127 + .makePermanent()
128 + .forTable(VLAN_CIRCUIT_TABLE).build();
129 + processFlowRule(install, rule, "Provisioned vlan circuit table");
130 + }
131 + });
132 + }
133 +
134 + @Override
135 + protected void processL3IFMacDATable(boolean install) {
136 + int table = L3_IF_MAC_DA_TABLE;
137 +
138 + //Default action
139 + processTableMissDrop(install, table, "Provisioned l3 table drop");
140 +
141 + TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
142 +
143 + TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder()
144 + .transition(ETHER_TABLE);
145 +
146 + FlowRule rule = DefaultFlowRule.builder()
147 + .forDevice(deviceId)
148 + .withSelector(selector.build())
149 + .withTreatment(treatment.build())
150 + .withPriority(1)
151 + .fromApp(appId)
152 + .makePermanent()
153 + .forTable(table).build();
154 + processFlowRule(install, rule, "Provisioned l3 table");
155 + }
156 +
157 + protected void processEtherTable(boolean install) {
158 +
159 + //Default action
160 + processTableMissDrop(install, ETHER_TABLE, "Provisioned ether type table drop");
161 +
162 + //IP to FIB_TABLE
163 + TrafficSelector.Builder selector = DefaultTrafficSelector.builder()
164 + .matchEthType(Ethernet.TYPE_IPV4);
165 +
166 + TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder().transition(FIB_TABLE);
167 +
168 + FlowRule rule = DefaultFlowRule.builder()
169 + .forDevice(deviceId)
170 + .withSelector(selector.build())
171 + .withTreatment(treatment.build())
172 + .withPriority(CONTROLLER_PRIORITY)
173 + .fromApp(appId)
174 + .makePermanent()
175 + .forTable(ETHER_TABLE).build();
176 + processFlowRule(install, rule, "Provisioned ether type table ip");
177 + }
178 +
179 + @Override
180 + protected Collection<FlowRule> processArpTraffic(ForwardingObjective fwd, Builder rule) {
181 + rule.forTable(PORT_BASED_PROTO_TABLE);
182 + rule.withPriority(255);
183 + return Collections.singletonList(rule.build());
184 + }
185 +
186 + @Override
187 + protected Collection<FlowRule> processLinkDiscovery(ForwardingObjective fwd, Builder rule) {
188 + rule.forTable(PORT_BASED_PROTO_TABLE);
189 + rule.withPriority(255);
190 + return Collections.singletonList(rule.build());
191 + }
192 +
193 + @Override
194 + protected Collection<FlowRule> processIpTraffic(ForwardingObjective fwd, Builder rule) {
195 + IPCriterion ipSrc = (IPCriterion) fwd.selector()
196 + .getCriterion(Criterion.Type.IPV4_SRC);
197 + if (ipSrc != null) {
198 + log.warn("Driver does not currently handle matching Src IP");
199 + fail(fwd, ObjectiveError.UNSUPPORTED);
200 + return Collections.emptySet();
201 + }
202 + IPCriterion ipDst = (IPCriterion) fwd.selector()
203 + .getCriterion(Criterion.Type.IPV4_DST);
204 + if (ipDst != null) {
205 + log.error("Driver handles Dst IP matching as specific forwarding "
206 + + "objective, not versatile");
207 + fail(fwd, ObjectiveError.UNSUPPORTED);
208 + return Collections.emptySet();
209 + }
210 + IPProtocolCriterion ipProto = (IPProtocolCriterion) fwd.selector()
211 + .getCriterion(Criterion.Type.IP_PROTO);
212 + if (ipProto != null && ipProto.protocol() == IPv4.PROTOCOL_TCP) {
213 + log.warn("Driver automatically punts all packets reaching the "
214 + + "LOCAL table to the controller");
215 + pass(fwd);
216 + return Collections.emptySet();
217 + }
218 + return Collections.emptySet();
219 + }
220 +}
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 -package org.onosproject.driver.handshaker; 16 +package org.onosproject.drivers.corsa;
17 17
18 import org.onosproject.net.meter.MeterId; 18 import org.onosproject.net.meter.MeterId;
19 import org.onosproject.openflow.controller.driver.AbstractOpenFlowSwitch; 19 import org.onosproject.openflow.controller.driver.AbstractOpenFlowSwitch;
......
1 +/*
2 + * Copyright 2014-2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +/**
18 + * Corsa drivers.
19 + */
20 +package org.onosproject.drivers.corsa;
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<!--
3 + ~ Copyright 2014-2016 Open Networking Laboratory
4 + ~
5 + ~ Licensed under the Apache License, Version 2.0 (the "License");
6 + ~ you may not use this file except in compliance with the License.
7 + ~ You may obtain a copy of the License at
8 + ~
9 + ~ http://www.apache.org/licenses/LICENSE-2.0
10 + ~
11 + ~ Unless required by applicable law or agreed to in writing, software
12 + ~ distributed under the License is distributed on an "AS IS" BASIS,
13 + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 + ~ See the License for the specific language governing permissions and
15 + ~ limitations under the License.
16 + -->
17 +<drivers>
18 + <driver name="ovs-corsa" extends="ovs"
19 + manufacturer="Corsa" hwVersion="emulation" swVersion="0.0.0">
20 + <behaviour api="org.onosproject.net.behaviour.Pipeliner"
21 + impl="org.onosproject.drivers.corsa.OvsCorsaPipeline"/>
22 + </driver>
23 + <driver name="corsa"
24 + manufacturer="Corsa" hwVersion="Corsa Element" swVersion="2.3.1">
25 + <behaviour api="org.onosproject.net.behaviour.Pipeliner"
26 + impl="org.onosproject.drivers.corsa.CorsaPipelineV1"/>
27 + <behaviour api="org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver"
28 + impl="org.onosproject.drivers.corsa.CorsaSwitchHandshaker"/>
29 + </driver>
30 + <driver name="corsa-v1"
31 + manufacturer="Corsa" hwVersion="Corsa Element" swVersion="2.3.1">
32 + <behaviour api="org.onosproject.net.behaviour.Pipeliner"
33 + impl="org.onosproject.drivers.corsa.CorsaPipelineV1"/>
34 + <behaviour api="org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver"
35 + impl="org.onosproject.drivers.corsa.CorsaSwitchHandshaker"/>
36 + </driver>
37 + <driver name="corsa-v3"
38 + manufacturer="Corsa" hwVersion="Corsa Element" swVersion="2.3.1">
39 + <behaviour api="org.onosproject.net.behaviour.Pipeliner"
40 + impl="org.onosproject.drivers.corsa.CorsaPipelineV3"/>
41 + <behaviour api="org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver"
42 + impl="org.onosproject.drivers.corsa.CorsaSwitchHandshaker"/>
43 + </driver>
44 + <driver name="corsa-v39"
45 + manufacturer="Corsa" hwVersion="CDP6420-A00" swVersion="corsa-ovs-datapath 1.4.88">
46 + <behaviour api="org.onosproject.net.behaviour.Pipeliner"
47 + impl="org.onosproject.drivers.corsa.CorsaPipelineV39"/>
48 + <behaviour api="org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver"
49 + impl="org.onosproject.drivers.corsa.CorsaSwitchHandshaker"/>
50 + </driver>
51 +</drivers>
...\ No newline at end of file ...\ No newline at end of file
...@@ -39,11 +39,6 @@ ...@@ -39,11 +39,6 @@
39 <behaviour api="org.onosproject.net.behaviour.MplsQuery" 39 <behaviour api="org.onosproject.net.behaviour.MplsQuery"
40 impl="org.onosproject.driver.query.FullMplsAvailable" /> 40 impl="org.onosproject.driver.query.FullMplsAvailable" />
41 </driver> 41 </driver>
42 - <driver name="ovs-corsa" extends="ovs"
43 - manufacturer="Corsa" hwVersion="emulation" swVersion="0.0.0">
44 - <behaviour api="org.onosproject.net.behaviour.Pipeliner"
45 - impl="org.onosproject.driver.pipeline.OVSCorsaPipeline"/>
46 - </driver>
47 <!-- Emulation of the spring-open pipeline using a CPqD OF 1.3 software switch. 42 <!-- Emulation of the spring-open pipeline using a CPqD OF 1.3 software switch.
48 ~ This driver is the default driver assigned to the CPqD switch. 43 ~ This driver is the default driver assigned to the CPqD switch.
49 --> 44 -->
...@@ -67,27 +62,6 @@ ...@@ -67,27 +62,6 @@
67 <behaviour api="org.onosproject.net.behaviour.LambdaQuery" 62 <behaviour api="org.onosproject.net.behaviour.LambdaQuery"
68 impl="org.onosproject.driver.query.LincOELambdaQuery"/> 63 impl="org.onosproject.driver.query.LincOELambdaQuery"/>
69 </driver> 64 </driver>
70 - <driver name="corsa"
71 - manufacturer="Corsa" hwVersion="Corsa Element" swVersion="2.3.1">
72 - <behaviour api="org.onosproject.net.behaviour.Pipeliner"
73 - impl="org.onosproject.driver.pipeline.CorsaPipeline"/>
74 - <behaviour api="org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver"
75 - impl="org.onosproject.driver.handshaker.CorsaSwitchHandshaker"/>
76 - </driver>
77 - <driver name="corsa-v1"
78 - manufacturer="Corsa" hwVersion="Corsa Element" swVersion="2.3.1">
79 - <behaviour api="org.onosproject.net.behaviour.Pipeliner"
80 - impl="org.onosproject.driver.pipeline.CorsaPipeline"/>
81 - <behaviour api="org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver"
82 - impl="org.onosproject.driver.handshaker.CorsaSwitchHandshaker"/>
83 - </driver>
84 - <driver name="corsa-v3"
85 - manufacturer="Corsa" hwVersion="Corsa Element" swVersion="2.3.1">
86 - <behaviour api="org.onosproject.net.behaviour.Pipeliner"
87 - impl="org.onosproject.driver.pipeline.CorsaPipelineV3"/>
88 - <behaviour api="org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver"
89 - impl="org.onosproject.driver.handshaker.CorsaSwitchHandshaker"/>
90 - </driver>
91 <driver name="ofdpa" extends="default" 65 <driver name="ofdpa" extends="default"
92 manufacturer="Broadcom Corp." hwVersion="OF-DPA.*" swVersion="OF-DPA.*"> 66 manufacturer="Broadcom Corp." hwVersion="OF-DPA.*" swVersion="OF-DPA.*">
93 <behaviour api="org.onosproject.net.behaviour.Pipeliner" 67 <behaviour api="org.onosproject.net.behaviour.Pipeliner"
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
42 <module>lumentum</module> 42 <module>lumentum</module>
43 <module>bti</module> 43 <module>bti</module>
44 <module>bmv2</module> 44 <module>bmv2</module>
45 + <module>corsa</module>
45 </modules> 46 </modules>
46 47
47 <!--<properties> 48 <!--<properties>
......