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
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2014-2016 Open Networking Laboratory
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>onos-drivers-general</artifactId>
<groupId>org.onosproject</groupId>
<version>1.6.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>onos-drivers-corsa</artifactId>
<packaging>bundle</packaging>
<description>Corsa device drivers</description>
<properties>
<onos.app.name>org.onosproject.drivers.corsa</onos.app.name>
<onos.app.origin>ON.Lab</onos.app.origin>
<onos.app.title>Corsa Device Drivers</onos.app.title>
<onos.app.category>Drivers</onos.app.category>
<onos.app.url>http://onosproject.org</onos.app.url>
<onos.app.requires>
org.onosproject.openflow
</onos.app.requires>
</properties>
<dependencies>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-of-api</artifactId>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>openflowj</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
/*
* Copyright 2014-2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.drivers.corsa;
import org.apache.felix.scr.annotations.Component;
import org.onosproject.net.driver.AbstractDriverLoader;
/**
* Loader for Corsa device drivers.
*/
@Component(immediate = true)
public class CorsaDriversLoader extends AbstractDriverLoader {
public CorsaDriversLoader() {
super("/corsa-drivers.xml");
}
}
......@@ -13,9 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.driver.pipeline;
import static org.slf4j.LoggerFactory.getLogger;
package org.onosproject.drivers.corsa;
import org.onlab.packet.Ethernet;
import org.onosproject.net.flow.DefaultFlowRule;
......@@ -26,18 +24,15 @@ import org.onosproject.net.flow.FlowRuleOperations;
import org.onosproject.net.flow.FlowRuleOperationsContext;
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.TrafficTreatment;
import org.onosproject.net.flowobjective.ForwardingObjective;
import org.onosproject.net.flowobjective.ObjectiveError;
import org.slf4j.Logger;
import java.util.Collection;
import java.util.Collections;
import static org.slf4j.LoggerFactory.getLogger;
/**
* Driver for Corsa TTP.
*
*/
public class CorsaPipeline extends OVSCorsaPipeline {
public class CorsaPipelineV1 extends OvsCorsaPipeline {
private final Logger log = getLogger(getClass());
......@@ -76,13 +71,4 @@ public class CorsaPipeline extends OVSCorsaPipeline {
}
}));
}
@Override
protected Collection<FlowRule> processSpecificSwitch(ForwardingObjective fwd) {
/* Not supported by until CorsaPipelineV3 */
log.warn("Vlan switching not supported in corsa-v1 driver");
fail(fwd, ObjectiveError.UNSUPPORTED);
return Collections.emptySet();
}
}
......
/*
* Copyright 2014-2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.drivers.corsa;
import org.onlab.packet.Ethernet;
import org.onlab.packet.IPv4;
import org.onlab.packet.VlanId;
import org.onosproject.net.flow.DefaultFlowRule;
import org.onosproject.net.flow.DefaultTrafficSelector;
import org.onosproject.net.flow.DefaultTrafficTreatment;
import org.onosproject.net.flow.FlowRule;
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.TrafficTreatment;
import org.onosproject.net.flow.criteria.Criterion;
import org.onosproject.net.flow.criteria.IPCriterion;
import org.onosproject.net.flow.criteria.IPProtocolCriterion;
import org.onosproject.net.flowobjective.ForwardingObjective;
import org.onosproject.net.flowobjective.ObjectiveError;
import org.slf4j.Logger;
import java.util.Collection;
import java.util.Collections;
import static org.onosproject.net.flow.FlowRule.Builder;
import static org.slf4j.LoggerFactory.getLogger;
public class CorsaPipelineV39 extends CorsaPipelineV3 {
private final Logger log = getLogger(getClass());
private static final Short NATIVE_VLAN = 4095;
@Override
public void initializePipeline() {
processMeterTable(true); //Meter Table
processPortBasedProtoTable(true);
processVlanCheckTable(true); //Table 1
processVlanMacXlateTable(true); //Table 2
processVlanCircuitTable(true); //Table 3
processL3IFMacDATable(true); //Table 5
processEtherTable(true); //Table 6
//TODO: to be implemented for intents
//processFibTable(true); //Table 7
//processLocalTable(true); //Table 9
}
@Override
protected void processVlanCheckTable(boolean install) {
//FIXME: error
processTableMissGoTo(true, VLAN_CHECK_TABLE, VLAN_MAC_XLATE_TABLE, "Provisioned vlan tagged");
//Tag untagged packets
processUntaggedPackets(install);
}
private void processUntaggedPackets(boolean install) {
deviceService.getPorts(deviceId).forEach(port -> {
if (!port.number().isLogical()) {
TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder()
.pushVlan().setVlanId(VlanId.vlanId(NATIVE_VLAN))
.transition(VLAN_MAC_XLATE_TABLE);
TrafficSelector.Builder selector = DefaultTrafficSelector.builder()
.matchVlanId(VlanId.NONE)
.matchInPort(port.number());
Builder rule = DefaultFlowRule.builder()
.forDevice(deviceId)
.withTreatment(treatment.build())
.withSelector(selector.build())
.withPriority(CONTROLLER_PRIORITY)
.fromApp(appId)
.makePermanent()
.forTable(VLAN_CHECK_TABLE);
processFlowRule(install, rule.build(), "Provisioned vlan untagged packet table");
}
});
}
@Override
protected void processVlanCircuitTable(boolean install) {
//Default action
processTableMissDrop(install, VLAN_CIRCUIT_TABLE, "Provisioned vlan circuit table drop");
//FIXME: it should be done only per port based when intent is installed
//Manage untagged packets
processRouterPacket(install);
}
private void processRouterPacket(boolean install) {
deviceService.getPorts(deviceId).forEach(port -> {
if (!port.number().isLogical()) {
TrafficSelector.Builder selector = DefaultTrafficSelector.builder()
.matchVlanId(VlanId.vlanId(NATIVE_VLAN))
.matchInPort(port.number());
TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder()
.setVlanPcp((byte) 0)
.setQueue(0)
.meter(defaultMeterId)
.transition(L3_IF_MAC_DA_TABLE);
FlowRule rule = DefaultFlowRule.builder()
.forDevice(deviceId)
.withSelector(selector.build())
.withTreatment(treatment.build())
.withPriority(CONTROLLER_PRIORITY)
.fromApp(appId)
.makePermanent()
.forTable(VLAN_CIRCUIT_TABLE).build();
processFlowRule(install, rule, "Provisioned vlan circuit table");
}
});
}
@Override
protected void processL3IFMacDATable(boolean install) {
int table = L3_IF_MAC_DA_TABLE;
//Default action
processTableMissDrop(install, table, "Provisioned l3 table drop");
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder()
.transition(ETHER_TABLE);
FlowRule rule = DefaultFlowRule.builder()
.forDevice(deviceId)
.withSelector(selector.build())
.withTreatment(treatment.build())
.withPriority(1)
.fromApp(appId)
.makePermanent()
.forTable(table).build();
processFlowRule(install, rule, "Provisioned l3 table");
}
protected void processEtherTable(boolean install) {
//Default action
processTableMissDrop(install, ETHER_TABLE, "Provisioned ether type table drop");
//IP to FIB_TABLE
TrafficSelector.Builder selector = DefaultTrafficSelector.builder()
.matchEthType(Ethernet.TYPE_IPV4);
TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder().transition(FIB_TABLE);
FlowRule rule = DefaultFlowRule.builder()
.forDevice(deviceId)
.withSelector(selector.build())
.withTreatment(treatment.build())
.withPriority(CONTROLLER_PRIORITY)
.fromApp(appId)
.makePermanent()
.forTable(ETHER_TABLE).build();
processFlowRule(install, rule, "Provisioned ether type table ip");
}
@Override
protected Collection<FlowRule> processArpTraffic(ForwardingObjective fwd, Builder rule) {
rule.forTable(PORT_BASED_PROTO_TABLE);
rule.withPriority(255);
return Collections.singletonList(rule.build());
}
@Override
protected Collection<FlowRule> processLinkDiscovery(ForwardingObjective fwd, Builder rule) {
rule.forTable(PORT_BASED_PROTO_TABLE);
rule.withPriority(255);
return Collections.singletonList(rule.build());
}
@Override
protected Collection<FlowRule> processIpTraffic(ForwardingObjective fwd, Builder rule) {
IPCriterion ipSrc = (IPCriterion) fwd.selector()
.getCriterion(Criterion.Type.IPV4_SRC);
if (ipSrc != null) {
log.warn("Driver does not currently handle matching Src IP");
fail(fwd, ObjectiveError.UNSUPPORTED);
return Collections.emptySet();
}
IPCriterion ipDst = (IPCriterion) fwd.selector()
.getCriterion(Criterion.Type.IPV4_DST);
if (ipDst != null) {
log.error("Driver handles Dst IP matching as specific forwarding "
+ "objective, not versatile");
fail(fwd, ObjectiveError.UNSUPPORTED);
return Collections.emptySet();
}
IPProtocolCriterion ipProto = (IPProtocolCriterion) fwd.selector()
.getCriterion(Criterion.Type.IP_PROTO);
if (ipProto != null && ipProto.protocol() == IPv4.PROTOCOL_TCP) {
log.warn("Driver automatically punts all packets reaching the "
+ "LOCAL table to the controller");
pass(fwd);
return Collections.emptySet();
}
return Collections.emptySet();
}
}
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.driver.handshaker;
package org.onosproject.drivers.corsa;
import org.onosproject.net.meter.MeterId;
import org.onosproject.openflow.controller.driver.AbstractOpenFlowSwitch;
......
/*
* Copyright 2014-2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Corsa drivers.
*/
package org.onosproject.drivers.corsa;
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2014-2016 Open Networking Laboratory
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<drivers>
<driver name="ovs-corsa" extends="ovs"
manufacturer="Corsa" hwVersion="emulation" swVersion="0.0.0">
<behaviour api="org.onosproject.net.behaviour.Pipeliner"
impl="org.onosproject.drivers.corsa.OvsCorsaPipeline"/>
</driver>
<driver name="corsa"
manufacturer="Corsa" hwVersion="Corsa Element" swVersion="2.3.1">
<behaviour api="org.onosproject.net.behaviour.Pipeliner"
impl="org.onosproject.drivers.corsa.CorsaPipelineV1"/>
<behaviour api="org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver"
impl="org.onosproject.drivers.corsa.CorsaSwitchHandshaker"/>
</driver>
<driver name="corsa-v1"
manufacturer="Corsa" hwVersion="Corsa Element" swVersion="2.3.1">
<behaviour api="org.onosproject.net.behaviour.Pipeliner"
impl="org.onosproject.drivers.corsa.CorsaPipelineV1"/>
<behaviour api="org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver"
impl="org.onosproject.drivers.corsa.CorsaSwitchHandshaker"/>
</driver>
<driver name="corsa-v3"
manufacturer="Corsa" hwVersion="Corsa Element" swVersion="2.3.1">
<behaviour api="org.onosproject.net.behaviour.Pipeliner"
impl="org.onosproject.drivers.corsa.CorsaPipelineV3"/>
<behaviour api="org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver"
impl="org.onosproject.drivers.corsa.CorsaSwitchHandshaker"/>
</driver>
<driver name="corsa-v39"
manufacturer="Corsa" hwVersion="CDP6420-A00" swVersion="corsa-ovs-datapath 1.4.88">
<behaviour api="org.onosproject.net.behaviour.Pipeliner"
impl="org.onosproject.drivers.corsa.CorsaPipelineV39"/>
<behaviour api="org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver"
impl="org.onosproject.drivers.corsa.CorsaSwitchHandshaker"/>
</driver>
</drivers>
\ No newline at end of file
......@@ -39,11 +39,6 @@
<behaviour api="org.onosproject.net.behaviour.MplsQuery"
impl="org.onosproject.driver.query.FullMplsAvailable" />
</driver>
<driver name="ovs-corsa" extends="ovs"
manufacturer="Corsa" hwVersion="emulation" swVersion="0.0.0">
<behaviour api="org.onosproject.net.behaviour.Pipeliner"
impl="org.onosproject.driver.pipeline.OVSCorsaPipeline"/>
</driver>
<!-- Emulation of the spring-open pipeline using a CPqD OF 1.3 software switch.
~ This driver is the default driver assigned to the CPqD switch.
-->
......@@ -67,27 +62,6 @@
<behaviour api="org.onosproject.net.behaviour.LambdaQuery"
impl="org.onosproject.driver.query.LincOELambdaQuery"/>
</driver>
<driver name="corsa"
manufacturer="Corsa" hwVersion="Corsa Element" swVersion="2.3.1">
<behaviour api="org.onosproject.net.behaviour.Pipeliner"
impl="org.onosproject.driver.pipeline.CorsaPipeline"/>
<behaviour api="org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver"
impl="org.onosproject.driver.handshaker.CorsaSwitchHandshaker"/>
</driver>
<driver name="corsa-v1"
manufacturer="Corsa" hwVersion="Corsa Element" swVersion="2.3.1">
<behaviour api="org.onosproject.net.behaviour.Pipeliner"
impl="org.onosproject.driver.pipeline.CorsaPipeline"/>
<behaviour api="org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver"
impl="org.onosproject.driver.handshaker.CorsaSwitchHandshaker"/>
</driver>
<driver name="corsa-v3"
manufacturer="Corsa" hwVersion="Corsa Element" swVersion="2.3.1">
<behaviour api="org.onosproject.net.behaviour.Pipeliner"
impl="org.onosproject.driver.pipeline.CorsaPipelineV3"/>
<behaviour api="org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver"
impl="org.onosproject.driver.handshaker.CorsaSwitchHandshaker"/>
</driver>
<driver name="ofdpa" extends="default"
manufacturer="Broadcom Corp." hwVersion="OF-DPA.*" swVersion="OF-DPA.*">
<behaviour api="org.onosproject.net.behaviour.Pipeliner"
......
......@@ -42,6 +42,7 @@
<module>lumentum</module>
<module>bti</module>
<module>bmv2</module>
<module>corsa</module>
</modules>
<!--<properties>
......