blob: c640bff64b0eaa4a642ba27b0f93fff60259ae2e [file] [log] [blame]
Thomas Vachuska58de4162015-09-10 16:15:33 -07001/*
2 * Copyright 2015 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 */
Saurav Dasd8b97002015-05-14 23:42:49 -070016package org.onosproject.driver.pipeline;
17
18import static org.slf4j.LoggerFactory.getLogger;
19
20import org.onlab.packet.Ethernet;
21import org.onosproject.net.flow.DefaultFlowRule;
22import org.onosproject.net.flow.DefaultTrafficSelector;
23import org.onosproject.net.flow.DefaultTrafficTreatment;
24import org.onosproject.net.flow.FlowRule;
25import org.onosproject.net.flow.FlowRuleOperations;
26import org.onosproject.net.flow.FlowRuleOperationsContext;
27import org.onosproject.net.flow.TrafficSelector;
28import org.onosproject.net.flow.TrafficTreatment;
Jonathan Gravel8c9f7bc2015-12-03 15:46:20 -050029import org.onosproject.net.flowobjective.ForwardingObjective;
30import org.onosproject.net.flowobjective.ObjectiveError;
Saurav Dasd8b97002015-05-14 23:42:49 -070031import org.slf4j.Logger;
32
Jonathan Gravel8c9f7bc2015-12-03 15:46:20 -050033import java.util.Collection;
34import java.util.Collections;
35
Saurav Dasdecd7a62015-05-16 22:39:47 -070036/**
37 * Driver for Corsa TTP.
38 *
39 */
Saurav Dasd8b97002015-05-14 23:42:49 -070040public class CorsaPipeline extends OVSCorsaPipeline {
41
42 private final Logger log = getLogger(getClass());
43
44 @Override
45 protected void processVlanMplsTable(boolean install) {
46 TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
47 TrafficTreatment.Builder treatment = DefaultTrafficTreatment
48 .builder();
49 FlowRuleOperations.Builder ops = FlowRuleOperations.builder();
50 FlowRule rule;
51 // corsa uses non-OF-standard way to match on presence of VLAN tags
52 selector.matchEthType(Ethernet.TYPE_VLAN);
53 treatment.transition(VLAN_TABLE);
54
55 rule = DefaultFlowRule.builder()
56 .forDevice(deviceId)
57 .withSelector(selector.build())
58 .withTreatment(treatment.build())
59 .withPriority(CONTROLLER_PRIORITY)
60 .fromApp(appId)
61 .makePermanent()
62 .forTable(VLAN_MPLS_TABLE).build();
63
Saurav Dasd8b97002015-05-14 23:42:49 -070064 ops = install ? ops.add(rule) : ops.remove(rule);
65
66 flowRuleService.apply(ops.build(new FlowRuleOperationsContext() {
67 @Override
68 public void onSuccess(FlowRuleOperations ops) {
69 log.info("Provisioned vlan/mpls table");
70 }
71
72 @Override
73 public void onError(FlowRuleOperations ops) {
74 log.info(
75 "Failed to provision vlan/mpls table");
76 }
77 }));
Jonathan Gravel8c9f7bc2015-12-03 15:46:20 -050078 }
Saurav Dasd8b97002015-05-14 23:42:49 -070079
Jonathan Gravel8c9f7bc2015-12-03 15:46:20 -050080 @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();
Saurav Dasd8b97002015-05-14 23:42:49 -070086 }
87
88}