blob: ecb51281350a0ce40abf9ae4d3e567f684d57f0c [file] [log] [blame]
Thomas Vachuska58de4162015-09-10 16:15:33 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
Thomas Vachuska58de4162015-09-10 16:15:33 -07003 *
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 */
Michele Santuari9a8d16d2016-03-24 10:37:58 -070016package org.onosproject.drivers.corsa;
Saurav Dasd8b97002015-05-14 23:42:49 -070017
18import org.onlab.packet.Ethernet;
19import org.onosproject.net.flow.DefaultFlowRule;
20import org.onosproject.net.flow.DefaultTrafficSelector;
21import org.onosproject.net.flow.DefaultTrafficTreatment;
22import org.onosproject.net.flow.FlowRule;
23import org.onosproject.net.flow.FlowRuleOperations;
24import org.onosproject.net.flow.FlowRuleOperationsContext;
25import org.onosproject.net.flow.TrafficSelector;
26import org.onosproject.net.flow.TrafficTreatment;
27import org.slf4j.Logger;
28
Michele Santuari9a8d16d2016-03-24 10:37:58 -070029import static org.slf4j.LoggerFactory.getLogger;
Jonathan Gravel8c9f7bc2015-12-03 15:46:20 -050030
Saurav Dasdecd7a62015-05-16 22:39:47 -070031/**
32 * Driver for Corsa TTP.
33 *
34 */
Michele Santuari9a8d16d2016-03-24 10:37:58 -070035public class CorsaPipelineV1 extends OvsCorsaPipeline {
Saurav Dasd8b97002015-05-14 23:42:49 -070036
37 private final Logger log = getLogger(getClass());
38
39 @Override
40 protected void processVlanMplsTable(boolean install) {
41 TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
42 TrafficTreatment.Builder treatment = DefaultTrafficTreatment
43 .builder();
44 FlowRuleOperations.Builder ops = FlowRuleOperations.builder();
45 FlowRule rule;
46 // corsa uses non-OF-standard way to match on presence of VLAN tags
47 selector.matchEthType(Ethernet.TYPE_VLAN);
48 treatment.transition(VLAN_TABLE);
49
50 rule = DefaultFlowRule.builder()
51 .forDevice(deviceId)
52 .withSelector(selector.build())
53 .withTreatment(treatment.build())
54 .withPriority(CONTROLLER_PRIORITY)
55 .fromApp(appId)
56 .makePermanent()
57 .forTable(VLAN_MPLS_TABLE).build();
58
Saurav Dasd8b97002015-05-14 23:42:49 -070059 ops = install ? ops.add(rule) : ops.remove(rule);
60
61 flowRuleService.apply(ops.build(new FlowRuleOperationsContext() {
62 @Override
63 public void onSuccess(FlowRuleOperations ops) {
64 log.info("Provisioned vlan/mpls table");
65 }
66
67 @Override
68 public void onError(FlowRuleOperations ops) {
69 log.info(
70 "Failed to provision vlan/mpls table");
71 }
72 }));
Jonathan Gravel8c9f7bc2015-12-03 15:46:20 -050073 }
Saurav Dasd8b97002015-05-14 23:42:49 -070074}