Thomas Vachuska | 58de416 | 2015-09-10 16:15:33 -0700 | [diff] [blame] | 1 | /* |
| 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 Das | d8b9700 | 2015-05-14 23:42:49 -0700 | [diff] [blame] | 16 | package org.onosproject.driver.pipeline; |
| 17 | |
| 18 | import static org.slf4j.LoggerFactory.getLogger; |
| 19 | |
| 20 | import org.onlab.packet.Ethernet; |
| 21 | import org.onosproject.net.flow.DefaultFlowRule; |
| 22 | import org.onosproject.net.flow.DefaultTrafficSelector; |
| 23 | import org.onosproject.net.flow.DefaultTrafficTreatment; |
| 24 | import org.onosproject.net.flow.FlowRule; |
| 25 | import org.onosproject.net.flow.FlowRuleOperations; |
| 26 | import org.onosproject.net.flow.FlowRuleOperationsContext; |
| 27 | import org.onosproject.net.flow.TrafficSelector; |
| 28 | import org.onosproject.net.flow.TrafficTreatment; |
Jonathan Gravel | 8c9f7bc | 2015-12-03 15:46:20 -0500 | [diff] [blame] | 29 | import org.onosproject.net.flowobjective.ForwardingObjective; |
| 30 | import org.onosproject.net.flowobjective.ObjectiveError; |
Saurav Das | d8b9700 | 2015-05-14 23:42:49 -0700 | [diff] [blame] | 31 | import org.slf4j.Logger; |
| 32 | |
Jonathan Gravel | 8c9f7bc | 2015-12-03 15:46:20 -0500 | [diff] [blame] | 33 | import java.util.Collection; |
| 34 | import java.util.Collections; |
| 35 | |
Saurav Das | decd7a6 | 2015-05-16 22:39:47 -0700 | [diff] [blame] | 36 | /** |
| 37 | * Driver for Corsa TTP. |
| 38 | * |
| 39 | */ |
Saurav Das | d8b9700 | 2015-05-14 23:42:49 -0700 | [diff] [blame] | 40 | public 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 Das | d8b9700 | 2015-05-14 23:42:49 -0700 | [diff] [blame] | 64 | 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 Gravel | 8c9f7bc | 2015-12-03 15:46:20 -0500 | [diff] [blame] | 78 | } |
Saurav Das | d8b9700 | 2015-05-14 23:42:49 -0700 | [diff] [blame] | 79 | |
Jonathan Gravel | 8c9f7bc | 2015-12-03 15:46:20 -0500 | [diff] [blame] | 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(); |
Saurav Das | d8b9700 | 2015-05-14 23:42:49 -0700 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | } |